Skip to content

Commit

Permalink
version 4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
peteroupc committed Oct 2, 2019
1 parent 9c8a782 commit 06f4f1a
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 119 deletions.
52 changes: 3 additions & 49 deletions CBOR.nuspec
Original file line number Diff line number Diff line change
@@ -1,51 +1,5 @@
<package
><metadata><version>4.0.0</version><id>PeterO.Cbor</id><requireLicenseAcceptance>false</requireLicenseAcceptance><releaseNotes>Version 4.0.0:
><metadata><version>4.0.1</version><id>PeterO.Cbor</id><requireLicenseAcceptance>false</requireLicenseAcceptance><releaseNotes>Version 4.0.1:

- Fix issues with CTAP2 Canonical CBOR form
- Support field serialization and deserialization in ToObject and FromObject

Version 4.0.0-beta2:

The features in this version include:

- The CBOR library no longer stores numbers in a special form beyond the CBOR data model, which represents all &quot;65-bit&quot; signed integers and all &quot;double&quot; values. This means the CBOR library no longer stores certain numbers as EDecimal, EInteger, EFloat, etc., rather than as tagged CBOR objects.
- CBORObject.CompareTo now compares objects using the default deterministic encoding comparison in the draft revision of the CBOR specification, and no longer treats numbers (objects with the former type CBORType.Number) as a special class.
- CBORType.Number is deprecated; CBORObjects no longer have this type. In its place, certain numbers now have new CBORTypes Integer or FloatingPoint.
- CBORObject now stores floating-point numbers internally as the bits that make them up, rather than as `double`s, to avoid data loss in conversions.
- Methods were added to CBORObject to read and write floating-point numbers in terms of their bit patterns rather than as `double`s or `float`s.
- Ctap2Canonical was made more strict and now works when decoding CBOR objects.
- Added ReadSequence and DecodeSequence to CBORObject for reading CBOR sequences.
- New CBORNumber class for storing numbers representable in CBOR. The new CBORObject.IsNumber property checks whether a CBOR object represents a number.
- Bug fixes

Version 4.0.0-beta1:

- Support nullable types in CBORObject.ToObject.
- Update Numbers library to newer version
- JSONOptions.Base64Padding now has no effect. The library will now write padding as necessary when
writing traditional base64 to JSON and write no padding when writing base64url to JSON.
- JSONOptions.ReplaceSurrogates property added.
- Restrict valid shared reference indices to integers 0 or greater.
- Reject writing JSON where CBOR maps have two keys with the same string equivalent.
- Improve performance of CBOR object comparisons involving big floats.

Version 4.0.0-alpha2:

- Support CBOR tags for IRIs and IRI references.
- Add CBOREncodeOptions.DefaultCtap2Canonical field.

Version 4.0.0-alpha1:

