diff --git a/CBOR.nuspec b/CBOR.nuspec
index e270d554..871ec4f2 100644
--- a/CBOR.nuspec
+++ b/CBOR.nuspec
@@ -1,51 +1,5 @@
CBORObject obj = CBORObject.FromInt64(99999);
/// if (obj.Type ==
/// CBORType.Integer && obj.CanValueFitInInt64()) {
- /// // Not an Int64; handle the error
- /// Console.WriteLine("Not a 64-bit integer."); } else {
- /// Console.WriteLine("The value is " + obj.AsInt64Value()); }
+ /// /* Not an Int64; handle the error*/
+ /// Console.WriteLine("Not a 64-bit integer."); } else {
+ /// Console.WriteLine("The value is " + obj.AsInt64Value()); }
/// .
///
public long AsInt64Value() {
@@ -5467,7 +5467,7 @@ public static int WriteValue(
/// CBORObject.WriteValue(stream, 4, 3);
/// /* item 1 */
/// CBORObject.Write("hello world", stream);
- /// CBORObject.Write(25, stream); // item 2
+ /// CBORObject.Write(25, stream); /* item 2*/
/// CBORObject.Write(false, stream); /* item 3*/
/// CBORObject obj = CBORObject.FromInt32(99999); if (obj.IsIntegral
- && obj.CanTruncatedIntFitInInt32()) { /* Not an Int32; handle*/
- the error Console.WriteLine("Not a 32-bit integer."); } else {
+ CBORObject obj = CBORObject.FromInt32(99999);
+ if (obj.IsIntegral && obj.CanTruncatedIntFitInInt32()) {
+ /* Not an Int32; handle the error */
+ Console.WriteLine("Not a 32-bit integer."); } else {
Console.WriteLine("The value is " + obj.AsInt32()); }
.
CBORObject obj = CBORObject.FromInt64(99999); if (obj.Type ==
- CBORType.Integer && obj.CanValueFitInInt64()) { /* Not an Int64;
- handle the error */ Console.WriteLine("Not a 64-bit integer."); } else {
- Console.WriteLine("The value is " + obj.AsInt64Value()); }
.
+ CBORObject obj = CBORObject.FromInt64(99999);
+ if (obj.Type ==
+ CBORType.Integer && obj.CanValueFitInInt64()) {
+ /* Not an Int64; handle the error*/
+ Console.WriteLine("Not a 64-bit integer."); } else {
+ Console.WriteLine("The value is " + obj.AsInt64Value()); }
.
/* maximum supported JSON size in bytes*/
@@ -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.
+ previous versions.
+
A writable data stream.
The parameter is null.
An I/O error
@@ -3726,7 +3731,7 @@
outputStream.WriteByte((byte)0xff); }
/* maximum supported CBOR size in bytes*/
@@ -3862,13 +3867,17 @@
The parameter is null.
In the following example, an array of three objects is
written as CBOR to a data stream.
- CBORObject.WriteValue(stream, 4, 3); /* array, length 3*/
- CBORObject.Write("hello world", stream); /* item 1 CBORObject.Write(25,*/
- stream); /* item 2 */ CBORObject.Write(false, stream); /* item 3*/
In the following example, a map consisting of two key-value
+ /* array, length 3*/
+ CBORObject.WriteValue(stream, 4, 3);
+ /* item 1 */
+ CBORObject.Write("hello world", stream);
+ CBORObject.Write(25, stream); /* item 2*/
+ CBORObject.Write(false, stream); /* item 3*/
In the following example, a map consisting of two key-value
pairs is written as CBOR to a data stream.
CBORObject.WriteValue(stream, 5, 2); /* map, 2 pairs*/
- CBORObject.Write("number", stream); /* key 1 CBORObject.Write(25,*/
- stream); /* value 1 CBORObject.Write("string", stream); /* key 2*/*/
+ CBORObject.Write("number", stream); /* key 1 */
+ CBORObject.Write(25, stream); /* value 1 */
+ CBORObject.Write("string", stream); /* key 2*/
CBORObject.Write("hello", stream); /* value 2*/
In the following example (originally written in C# for
the.NET Framework version), a text string is written as CBOR to a
data stream.
@@ -4638,35 +4647,45 @@
-The rules only check for the appropriate delimiters when
+
+ 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.
+
-The rules follow the syntax for parsing IRIs. In
+
+ 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.
+
-The rules only check for the appropriate delimiters when
+
+ 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.
+
-The rules only check for the appropriate delimiters when
+
+ 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.
+
-The rules follow the syntax for parsing IRIs, except that
+
+ 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.
+
Decodes percent-encoding (of the form "%XX" where X is a hexadecimal
diff --git a/CBOR20/Properties/AssemblyInfo.cs b/CBOR20/Properties/AssemblyInfo.cs
index 63576512..f38c6d1a 100644
--- a/CBOR20/Properties/AssemblyInfo.cs
+++ b/CBOR20/Properties/AssemblyInfo.cs
@@ -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" +
diff --git a/CBOR40/Properties/AssemblyInfo.cs b/CBOR40/Properties/AssemblyInfo.cs
index 63576512..f38c6d1a 100644
--- a/CBOR40/Properties/AssemblyInfo.cs
+++ b/CBOR40/Properties/AssemblyInfo.cs
@@ -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" +
diff --git a/CBORDocs/DocVisitor.cs b/CBORDocs/DocVisitor.cs
index 164c3ac1..f4aaf1b2 100644
--- a/CBORDocs/DocVisitor.cs
+++ b/CBORDocs/DocVisitor.cs
@@ -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);
}
diff --git a/CBORTest/CBORExtraTest.cs b/CBORTest/CBORExtraTest.cs
index 69998c73..5be705a1 100644
--- a/CBORTest/CBORExtraTest.cs
+++ b/CBORTest/CBORExtraTest.cs
@@ -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
}
diff --git a/CBORTest/CBORObjectTest.cs b/CBORTest/CBORObjectTest.cs
index dc41ffdc..ebbf507a 100644
--- a/CBORTest/CBORObjectTest.cs
+++ b/CBORTest/CBORObjectTest.cs
@@ -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(
@@ -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]
diff --git a/CBORTest/CBORTest.cs b/CBORTest/CBORTest.cs
index fbbf33a4..e58e4e29 100644
--- a/CBORTest/CBORTest.cs
+++ b/CBORTest/CBORTest.cs
@@ -1451,7 +1451,7 @@ public static CBORObject ReferenceTestObject() {
}
[Test]
- [Timeout(2000)]
+ [Timeout(5000)]
public void TestNoRecursiveExpansion() {
CBORObject root = ReferenceTestObject();
byte[] bytes = root.EncodeToBytes();
diff --git a/CBORTest/TestCommon.cs b/CBORTest/TestCommon.cs
index 66d05033..83f81cd3 100644
--- a/CBORTest/TestCommon.cs
+++ b/CBORTest/TestCommon.cs
@@ -104,6 +104,41 @@ public static void AssertByteArraysEqual(byte[] arr1, byte[] arr2) {
}
}
+ public static void AssertNotEqual(object o, object o2, string msg) {
+ if (o == null) {
+ throw new ArgumentNullException(nameof(o));
+ }
+ if (o.Equals(o2)) {
+ string str = msg + "\r\n" + ObjectMessages(
+ o,
+ o2,
+ "Unexpectedly equal");
+ Assert.Fail(str);
+ }
+ }
+
+ public static void AssertEquals(object o, object o2, string msg) {
+ if (o == null) {
+ throw new ArgumentNullException(nameof(o));
+ }
+ if (!o.Equals(o2)) {
+ Assert.AreEqual(o, o2, msg);
+ }
+ }
+
+ public static void AssertNotEqual(Object o, Object o2) {
+ if (o == null) {
+ throw new ArgumentNullException(nameof(o));
+ }
+ if (o.Equals(o2)) {
+ string str = ObjectMessages(
+ o,
+ o2,
+ "Unexpectedly equal");
+ Assert.Fail(str);
+ }
+ }
+
public static void AssertEquals(Object o, Object o2) {
if (o == null) {
throw new ArgumentNullException(nameof(o));
@@ -179,6 +214,27 @@ public static void CompareTestConsistency(T o1, T o2, T o3) where T :
Assert.AreEqual(cmp3 == 0, o3.Equals(o1));
}
+ public static void CompareTestNotEqual(T o1, T o2) where T :
+ IComparable {
+ if (CompareTestReciprocal(o1, o2) == 0) {
+ Assert.Fail(ObjectMessages(
+ o1,
+ o2,
+ "Unexpectedly equal: " + CompareTestReciprocal(o1, o2)));
+ }
+ }
+
+ public static void CompareTestNotEqual(T o1, T o2, string msg) where T :
+ IComparable {
+ if (CompareTestReciprocal(o1, o2) == 0) {
+ string str = msg + "\r\n" + ObjectMessages(
+ o1,
+ o2,
+ "Unexpectedly equal: " + CompareTestReciprocal(o1, o2));
+ Assert.Fail(str);
+ }
+ }
+
public static void CompareTestEqual(T o1, T o2) where T :
IComparable {
if (CompareTestReciprocal(o1, o2) != 0) {
diff --git a/History.md b/History.md
index 9ea6e458..a86037fb 100644
--- a/History.md
+++ b/History.md
@@ -1,6 +1,10 @@
Release notes
---------------------
+### Version 4.0.1:
+
+- Fix issue with unexpected CBORObject#ToString result for True and False.
+
### Version 4.0.0:
- Fix issues with CTAP2 Canonical CBOR form
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index 63576512..f38c6d1a 100644
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -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" +
diff --git a/docs/PeterO.Cbor.CBORObject.md b/docs/PeterO.Cbor.CBORObject.md
index 497adc70..b21e390d 100644
--- a/docs/PeterO.Cbor.CBORObject.md
+++ b/docs/PeterO.Cbor.CBORObject.md
@@ -902,9 +902,10 @@ Converts this object to a 32-bit signed integer. Non-integer number values are t
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.
- CBORObject obj = CBORObject.FromInt32(99999); if (obj.IsIntegral
- && obj.CanTruncatedIntFitInInt32()) { /* Not an Int32; handle*/
- the error Console.WriteLine("Not a 32-bit integer."); } else {
+ CBORObject obj = CBORObject.FromInt32(99999);
+ if (obj.IsIntegral && obj.CanTruncatedIntFitInInt32()) {
+ /* Not an Int32; handle the error */
+ Console.WriteLine("Not a 32-bit integer."); } else {
Console.WriteLine("The value is " + obj.AsInt32()); }
.
@@ -986,9 +987,11 @@ Converts this object to a 64-bit signed integer if this CBOR object's type is In
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.
- CBORObject obj = CBORObject.FromInt64(99999); if (obj.Type ==
- CBORType.Integer && obj.CanValueFitInInt64()) { /* Not an Int64;
- handle the error */ Console.WriteLine("Not a 64-bit integer."); } else {
+ CBORObject obj = CBORObject.FromInt64(99999);
+ if (obj.Type ==
+ CBORType.Integer && obj.CanValueFitInInt64()) {
+ /* Not an Int64; handle the error*/
+ Console.WriteLine("Not a 64-bit integer."); } else {
Console.WriteLine("The value is " + obj.AsInt64Value()); }
.
@@ -4449,15 +4452,19 @@ Writes a CBOR major type number and an integer 0 or greater associated with it t
In the following example, an array of three objects is written as CBOR to a data stream.
- CBORObject.WriteValue(stream, 4, 3); /* array, length 3*/
- CBORObject.Write("hello world", stream); /* item 1 CBORObject.Write(25,*/
- stream); /* item 2 */ CBORObject.Write(false, stream); /* item 3*/
+ /* array, length 3*/
+ CBORObject.WriteValue(stream, 4, 3);
+ /* item 1 */
+ CBORObject.Write("hello world", stream);
+ CBORObject.Write(25, stream); /* item 2*/
+ CBORObject.Write(false, stream); /* item 3*/
In the following example, a map consisting of two key-value pairs is written as CBOR to a data stream.
CBORObject.WriteValue(stream, 5, 2); /* map, 2 pairs*/
- CBORObject.Write("number", stream); /* key 1 CBORObject.Write(25,*/
- stream); /* value 1 CBORObject.Write("string", stream); // key 2*/
+ CBORObject.Write("number", stream); /* key 1 */
+ CBORObject.Write(25, stream); /* value 1 */
+ CBORObject.Write("string", stream); /* key 2*/
CBORObject.Write("hello", stream); /* value 2*/
In the following example (originally written in C# for the.NET Framework version), a text string is written as CBOR to a data stream.