- Remove all APIs obsoleted since version 3.4. This
includes the BigInteger, ExtendedDecimal, and ExtendedFloat APIs,
which were renamed and moved to a different library, as well as the
ICBORTag and CBORTypeFilter APIs.
- Changed implementation of FromObject, including imposing a nesting depth
limit and supporting a CBORTypeMapper parameter.
- Property name conversion rules (in PODOptions) were changed
in this version with respect to FromObject. In this sense,
PODOptions.RemoveIsPrefix was removed.
- Certain other changes in CBOR object reading and validation were
made; they are largely compatible with previous versions but may be
backwards-incompatible in certain rare cases</releaseNotes><summary></summary><license type='expression'>CC0-1.0</license><projectUrl>https://github.com/peteroupc/CBOR</projectUrl><authors>Peter Occil</authors><description>A C# implementation of Concise Binary Object Representation (CBOR), a general-purpose binary data format defined in RFC 7049.</description><owners>Peter Occil</owners><title>CBOR (Concise Binary Object Representation)</title><tags>cbor data serialization binary json</tags><dependencies><group><dependency id='PeterO.Numbers' version='1.4.3' /></group></dependencies></metadata><files><file src='CBOR/bin/Release/netstandard1.0/CBOR.dll' target='/lib/netstandard1.0' /><file src='CBOR/bin/Release/netstandard1.0/CBOR.xml' target='/lib/netstandard1.0' /><file src='CBOR20/bin/Release/CBOR.dll' target='/lib/net20' /><file src='CBOR20/bin/Release/CBOR.xml' target='/lib/net20' /><file src='CBOR40/bin/Release/CBOR.dll' target='/lib/net40' /><file src='CBOR40/bin/Release/CBOR.xml' target='/lib/net40' /></files></package
>
- Fix issue with unexpected CBORObject#ToString result for True and False.</releaseNotes><summary></summary><license type='expression'>CC0-1.0</license><projectUrl>https://github.com/peteroupc/CBOR</projectUrl><authors>Peter Occil</authors><description>A C# implementation of Concise Binary Object Representation (CBOR), a general-purpose binary data format defined in RFC 7049.</description><owners>Peter Occil</owners><title>CBOR (Concise Binary Object Representation)</title><tags>cbor data serialization binary json</tags><dependencies><group><dependency id='PeterO.Numbers' version='1.4.3' /></group></dependencies></metadata><files><file src='CBOR/bin/Release/netstandard1.0/CBOR.dll' target='/lib/netstandard1.0' /><file src='CBOR/bin/Release/netstandard1.0/CBOR.xml' target='/lib/netstandard1.0' /><file src='CBOR20/bin/Release/CBOR.dll' target='/lib/net20' /><file src='CBOR20/bin/Release/CBOR.xml' target='/lib/net20' /><file src='CBOR40/bin/Release/CBOR.dll' target='/lib/net40' /><file src='CBOR40/bin/Release/CBOR.xml' target='/lib/net40' /></files></package
>
10 changes: 3 additions & 7 deletions CBOR/CBOR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.0</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>4.0.0</Version>
<Version>4.0.1</Version>
<Owners>Peter Occil</Owners>
<Description>A C# implementation of Concise Binary Object Representation (CBOR), a general-purpose binary data format defined in RFC 7049.</Description>
<Summary>A C# implementation of Concise Binary Object Representation (CBOR), a general-purpose binary data format defined in RFC 7049. </Summary>
Expand All @@ -13,10 +13,9 @@
<PackageLicenseExpression>CC0-1.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/peteroupc/CBOR</PackageProjectUrl>
<PackageReleaseNotes>
Version 4.0.0:
Version 4.0.1:

- Fix issues with CTAP2 Canonical CBOR form
- Support field serialization and deserialization in ToObject and FromObject
- Fix issue with unexpected CBORObject#ToString result for True and False.

</PackageReleaseNotes>
<PackageTags>cbor data serialization binary json</PackageTags>
Expand Down Expand Up @@ -62,7 +61,4 @@ Version 4.0.0:
<AdditionalFiles Include='stylecop.json'/>
<PackageReference Include='PeterO.Numbers' Version='1.4.3'/>
<AdditionalFiles Include='rules.ruleset'/></ItemGroup>
<ItemGroup>
<Compile Remove='PeterO\Cbor\CBORObjectMath.cs'/>
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions CBOR/PeterO/Cbor/CBORObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3463,9 +3463,9 @@ public int AsInt32Value() {
/// <code>CBORObject obj = CBORObject.FromInt64(99999);
/// if (obj.Type ==
/// CBORType.Integer &amp;&amp; obj.CanValueFitInInt64()) {
/// // Not an Int64; handle the error
/// Console.WriteLine("Not a 64-bit integer."); } else {
/// Console.WriteLine("The value is " + obj.AsInt64Value()); }</code>
/// &#x2f;&#x2a; Not an Int64; handle the error&#x2a;&#x2f;
/// Console.WriteLine("Not a 64-bit integer."); } else {
/// Console.WriteLine("The value is " + obj.AsInt64Value()); }</code>
/// .
/// </example>
public long AsInt64Value() {
Expand Down Expand Up @@ -5467,7 +5467,7 @@ public static int WriteValue(
/// CBORObject.WriteValue(stream, 4, 3);
/// &#x2f;&#x2a; item 1 */
/// CBORObject.Write("hello world", stream);
/// CBORObject.Write(25, stream); // item 2
/// CBORObject.Write(25, stream); &#x2f;&#x2a; item 2&#x2a;&#x2f;
/// CBORObject.Write(false, stream); &#x2f;&#x2a; item 3&#x2a;&#x2f;</code>
/// <para>In the following example, a map consisting of two key-value
/// pairs is written as CBOR to a data stream.</para>
Expand Down
61 changes: 40 additions & 21 deletions CBOR/docs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@
according to the FIDO Client-to-Authenticator Protocol 2
specification.</summary>
<value><c>true</c> if CBOR objects are written out using the CTAP2
canonical CBOR encoding form; otherwise, <c>false</c>. The default is <c>false</c>.</value>
canonical CBOR encoding form; otherwise, <c>false</c>. The default
is <c>false</c>.</value>

</doc>
<doc name="F:PeterO.Cbor.CBOREncodeOptions.Default">
Expand Down Expand Up @@ -876,9 +877,10 @@
<example><para>The following example code (originally written in C# for
the.NET Framework) shows a way to check whether a given CBOR object
stores a 32-bit signed integer before getting its value.</para>
<code>CBORObject obj = CBORObject.FromInt32(99999); if (obj.IsIntegral
&amp;&amp; obj.CanTruncatedIntFitInInt32()) { &#x2f;&#x2a; Not an Int32; handle&#x2a;&#x2f;
the error Console.WriteLine("Not a 32-bit integer."); } else {
<code>CBORObject obj = CBORObject.FromInt32(99999);
if (obj.IsIntegral &amp;&amp; obj.CanTruncatedIntFitInInt32()) {
&#x2f;&#x2a; Not an Int32; handle the error &#x2a;&#x2f;
Console.WriteLine("Not a 32-bit integer."); } else {
Console.WriteLine("The value is " + obj.AsInt32()); }</code> .
</example>

Expand Down Expand Up @@ -941,10 +943,12 @@
<example><para>The following example code (originally written in C# for
the.NET Framework) shows a way to check whether a given CBOR object
stores a 64-bit signed integer before getting its value.</para>
<code>CBORObject obj = CBORObject.FromInt64(99999); if (obj.Type ==
CBORType.Integer &amp;&amp; obj.CanValueFitInInt64()) { /* Not an Int64;
handle the error */ Console.WriteLine("Not a 64-bit integer."); } else {
Console.WriteLine("The value is " + obj.AsInt64Value()); }</code> .
<code>CBORObject obj = CBORObject.FromInt64(99999);
if (obj.Type ==
CBORType.Integer &amp;&amp; obj.CanValueFitInInt64()) {
&#x2f;&#x2a; Not an Int64; handle the error&#x2a;&#x2f;
Console.WriteLine("Not a 64-bit integer."); } else {
Console.WriteLine("The value is " + obj.AsInt64Value()); }</code> .
</example>

</doc>
Expand Down Expand Up @@ -3591,7 +3595,7 @@
<example><para>The following example (written in C# for the.NET version)
shows how to use the <c>LimitedMemoryStream</c> class (implemented
in <i>LimitedMemoryStream.cs</i>
in the peteroupc/CBOR open-source
in the peteroupc/CBOR open-source
repository) to limit the size of supported JSON serializations of
CBOR objects.</para>
<code>&#x2f;&#x2a; maximum supported JSON size in bytes&#x2a;&#x2f;
Expand Down Expand Up @@ -3673,7 +3677,8 @@
out certain keys of a CBOR map in a given order. In the case of
CBOR objects of type FloatingPoint, the number is written using the
shortest floating-point encoding possible; this is a change from
previous versions.</para></summary>
previous versions.</para>
</summary>
<param name='stream'>A writable data stream.</param>
<exception cref='ArgumentNullException'>The parameter <paramref name='stream'/> is null.</exception>
<exception cref='System.IO.IOException'>An I/O error
Expand Down Expand Up @@ -3726,7 +3731,7 @@
outputStream.WriteByte((byte)0xff); }</code> <para>The following example (written in C# for the.NET version)
shows how to use the <c>LimitedMemoryStream</c> class (implemented
in <i>LimitedMemoryStream.cs</i>
in the peteroupc/CBOR open-source
in the peteroupc/CBOR open-source
repository) to limit the size of supported CBOR
serializations.</para>
<code>&#x2f;&#x2a; maximum supported CBOR size in bytes&#x2a;&#x2f;
Expand Down Expand Up @@ -3862,13 +3867,17 @@
<exception cref='ArgumentNullException'>The parameter <paramref name='outputStream'/> is null.</exception>
<example><para>In the following example, an array of three objects is
written as CBOR to a data stream.</para>
<code>CBORObject.WriteValue(stream, 4, 3); &#x2f;&#x2a; array, length 3&#x2a;&#x2f;
CBORObject.Write("hello world", stream); &#x2f;&#x2a; item 1 CBORObject.Write(25,&#x2a;&#x2f;
stream); /* item 2 */ CBORObject.Write(false, stream); &#x2f;&#x2a; item 3&#x2a;&#x2f;</code> <para>In the following example, a map consisting of two key-value
<code>&#x2f;&#x2a; array, length 3&#x2a;&#x2f;
CBORObject.WriteValue(stream, 4, 3);
&#x2f;&#x2a; item 1 */
CBORObject.Write("hello world", stream);
CBORObject.Write(25, stream); &#x2f;&#x2a; item 2&#x2a;&#x2f;
CBORObject.Write(false, stream); &#x2f;&#x2a; item 3&#x2a;&#x2f;</code> <para>In the following example, a map consisting of two key-value
pairs is written as CBOR to a data stream.</para>
<code>CBORObject.WriteValue(stream, 5, 2); &#x2f;&#x2a; map, 2 pairs&#x2a;&#x2f;
CBORObject.Write("number", stream); &#x2f;&#x2a; key 1 CBORObject.Write(25,&#x2a;&#x2f;
stream); &#x2f;&#x2a; value 1 CBORObject.Write("string", stream); &#x2f;&#x2a; key 2&#x2a;&#x2f;&#x2a;&#x2f;
CBORObject.Write("number", stream); &#x2f;&#x2a; key 1 */
CBORObject.Write(25, stream); &#x2f;&#x2a; value 1 */
CBORObject.Write("string", stream); &#x2f;&#x2a; key 2&#x2a;&#x2f;
CBORObject.Write("hello", stream); &#x2f;&#x2a; value 2&#x2a;&#x2f;</code> <para>In the following example (originally written in C# for
the.NET Framework version), a text string is written as CBOR to a
data stream.</para>
Expand Down Expand Up @@ -4638,35 +4647,45 @@
</summary>
</doc>
<doc name="F:PeterO.Cbor.URIUtility.ParseMode.IRILenient">
<summary>The rules only check for the appropriate delimiters when

<summary>The rules only check for the appropriate delimiters when
splitting the path, without checking if all the characters in each
component are valid. Even with this mode, strings with unpaired
surrogate code points are considered invalid.</summary>

</doc>
<doc name="F:PeterO.Cbor.URIUtility.ParseMode.IRIStrict">
<summary>The rules follow the syntax for parsing IRIs. In

<summary>The rules follow the syntax for parsing IRIs. In
particular, many code points outside the Basic Latin range (U+0000
to U+007F) are allowed. Strings with unpaired surrogate code points
are considered invalid.</summary>

</doc>
<doc name="F:PeterO.Cbor.URIUtility.ParseMode.IRISurrogateLenient">
<summary>The rules only check for the appropriate delimiters when

<summary>The rules only check for the appropriate delimiters when
splitting the path, without checking if all the characters in each
component are valid. Unpaired surrogate code points are treated as
though they were replacement characters instead for the purposes of
these rules, so that strings with those code points are not
considered invalid strings.</summary>

</doc>
<doc name="F:PeterO.Cbor.URIUtility.ParseMode.URILenient">
<summary>The rules only check for the appropriate delimiters when

<summary>The rules only check for the appropriate delimiters when
splitting the path, without checking if all the characters in each
component are valid. Code points outside the Basic Latin range
(U+0000 to U+007F) are not allowed.</summary>

</doc>
<doc name="F:PeterO.Cbor.URIUtility.ParseMode.URIStrict">
<summary>The rules follow the syntax for parsing IRIs, except that

<summary>The rules follow the syntax for parsing IRIs, except that
code points outside the Basic Latin range (U+0000 to U+007F) are
not allowed.</summary>

</doc>
<doc name="M:PeterO.Cbor.URIUtility.PercentDecode(System.String)">
<summary>Decodes percent-encoding (of the form "%XX" where X is a hexadecimal
Expand Down
6 changes: 3 additions & 3 deletions CBOR20/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Reflection;
[assembly: System.CLSCompliant(true)]
[assembly: AssemblyInformationalVersion("4.0.0")]
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyInformationalVersion("4.0.1")]
[assembly: AssemblyVersion("4.0.1.0")]
[assembly: AssemblyFileVersion("4.0.1.0")]
[assembly: AssemblyProduct("CBOR (Concise Binary Object Representati" +
"on)")]
[assembly: AssemblyTitle("CBOR (Concise Binary Object Representati" +
Expand Down
6 changes: 3 additions & 3 deletions CBOR40/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Reflection;
[assembly: System.CLSCompliant(true)]
[assembly: AssemblyInformationalVersion("4.0.0")]
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyInformationalVersion("4.0.1")]
[assembly: AssemblyVersion("4.0.1.0")]
[assembly: AssemblyFileVersion("4.0.1.0")]
[assembly: AssemblyProduct("CBOR (Concise Binary Object Representati" +
"on)")]
[assembly: AssemblyTitle("CBOR (Concise Binary Object Representati" +
Expand Down
2 changes: 1 addition & 1 deletion CBORDocs/DocVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ public void VisitNode(INode node) {
var t = node.GetContent();
// Collapse multiple spaces into a single space
t = Regex.Replace(t, @"\s+", " ");
if (t.Length!=1 || t[0]!=' ') {
if (t.Length != 1 || t[0] != ' ') {
// Don't write if result is a single space
this.Write(t);
}
Expand Down
7 changes: 3 additions & 4 deletions CBORTest/CBORExtraTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,13 @@ from i in RangeExclusive(0, 10)
CBORTestCommon.AssertRoundTrip(obj);
// Select all even numbers
var query2 =
from i in RangeExclusive(0, 10)
where i % 2 == 0
select new { A = i, B = i + 1 };
from i in RangeExclusive(0, 10)
where i % 2 == 0 select new { A = i, B = i + 1 };
obj = CBORObject.FromObject(query2);
Assert.AreEqual(5, obj.Count);
Assert.AreEqual(0, obj[0]["a"].AsInt32());
Assert.AreEqual(3, obj[1]["b"].AsInt32());
CBORTestCommon.AssertRoundTrip(obj);
CBORTestCommon.AssertRoundTrip(obj);
#endif
}

Expand Down
24 changes: 12 additions & 12 deletions CBORTest/CBORObjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5703,17 +5703,17 @@ public void TestToString() {
stringTemp);
}
CBORObject cbor = CBORObject.True;
Assert.AreNotEqual("21", cbor.ToString());
Assert.AreNotEqual("simple(21)", cbor.ToString());
TestCommon.AssertNotEqual("21", cbor.ToString());
TestCommon.AssertNotEqual("simple(21)", cbor.ToString());
cbor = CBORObject.False;
Assert.AreNotEqual("20", cbor.ToString());
Assert.AreNotEqual("simple(20)", cbor.ToString());
TestCommon.AssertNotEqual("20", cbor.ToString());
TestCommon.AssertNotEqual("simple(20)", cbor.ToString());
cbor = CBORObject.Null;
Assert.AreNotEqual("22", cbor.ToString());
Assert.AreNotEqual("simple(22)", cbor.ToString());
TestCommon.AssertNotEqual("22", cbor.ToString());
TestCommon.AssertNotEqual("simple(22)", cbor.ToString());
cbor = CBORObject.Undefined;
Assert.AreNotEqual("23", cbor.ToString());
Assert.AreNotEqual("simple(23)", cbor.ToString());
TestCommon.AssertNotEqual("23", cbor.ToString());
TestCommon.AssertNotEqual("simple(23)", cbor.ToString());
{
string stringTemp = CBORObject.FromSimpleValue(50).ToString();
Assert.AreEqual(
Expand All @@ -5725,13 +5725,13 @@ public void TestToString() {
[Test]
public void TestSimpleValuesNotIntegers() {
CBORObject cbor = CBORObject.True;
Assert.AreNotEqual(CBORObject.FromObject(21), cbor);
TestCommon.AssertNotEqual(CBORObject.FromObject(21), cbor);
cbor = CBORObject.False;
Assert.AreNotEqual(CBORObject.FromObject(20), cbor);
TestCommon.AssertNotEqual(CBORObject.FromObject(20), cbor);
cbor = CBORObject.Null;
Assert.AreNotEqual(CBORObject.FromObject(22), cbor);
TestCommon.AssertNotEqual(CBORObject.FromObject(22), cbor);
cbor = CBORObject.Undefined;
Assert.AreNotEqual(CBORObject.FromObject(23), cbor);
TestCommon.AssertNotEqual(CBORObject.FromObject(23), cbor);
}

[Test]
Expand Down
Loading

0 comments on commit 06f4f1a

Please sign in to comment.