diff --git a/CBOR/CBOR.csproj b/CBOR/CBOR.csproj
index 0d3f9bea..f8e8feb6 100644
--- a/CBOR/CBOR.csproj
+++ b/CBOR/CBOR.csproj
@@ -63,4 +63,6 @@ Note that after version 4.5x, the CBOR library's repository will stop including
+
+
diff --git a/CBOR/PeterO/Cbor/CBORDataUtilitiesTextString.cs b/CBOR/PeterO/Cbor/CBORDataUtilitiesTextString.cs
index 9ace61bb..e389bb96 100644
--- a/CBOR/PeterO/Cbor/CBORDataUtilitiesTextString.cs
+++ b/CBOR/PeterO/Cbor/CBORDataUtilitiesTextString.cs
@@ -30,7 +30,7 @@ internal static CBORObject ParseJSONNumber(
return null;
}
- _ = options ?? CBORDataUtilities.DefaultOptions;
+ options = options ?? CBORDataUtilities.DefaultOptions;
bool preserveNegativeZero = options.PreserveNegativeZero;
JSONOptions.ConversionMode kind = options.NumberConversion;
int endPos = offset + count;
diff --git a/CBOR/PeterO/Cbor/CBORDateConverter.cs b/CBOR/PeterO/Cbor/CBORDateConverter.cs
index d552f2a7..a5d3ddba 100644
--- a/CBOR/PeterO/Cbor/CBORDateConverter.cs
+++ b/CBOR/PeterO/Cbor/CBORDateConverter.cs
@@ -168,9 +168,7 @@ public DateTime FromCBORObject(CBORObject obj) {
/// cannot be less than -1439 or greater than 1439. For tags 0 and 1,
/// this value is always 0..
/// Either true if the method is successful, or
- /// false otherwise. Returns false if the parameter
- /// or is null,
- /// or contains fewer elements than required.
+ /// false otherwise.
public bool TryGetDateTimeFields(CBORObject obj, EInteger[] year, int[]
lesserFields) {
if (year == null) {
@@ -225,7 +223,8 @@ private string TryGetDateTimeFieldsInternal(
return "\"lesserFields\" + \"'s length\" (" +
lesserFields.Length + ") is not greater or equal to 7";
}
- if (this.Type == ConversionType.UntaggedNumber) {
+ ConversionType thisType = this.Type;
+ if (thisType == ConversionType.UntaggedNumber) {
if (obj.IsTagged) {
return "May not be tagged";
}
@@ -237,8 +236,8 @@ private string TryGetDateTimeFieldsInternal(
if (!num.IsFinite()) {
return "Not a finite number";
}
- if (num.CompareTo(long.MinValue) < 0 ||
- num.CompareTo(long.MaxValue) > 0) {
+ if (num.CompareTo(Int64.MinValue) < 0 ||
+ num.CompareTo(Int64.MaxValue) > 0) {
return "Too big or small to fit a DateTime";
}
if (num.CanFitInInt64()) {
@@ -389,7 +388,8 @@ public CBORObject DateTimeFieldsToCBORObject(EInteger bigYear, int[]
}
try {
CBORUtilities.CheckYearAndLesserFields(bigYear, lesserFields);
- switch (this.Type) {
+ ConversionType thisType = this.Type;
+ switch (thisType) {
case ConversionType.TaggedString:
{
string str = CBORUtilities.ToAtomDateTimeString(bigYear,
@@ -404,21 +404,23 @@ public CBORObject DateTimeFieldsToCBORObject(EInteger bigYear, int[]
bigYear,
lesserFields,
status);
- return status[0] == 0 ?
- this.Type == ConversionType.TaggedNumber ?
- CBORObject.FromEInteger(ef.ToEInteger()).WithTag(1) :
- CBORObject.FromEInteger(ef.ToEInteger()) : status[0] == 1 ?
- this.Type == ConversionType.TaggedNumber ?
- CBORObject.FromFloatingPointBits(ef.ToDoubleBits(), 8)
- .WithTag(1) :
- CBORObject.FromFloatingPointBits(ef.ToDoubleBits(), 8) :
- throw new CBORException("Too big or small to fit an" +
- "\u0020integer" + "\u0020or floating-point number");
+ switch (status[0]) {
+ case 0:
+ return thisType == ConversionType.TaggedNumber ?
+ CBORObject.FromObjectAndTag(ef.ToEInteger(), 1) :
+ CBORObject.FromObject(ef.ToEInteger());
+ case 1:
+ return thisType == ConversionType.TaggedNumber ?
+ CBORObject.FromFloatingPointBits(ef.ToDoubleBits(), 8)
+ .WithTag(1) :
+ CBORObject.FromFloatingPointBits(ef.ToDoubleBits(), 8);
+ default: throw new CBORException("Too big or small to fit an" +
+ "\u0020integer" + "\u0020or floating-point number");
+ }
} catch (ArgumentException ex) {
throw new CBORException(ex.Message, ex);
}
- default:
- throw new CBORException("Internal error");
+ default: throw new CBORException("Internal error");
}
} catch (ArgumentException ex) {
throw new CBORException(ex.Message, ex);
diff --git a/CBOR/PeterO/Cbor/CBORJson.cs b/CBOR/PeterO/Cbor/CBORJson.cs
index 2f72b233..328f648c 100644
--- a/CBOR/PeterO/Cbor/CBORJson.cs
+++ b/CBOR/PeterO/Cbor/CBORJson.cs
@@ -192,7 +192,6 @@ private CBORObject NextJSONNegativeNumber(
this.RaiseError("JSON number can't be parsed.");
}
- _ = -(c - '0');
int cstart = c;
c = this.ReadChar();
this.sb = this.sb ?? new StringBuilder();
@@ -279,8 +278,8 @@ private CBORObject NextJSONValue(
case 't':
{
// Parse true
- if ((_ = this.ReadChar()) != 'r' || (_ = this.ReadChar()) != 'u' ||
- (_ = this.ReadChar()) != 'e') {
+ if (this.ReadChar() != 'r' || this.ReadChar() != 'u' ||
+this.ReadChar() != 'e') {
this.RaiseError("Value can't be parsed.");
}
c = this.ReadChar();
@@ -298,8 +297,8 @@ private CBORObject NextJSONValue(
case 'f':
{
// Parse false
- if ((_ = this.ReadChar()) != 'a' || (_ = this.ReadChar()) != 'l' ||
- (_ = this.ReadChar()) != 's' || (_ = this.ReadChar()) != 'e') {
+ if (this.ReadChar() != 'a' || this.ReadChar() != 'l' ||
+this.ReadChar() != 's' || this.ReadChar() != 'e') {
this.RaiseError("Value can't be parsed.");
}
c = this.ReadChar();
@@ -317,8 +316,8 @@ private CBORObject NextJSONValue(
case 'n':
{
// Parse null
- if ((_ = this.ReadChar()) != 'u' || (_ = this.ReadChar()) != 'l' ||
- (_ = this.ReadChar()) != 'l') {
+ if (this.ReadChar() != 'u' || this.ReadChar() != 'l' ||
+this.ReadChar() != 'l') {
this.RaiseError("Value can't be parsed.");
}
c = this.ReadChar();
@@ -540,7 +539,7 @@ internal static CBORObject[] ParseJSONSequence(
// a truncated JSON text
return new CBORObject[] { null };
}
- var list = new List();
+ var cborList = new List();
while (true) {
CBORObject co;
try {
@@ -554,7 +553,7 @@ internal static CBORObject[] ParseJSONSequence(
cj.SkipToEnd();
co = null;
}
- list.Add(co);
+ cborList.Add(co);
if (!cj.recordSeparatorSeen) {
// End of the stream was reached
nextChar[0] = -1;
@@ -567,12 +566,12 @@ internal static CBORObject[] ParseJSONSequence(
if (nextChar[0] < 0) {
// Rest of stream had only record separators, so we found
// a truncated JSON text
- list.Add(null);
+ cborList.Add(null);
break;
}
}
}
- return list.ToArray();
+ return cborList.ToArray();
}
private CBORObject ParseJSONObject(int depth) {
diff --git a/CBOR/PeterO/Cbor/CBORJson3.cs b/CBOR/PeterO/Cbor/CBORJson3.cs
index cb76df43..82fd5837 100644
--- a/CBOR/PeterO/Cbor/CBORJson3.cs
+++ b/CBOR/PeterO/Cbor/CBORJson3.cs
@@ -61,8 +61,8 @@ private string NextJSONString() {
}
}
this.sb = this.sb ?? new StringBuilder();
- _ = this.sb.Remove(0, this.sb.Length);
- _ = this.sb.Append(js, startIndex, endIndex - startIndex);
+ this.sb.Remove(0, this.sb.Length);
+ this.sb.Append(js, startIndex, endIndex - startIndex);
while (true) {
c = this.index < ep ? js[this.index++] & 0xffff : -1;
if (c == -1 || c < 0x20) {
@@ -70,7 +70,6 @@ private string NextJSONString() {
}
switch (c) {
case '\\':
- _ = this.index - 1;
c = this.index < ep ? js[this.index++] & 0xffff : -1;
switch (c) {
case '\\':
diff --git a/CBOR/PeterO/Cbor/CBORNumber.cs b/CBOR/PeterO/Cbor/CBORNumber.cs
index 6ce161e2..3a1ff9a1 100644
--- a/CBOR/PeterO/Cbor/CBORNumber.cs
+++ b/CBOR/PeterO/Cbor/CBORNumber.cs
@@ -204,7 +204,6 @@ private static CBORNumber RationalToNumber(
if (denominator.Sign <= 0) {
return null; // "Denominator may not be negative or zero");
}
- var erat = ERational.Create(numerator, denominator);
if (tagName == 270) {
if (numerator.Sign < 0) {
return null; // "Numerator may not be negative");
@@ -213,11 +212,13 @@ private static CBORNumber RationalToNumber(
return null; // "Invalid options";
}
int options = o[2].AsInt32Value();
+ ERational erat = null;
switch (options) {
case 0:
+ erat = ERational.Create(numerator, denominator);
break;
case 1:
- erat = erat.Negate();
+ erat = ERational.Create(numerator, denominator).Negate();
break;
case 2:
if (!numerator.IsZero || denominator.CompareTo(1) != 0) {
@@ -245,8 +246,10 @@ private static CBORNumber RationalToNumber(
break;
default: return null; // "Invalid options");
}
+ return CBORNumber.FromObject(erat);
+ } else {
+ return CBORNumber.FromObject(ERational.Create(numerator, denominator));
}
- return CBORNumber.FromERational(erat);
}
private static bool CheckRationalToNumber(
@@ -632,11 +635,15 @@ public byte ToByteUnchecked() {
/// not-a-number, is not an exact integer, or is less than 0 or greater
/// than 255.
public byte ToByteIfExact() {
- return !this.IsFinite() ?
- throw new OverflowException("Value is infinity or NaN") :
- this.IsZero() ? (byte)0 : this.IsNegative() ? throw new
-OverflowException("Value out of range") :
-this.ToEIntegerIfExact().ToByteChecked();
+ if (!this.IsFinite()) {
+ throw new OverflowException("Value is infinity or NaN");
+ }
+ if (this.IsZero()) {
+ return (byte)0;
+ }
+ return this.IsNegative() ? throw new
+ OverflowException("Value out of range") :
+ this.ToEIntegerIfExact().ToByteChecked();
}
/// Converts a byte (from 0 to 255) to an arbitrary-precision
@@ -935,7 +942,7 @@ public bool CanFitInInt32() {
return false;
}
long v = icn.AsInt64(gv);
- return v >= int.MinValue && v <= int.MaxValue;
+ return v >= Int32.MinValue && v <= Int32.MaxValue;
}
/// Returns whether this object's numerical value is an
@@ -1046,14 +1053,15 @@ public CBORNumber Negate() {
var longValue = (long)this.value;
return longValue == 0 ? FromEDecimal(EDecimal.NegativeZero) :
longValue == long.MinValue ?
-FromEInteger(EInteger.FromInt64(longValue).Negate()) : new
-CBORNumber(this.Kind, -longValue);
+ FromEInteger(EInteger.FromInt64(longValue).Negate()) : new
+ CBORNumber(this.Kind, -longValue);
}
case NumberKind.EInteger:
{
var eiValue = (EInteger)this.value;
- return eiValue.IsZero ? FromEDecimal(EDecimal.NegativeZero) :
-FromEInteger(eiValue.Negate());
+ return eiValue.IsZero ?
+ FromEDecimal(EDecimal.NegativeZero) :
+ FromEInteger(eiValue.Negate());
}
default:
return new CBORNumber(this.Kind,
@@ -1129,8 +1137,8 @@ public CBORNumber Add(CBORNumber b) {
if (typeA == NumberKind.Integer && typeB == NumberKind.Integer) {
var valueA = (long)objA;
var valueB = (long)objB;
- if ((valueA < 0 && valueB < long.MinValue - valueA) ||
- (valueA > 0 && valueB > long.MaxValue - valueA)) {
+ if ((valueA < 0 && valueB < Int64.MinValue - valueA) ||
+ (valueA > 0 && valueB > Int64.MaxValue - valueA)) {
// would overflow, convert to EInteger
return CBORNumber.FromEInteger(
EInteger.FromInt64(valueA).Add(EInteger.FromInt64(valueB)));
@@ -1203,8 +1211,8 @@ public CBORNumber Subtract(CBORNumber b) {
if (typeA == NumberKind.Integer && typeB == NumberKind.Integer) {
var valueA = (long)objA;
var valueB = (long)objB;
- if ((valueB < 0 && long.MaxValue + valueB < valueA) ||
- (valueB > 0 && long.MinValue + valueB > valueA)) {
+ if ((valueB < 0 && Int64.MaxValue + valueB < valueA) ||
+ (valueB > 0 && Int64.MinValue + valueB > valueA)) {
// would overflow, convert to EInteger
return CBORNumber.FromEInteger(
EInteger.FromInt64(valueA).Subtract(EInteger.FromInt64(
@@ -1242,9 +1250,9 @@ public CBORNumber Subtract(CBORNumber b) {
} else {
// DebugUtility.Log("type=" + typeA + "/" + typeB + " finite=" +
// (// this.IsFinite()) + "/" + (b.IsFinite()));
- EInteger b1 = GetNumberInterface(typeA).AsEInteger(objA);
- EInteger b2 = GetNumberInterface(typeB).AsEInteger(objB);
- return new CBORNumber(NumberKind.EInteger, b1 - b2);
+ EInteger b1 = GetNumberInterface(typeA).AsEInteger(objA)
+ .Subtract(GetNumberInterface(typeB).AsEInteger(objB));
+ return new CBORNumber(NumberKind.EInteger, b1);
}
}
@@ -1274,11 +1282,11 @@ public CBORNumber Multiply(CBORNumber b) {
bool apos = valueA > 0L;
bool bpos = valueB > 0L;
if (
- (apos && ((!bpos && (long.MinValue / valueA) > valueB) ||
- (bpos && valueA > (long.MaxValue / valueB)))) ||
+ (apos && ((!bpos && (Int64.MinValue / valueA) > valueB) ||
+ (bpos && valueA > (Int64.MaxValue / valueB)))) ||
(!apos && ((!bpos && valueA != 0L &&
- (long.MaxValue / valueA) > valueB) ||
- (bpos && valueA < (long.MinValue / valueB))))) {
+ (Int64.MaxValue / valueA) > valueB) ||
+ (bpos && valueA < (Int64.MinValue / valueB))))) {
// would overflow, convert to EInteger
var bvalueA = (EInteger)valueA;
var bvalueB = (EInteger)valueB;
@@ -1342,7 +1350,7 @@ public CBORNumber Divide(CBORNumber b) {
FromEDecimal(EDecimal.PositiveInfinity));
}
- if (valueA == long.MinValue && valueB == -1) {
+ if (valueA == Int64.MinValue && valueB == -1) {
return new CBORNumber(NumberKind.Integer, valueA).Negate();
}
long quo = valueA / valueB;
diff --git a/CBOR/PeterO/Cbor/CBORObject.cs b/CBOR/PeterO/Cbor/CBORObject.cs
index bac2e294..21e1b3df 100644
--- a/CBOR/PeterO/Cbor/CBORObject.cs
+++ b/CBOR/PeterO/Cbor/CBORObject.cs
@@ -11,6 +11,7 @@ licensed under Creative Commons Zero (CC0):
using System.IO;
using System.Text;
using System.Diagnostics.CodeAnalysis;
+using PeterO;
using PeterO.Numbers;
// TODO: Add ReadObject that combines Read and ToObject; similarly
@@ -537,11 +538,14 @@ public CBORObject this[int index]
set {
if (this.Type == CBORType.Array) {
+ if (value == null) {
+ throw new ArgumentNullException(nameof(value));
+ }
IList list = this.AsList();
if (index < 0 || index >= list.Count) {
throw new ArgumentOutOfRangeException(nameof(index));
}
- list[index] = value ?? throw new ArgumentNullException(nameof(value));
+ list[index] = value;
} else if (this.Type == CBORType.Map) {
IDictionary map = this.AsMap();
var key = CBORObject.FromInt(index);
@@ -2494,7 +2498,7 @@ public static CBORObject FromObject(int[] array) {
return CBORObject.Null;
}
IList list = new List(array.Length ==
- int.MaxValue ? array.Length : (array.Length + 1));
+ Int32.MaxValue ? array.Length : (array.Length + 1));
foreach (int i in array) {
list.Add(FromInt(i));
}
@@ -2512,7 +2516,7 @@ public static CBORObject FromObject(long[] array) {
return CBORObject.Null;
}
IList list = new List(array.Length ==
- int.MaxValue ? array.Length : (array.Length + 1));
+ Int32.MaxValue ? array.Length : (array.Length + 1));
foreach (long i in array) {
list.Add(FromInt64(i));
}
@@ -2655,18 +2659,18 @@ public static CBORObject FromObject(
/// string. To create a CBOR byte string object from String
/// ,
/// see the example given in .
- /// - In
- /// the.NET version, a nullable is converted to CBORObject.Null
- /// if the nullable's value is null
- /// , or converted according to
- /// the nullable's underlying type, if that type is supported by this
- /// method.
- /// - In the Java version, a number of type
- /// BigInteger
+ /// cref='PeterO.Cbor.CBORObject.FromObject(System.Byte[])'/>.
+ /// - In the.NET version, a nullable is converted to
+ /// CBORObject.Null
+ /// if the nullable's value is null
+ /// , or
+ /// converted according to the nullable's underlying type, if that type
+ /// is supported by this method.
+ /// - In the Java version, a
+ /// number of type BigInteger
/// or BigDecimal
- /// is converted to the
- /// corresponding CBOR number.
+ /// is converted
+ /// to the corresponding CBOR number.
/// - A number of type
/// EDecimal
/// , EFloat
@@ -3005,7 +3009,7 @@ public CBORObject WithTag(EInteger bigintTag) {
} else {
if (bigintTag.CompareTo(UInt64MaxValue) > 0) {
throw new ArgumentException(
- "tag more than 18446744073709551615 (" + bigintTag + ")");
+ "tag more than 18446744073709551615");
}
var tagLow = 0;
var tagHigh = 0;
@@ -3059,8 +3063,8 @@ public static CBORObject FromCBORObjectAndTag(
throw new ArgumentException("tagEInt's sign(" + bigintTag.Sign +
") is less than 0") : bigintTag.CompareTo(UInt64MaxValue) > 0 ?
throw new ArgumentException(
- "tag more than 18446744073709551615 (" + bigintTag + ")") :
- cborObj.WithTag(bigintTag);
+ "tag more than 18446744073709551615") :
+ FromObject(valueOb).WithTag(bigintTag);
}
/// Generates a CBOR object from an arbitrary object and gives
@@ -3152,12 +3156,16 @@ public static CBORObject FromObjectAndTag(object valueObValue, int smallTag) =>
/// name='simpleValue'/> is less than 0, greater than 255, or from 24
/// through 31.
public static CBORObject FromSimpleValue(int simpleValue) {
- return simpleValue < 0 ?
+ if (simpleValue < 0) {
throw new ArgumentException("simpleValue(" + simpleValue +
- ") is less than 0") : simpleValue > 255 ?
+ ") is less than 0");
+ }
+ if (simpleValue > 255) {
throw new ArgumentException("simpleValue(" + simpleValue +
- ") is more than " + "255") : simpleValue >= 24 && simpleValue < 32 ?
- throw new ArgumentException("Simple value is from 24 to 31: " +
+ ") is more than " + "255");
+ }
+ return simpleValue >= 24 && simpleValue < 32 ?
+ throw new ArgumentException("Simple value is from 24 to 31 - " +
simpleValue) : simpleValue < 32 ?
FixedObjects[0xe0 + simpleValue] : new CBORObject(
CBORObjectTypeSimpleValue,
@@ -3644,9 +3652,6 @@ public static CBORObject FromJSONBytes(
if (jsonoptions == null) {
throw new ArgumentNullException(nameof(jsonoptions));
}
- if (bytes == null) {
- throw new ArgumentNullException(nameof(bytes));
- }
if (offset < 0) {
throw new ArgumentException("offset (" + offset + ") is not greater" +
"\u0020or equal to 0");
@@ -3898,7 +3903,7 @@ public static void Write(EInteger bigint, Stream stream) {
// If the arbitrary-precision integer is representable as a long and in
// major type 0 or 1, write that major type
// instead of as a bignum
- _ = WritePositiveInt64(datatype, bigint.ToInt64Checked(), stream);
+ WritePositiveInt64(datatype, bigint.ToInt64Checked(), stream);
} else {
// Get a byte array of the arbitrary-precision integer's value,
// since shifting and doing AND operations is
@@ -3925,7 +3930,7 @@ public static void Write(EInteger bigint, Stream stream) {
stream.WriteByte((byte)(datatype << 5));
return;
case 1:
- _ = WritePositiveInt(datatype, bytes[0] & 0xff, stream);
+ WritePositiveInt(datatype, bytes[0] & 0xff, stream);
break;
case 2:
stream.WriteByte((byte)((datatype << 5) | 25));
@@ -3964,7 +3969,7 @@ public static void Write(EInteger bigint, Stream stream) {
break;
default: stream.WriteByte((datatype == 0) ?
(byte)0xc2 : (byte)0xc3);
- _ = WritePositiveInt(2, byteCount, stream);
+ WritePositiveInt(2, byteCount, stream);
stream.Write(bytes, 0, byteCount);
break;
}
@@ -4439,7 +4444,7 @@ public int AsInt32Value() {
switch (this.ItemType) {
case CBORObjectTypeInteger: {
var longValue = (long)this.ThisItem;
- return longValue < int.MinValue || longValue > int.MaxValue ?
+ return longValue < Int32.MinValue || longValue > Int32.MaxValue ?
throw new OverflowException() : (int)longValue;
}
case CBORObjectTypeEInteger: {
@@ -4510,7 +4515,7 @@ public bool CanValueFitInInt32() {
switch (this.ItemType) {
case CBORObjectTypeInteger: {
var elong = (long)this.ThisItem;
- return elong >= int.MinValue && elong <= int.MaxValue;
+ return elong >= Int32.MinValue && elong <= Int32.MaxValue;
}
case CBORObjectTypeEInteger: {
var ei = (EInteger)this.ThisItem;
@@ -4614,7 +4619,7 @@ public CBORNumber AsNumber() {
/// .
///
public int AsInt32() {
- return this.AsInt32(int.MinValue, int.MaxValue);
+ return this.AsInt32(Int32.MinValue, Int32.MaxValue);
}
/// Converts this object to a 32-bit floating point
@@ -4778,7 +4783,7 @@ public int CompareTo(CBORObject other) {
int alen = strA.Length;
int blen = strB.Length;
cmp = (alen < blen) ? (-1) : ((alen > blen) ? 1 :
- string.CompareOrdinal(strA, strB));
+ String.CompareOrdinal(strA, strB));
break;
}
case CBORObjectTypeTextString: {
@@ -5041,22 +5046,17 @@ public byte[] EncodeToBytes(CBOREncodeOptions options) {
}
case CBORObjectTypeSimpleValue: {
if (tagged) {
- var simpleBytes = new byte[] { tagbyte, 0xf4 };
if (this.IsFalse) {
- simpleBytes[1] = 0xf4;
- return simpleBytes;
+ return new[] { (byte)tagbyte, (byte)0xf4 };
}
if (this.IsTrue) {
- simpleBytes[1] = 0xf5;
- return simpleBytes;
+ return new[] { (byte)tagbyte, (byte)0xf5 };
}
if (this.IsNull) {
- simpleBytes[1] = 0xf6;
- return simpleBytes;
+ return new[] { (byte)tagbyte, (byte)0xf6 };
}
if (this.IsUndefined) {
- simpleBytes[1] = 0xf7;
- return simpleBytes;
+ return new[] { (byte)tagbyte, (byte)0xf7 };
}
} else {
if (this.IsFalse) {
@@ -5249,9 +5249,9 @@ public bool Equals(CBORObject other) {
(byte[])this.itemValue,
otherValue.itemValue as byte[]);
case CBORObjectTypeMap: {
- var cbordict =
- otherValue.itemValue as IDictionary;
- return CBORMapEquals(this.AsMap(), cbordict);
+ return CBORMapEquals(
+ this.AsMap(),
+ otherValue.itemValue as IDictionary);
}
case CBORObjectTypeArray:
return CBORArrayEquals(
@@ -5350,15 +5350,15 @@ public EInteger[] GetAllTags() {
}
CBORObject curitem = this;
if (curitem.IsTagged) {
- var list = new List();
+ var extIntegerList = new List();
while (curitem.IsTagged) {
- list.Add(
+ extIntegerList.Add(
LowHighToEInteger(
curitem.tagLow,
curitem.tagHigh));
curitem = (CBORObject)curitem.itemValue;
}
- return list.ToArray();
+ return extIntegerList.ToArray();
}
return new[] { LowHighToEInteger(this.tagLow, this.tagHigh) };
}
@@ -6960,8 +6960,8 @@ internal static CBORObject GetFixedLengthObject(
int low = unchecked((int)(uadditional & 0xffffffffL));
int high = unchecked((int)((uadditional >> 32) & 0xffffffffL));
EInteger bigintAdditional = LowHighToEInteger(low, high);
- EInteger minusOne = -EInteger.One;
- bigintAdditional = minusOne - bigintAdditional;
+ EInteger minusOne = EInteger.FromInt32(-1);
+ bigintAdditional = minusOne.Subtract(bigintAdditional);
return FromEInteger(bigintAdditional);
}
case 7:
diff --git a/CBOR/PeterO/Cbor/CBORReader.cs b/CBOR/PeterO/Cbor/CBORReader.cs
index 843c1d70..bcdaa4a6 100644
--- a/CBOR/PeterO/Cbor/CBORReader.cs
+++ b/CBOR/PeterO/Cbor/CBORReader.cs
@@ -142,19 +142,21 @@ private CBORObject ReadInternal() {
}
private CBORObject ReadStringArrayMap(int type, long uadditional) {
- _ = this.options.Ctap2Canonical;
if (type == 2 || type == 3) { // Byte string or text string
if ((uadditional >> 31) != 0) {
throw new CBORException("Length of " +
ToUnsignedEInteger(uadditional).ToString() + " is bigger" +
"\u0020than supported");
}
- int hint = (uadditional > int.MaxValue ||
- (uadditional >> 63) != 0) ? int.MaxValue : (int)uadditional;
+ int hint = (uadditional > Int32.MaxValue ||
+ (uadditional >> 63) != 0) ? Int32.MaxValue : (int)uadditional;
byte[] data = ReadByteData(this.stream, uadditional, null);
- return type == 3 ? !CBORUtilities.CheckUtf8(data) ? throw new
-CBORException("Invalid UTF-8") : this.ObjectFromUtf8Array(data, hint) :
- this.ObjectFromByteArray(data, hint);
+ if (type == 3) {
+ return !CBORUtilities.CheckUtf8(data) ? throw new
+CBORException("Invalid UTF-8") : this.ObjectFromUtf8Array(data, hint);
+ } else {
+ return this.ObjectFromByteArray(data, hint);
+ }
}
if (type == 4) { // Array
if (this.options.Ctap2Canonical && this.depth >= 4) {
@@ -349,7 +351,7 @@ public CBORObject ReadForFirstByte(int firstbyte) {
if (expectedLength > 1) {
ReadHelper(this.stream, data, 1, expectedLength - 1);
}
- var cbor = CBORObject.GetFixedLengthObject(firstbyte, data);
+ CBORObject cbor = CBORObject.GetFixedLengthObject(firstbyte, data);
if (this.stringRefs != null && (type == 2 || type == 3)) {
this.stringRefs.AddStringIfNeeded(cbor, expectedLength - 1);
}
@@ -371,7 +373,7 @@ public CBORObject ReadForFirstByte(int firstbyte) {
break;
}
long len = ReadDataLength(this.stream, nextByte, 2);
- if ((len >> 63) != 0 || len > int.MaxValue) {
+ if ((len >> 63) != 0 || len > Int32.MaxValue) {
throw new CBORException("Length" + ToUnsignedEInteger(len) +
" is bigger than supported ");
}
@@ -380,7 +382,7 @@ public CBORObject ReadForFirstByte(int firstbyte) {
_ = ReadByteData(this.stream, len, ms);
}
}
- if (ms.Position > int.MaxValue) {
+ if (ms.Position > Int32.MaxValue) {
throw new
CBORException("Length of bytes to be streamed is bigger" +
"\u0020than supported ");
@@ -399,7 +401,7 @@ public CBORObject ReadForFirstByte(int firstbyte) {
break;
}
long len = ReadDataLength(this.stream, nextByte, 3);
- if ((len >> 63) != 0 || len > int.MaxValue) {
+ if ((len >> 63) != 0 || len > Int32.MaxValue) {
throw new CBORException("Length" + ToUnsignedEInteger(len) +
" is bigger than supported");
}
@@ -536,7 +538,7 @@ private static byte[] ReadByteData(
if (uadditional == 0) {
return EmptyByteArray;
}
- if ((uadditional >> 63) != 0 || uadditional > int.MaxValue) {
+ if ((uadditional >> 63) != 0 || uadditional > Int32.MaxValue) {
throw new CBORException("Length" + ToUnsignedEInteger(uadditional) +
" is bigger than supported ");
}
diff --git a/CBOR/PeterO/Cbor/CBORTypeMapper.cs b/CBOR/PeterO/Cbor/CBORTypeMapper.cs
index 7eb9edd5..5d805759 100644
--- a/CBOR/PeterO/Cbor/CBORTypeMapper.cs
+++ b/CBOR/PeterO/Cbor/CBORTypeMapper.cs
@@ -73,15 +73,21 @@ public CBORTypeMapper AddConverter(
internal object ConvertBackWithConverter(
CBORObject cbor,
Type type) {
- return !this.converters.TryGetValue(type, out ConverterInfo convinfo) ?
- null : convinfo == null ? null : (convinfo.FromObject == null) ? null :
+ ConverterInfo convinfo = PropertyMap.GetOrDefault(
+ this.converters,
+ type,
+ null);
+ return convinfo == null ? null : (convinfo.FromObject == null) ? null :
PropertyMap.CallFromObject(convinfo, cbor);
}
internal CBORObject ConvertWithConverter(object obj) {
object type = obj.GetType();
- return !this.converters.TryGetValue(type, out ConverterInfo convinfo) ?
- null : (convinfo == null) ? null :
+ ConverterInfo convinfo = PropertyMap.GetOrDefault(
+ this.converters,
+ type,
+ null);
+ return (convinfo == null) ? null :
PropertyMap.CallToObject(convinfo, obj);
}
diff --git a/CBOR/PeterO/Cbor/CBORUtilities.cs b/CBOR/PeterO/Cbor/CBORUtilities.cs
index e0c18a38..4c63e36a 100644
--- a/CBOR/PeterO/Cbor/CBORUtilities.cs
+++ b/CBOR/PeterO/Cbor/CBORUtilities.cs
@@ -535,13 +535,13 @@ public static string SingleToString(float sing) {
}
public static string LongToString(long longValue) {
- if (longValue == long.MinValue) {
+ if (longValue == Int64.MinValue) {
return "-9223372036854775808";
}
if (longValue == 0L) {
return "0";
}
- if (longValue == int.MinValue) {
+ if (longValue == Int32.MinValue) {
return "-2147483648";
}
bool neg = longValue < 0;
@@ -672,7 +672,7 @@ public static void GetNormalizedPartProlepticGregorian(
}
if (intDay < -101) {
// Number of days in a 400-year block
- int intCount = (intDay == int.MinValue) ? 14699 : Math.Abs(intDay)
+ int intCount = (intDay == Int32.MinValue) ? 14699 : Math.Abs(intDay)
/ 146097;
intDay = checked(intDay + (intCount * 146097));
longYear = checked(longYear - (intCount * 400));
@@ -929,7 +929,7 @@ public static void BreakDownSecondsSinceEpoch(
EDecimal edec,
EInteger[] year,
int[] lesserFields) {
- var integerPart = edec.Quantize(0, ERounding.Floor)
+ EInteger integerPart = edec.Quantize(0, ERounding.Floor)
.ToEInteger();
EDecimal fractionalPart = edec.Subtract(
EDecimal.FromEInteger(integerPart)).Abs();
@@ -1351,7 +1351,7 @@ public static string ToAtomDateTimeString(
}
public static long IntegerToDoubleBits(int i) {
- if (i == int.MinValue) {
+ if (i == Int32.MinValue) {
return unchecked((long)0xc1e0000000000000L);
}
if (i == 0) {
diff --git a/CBOR/PeterO/Cbor/JSONPointer.cs b/CBOR/PeterO/Cbor/JSONPointer.cs
index d4150488..056ae104 100644
--- a/CBOR/PeterO/Cbor/JSONPointer.cs
+++ b/CBOR/PeterO/Cbor/JSONPointer.cs
@@ -196,7 +196,7 @@ private static int ReadPositiveInteger(
--index;
break;
}
- if (lvalue > int.MaxValue) {
+ if (lvalue > Int32.MaxValue) {
return index - 1;
}
}
@@ -383,7 +383,7 @@ private static string Replace(string str, char c, string srep) {
_ = sb.Append(str.Substring(0, j));
_ = sb.Append(srep);
for (int i = j + 1; i < str.Length; ++i) {
- _ = str[i] == c ? sb.Append(srep) : sb.Append(str[i]);
+ sb = str[i] == c ? sb.Append(srep) : sb.Append(str[i]);
}
return sb.ToString();
}
diff --git a/CBOR/PeterO/Cbor/PropertyMap.cs b/CBOR/PeterO/Cbor/PropertyMap.cs
index 6ca567e3..8a3fc638 100644
--- a/CBOR/PeterO/Cbor/PropertyMap.cs
+++ b/CBOR/PeterO/Cbor/PropertyMap.cs
@@ -1304,10 +1304,10 @@ public static object TypeToObject(
}
}
- public static CBORObject GetOrDefault(IDictionary map,
- CBORObject key,
- CBORObject defaultValue) {
- return (!map.TryGetValue(key, out CBORObject ret)) ? defaultValue : ret;
+ public static TValue GetOrDefault(IDictionary map,
+ TKey key,
+ TValue defaultValue) {
+ return (!map.TryGetValue(key, out TValue ret)) ? defaultValue : ret;
}
public static CBORObject FromObjectOther(object obj) {
diff --git a/CBOR/PeterO/Cbor/StringOutput.cs b/CBOR/PeterO/Cbor/StringOutput.cs
index 4fd7c7aa..628a4817 100644
--- a/CBOR/PeterO/Cbor/StringOutput.cs
+++ b/CBOR/PeterO/Cbor/StringOutput.cs
@@ -40,13 +40,13 @@ public void WriteString(string str) {
}
}
} else {
- _ = this.builder.Append(str);
+ this.builder.Append(str);
}
}
public void WriteString(string str, int index, int length) {
if (this.outputStream == null) {
- _ = this.builder.Append(str, index, length);
+ this.builder.Append(str, index, length);
} else {
if (length == 1) {
this.WriteCodePoint(str[index]);
@@ -111,7 +111,7 @@ public void WriteCodePoint(int codePoint) {
if ((codePoint >> 7) == 0) {
// Code point is in the Basic Latin range (U+0000 to U+007F)
if (this.outputStream == null) {
- _ = this.builder.Append((char)codePoint);
+ this.builder.Append((char)codePoint);
} else {
this.outputStream.WriteByte((byte)codePoint);
}
@@ -156,13 +156,13 @@ public void WriteCodePoint(int codePoint) {
}
if (codePoint <= 0xffff) {
{
- _ = this.builder.Append((char)codePoint);
+ this.builder.Append((char)codePoint);
}
} else if (codePoint <= 0x10ffff) {
- _ = this.builder.Append((char)((((codePoint - 0x10000) >> 10) &
+ this.builder.Append((char)((((codePoint - 0x10000) >> 10) &
0x3ff) |
0xd800));
- _ = this.builder.Append((char)(((codePoint - 0x10000) & 0x3ff) |
+ this.builder.Append((char)(((codePoint - 0x10000) & 0x3ff) |
0xdc00));
}
}
diff --git a/CBOR/docs.xml b/CBOR/docs.xml
index d725435c..66812d68 100644
--- a/CBOR/docs.xml
+++ b/CBOR/docs.xml
@@ -44,14 +44,12 @@
Parses a number from a byte sequence whose format follows
the JSON specification. The method uses a JSONOptions with all
- default properties except for a PreserveNegativeZero property of
- false.
+ default properties.
A byte sequence to parse as a JSON
number.
A CBOR object that represents the parsed number. Returns
- positive zero if the number is a zero that starts with a minus sign
- (such as "-0" or "-0.0"). Returns null if the parsing fails,
- including if the byte sequence is null or empty.
+ null if the parsing fails, including if the byte sequence is null
+ or empty.
@@ -141,15 +139,11 @@
Parses a number from a sequence of char s whose
format follows the JSON specification. The method uses a
- JSONOptions with all default properties except for a
- PreserveNegativeZero property of false.
+ JSONOptions with all default properties.
A sequence of char s to parse as a JSON
number.
A CBOR object that represents the parsed number. Returns
- positive zero if the number is a zero that starts with a minus sign
- (such as "-0" or "-0.0"). Returns null if the parsing fails,
- including if the sequence of char s is null or
- empty.
+ null if the parsing fails, including if the sequence of char s is null or empty.
@@ -234,13 +228,11 @@
Parses a number whose format follows the JSON
specification. The method uses a JSONOptions with all default
- properties except for a PreserveNegativeZero property of
- false.
+ properties.
A text string to parse as a JSON number.
A CBOR object that represents the parsed number. Returns
- positive zero if the number is a zero that starts with a minus sign
- (such as "-0" or "-0.0"). Returns null if the parsing fails,
- including if the string is null or empty.
+ null if the parsing fails, including if the string is null or
+ empty.
@@ -674,15 +666,12 @@
- Tries to extract the fields of a date and time in the form
- of a CBOR object.
- A CBOR object that specifies a date/time
+ Tries to extract the fields of a date and time in the form
+ of a CBOR object.A CBOR object that specifies a date/time
according to the conversion type used to create this date
- converter.
- An array whose first element will store the
+ converter.An array whose first element will store the
year. The array's length must be 1 or greater. If this function
- fails, the first element is set to null.
- An array that will store the fields
+ fails, the first element is set to null.An array that will store the fields
(other than the year) of the date and time. The array's length must
be 7 or greater. If this function fails, the first seven elements
are set to 0. If this method is successful, the first seven
@@ -699,12 +688,8 @@
- 6 - Number of minutes to subtract from this date and time to
get global time. This number can be positive or negative, but
cannot be less than -1439 or greater than 1439. For tags 0 and 1,
- this value is always 0.
.
- Either true if the method is successful, or
+ this value is always 0..Either true if the method is successful, or
false otherwise.
- The parameter or is null, or
- contains fewer elements than required.
-
@@ -1472,6 +1457,13 @@
A CBOR object that stores this object's value.
+
+Converts this number's value to a CLR decimal.
+ This number's value, converted to a decimal as though by
+ (decimal)this.ToEDecimal().
+ This value is infinity or
+ not-a-number.
+
Converts this object to a decimal number.
@@ -2031,8 +2023,7 @@
part).
-
- Converts this object to a DotNet decimal.
+Converts this object to a DotNet decimal.
The closest big integer to this object.
This object does not
represent a number (for this purpose, infinities and not-a-number
@@ -2040,7 +2031,6 @@
numbers).
This object's value exceeds the
range of a DotNet decimal.
-
@@ -2252,10 +2242,8 @@
-
- Converts this object to an 8-bit signed integer.
+Converts this object to an 8-bit signed integer.
An 8-bit signed integer.
-
@@ -2294,8 +2282,7 @@
-
- Converts this object to a 16-bit unsigned integer after
+Converts this object to a 16-bit unsigned integer after
discarding any fractional part, if any, from its value.
A 16-bit unsigned integer.
This object does not
@@ -2305,11 +2292,9 @@
This object's value, if
converted to an integer by discarding its fractional part, is
outside the range of a 16-bit unsigned integer.
-
-
- Converts this object to a 32-bit unsigned integer after
+Converts this object to a 32-bit unsigned integer after
discarding any fractional part, if any, from its value.
A 32-bit unsigned integer.
This object does not
@@ -2319,11 +2304,9 @@
This object's value, if
converted to an integer by discarding its fractional part, is
outside the range of a 32-bit unsigned integer.
-
-
- Converts this object to a 64-bit unsigned integer after
+Converts this object to a 64-bit unsigned integer after
discarding any fractional part, if any, from its value.
A 64-bit unsigned integer.
This object does not
@@ -2333,7 +2316,6 @@
This object's value, if
converted to an integer by discarding its fractional part, is
outside the range of a 64-bit unsigned integer.
-
@@ -3666,13 +3648,13 @@
- A String is converted to a CBOR text
string. To create a CBOR byte string object from String ,
see the example given in .
- - In the.NET version, a nullable is converted to
- CBORObject.Null if the nullable's value is null , or
- converted according to the nullable's underlying type, if that type
- is supported by this method.
- - In the Java version, a
- number of type BigInteger or BigDecimal is converted
- to the corresponding CBOR number.
+ - In
+ the.NET version, a nullable is converted to CBORObject.Null if the nullable's value is null , or converted according to
+ the nullable's underlying type, if that type is supported by this
+ method.
+ - In the Java version, a number of type
+ BigInteger or BigDecimal is converted to the
+ corresponding CBOR number.
- A number of type
EDecimal , EFloat , EInteger , and
ERational in the PeterO.Numbers
@@ -7671,8 +7653,7 @@
-
- Contains methods useful for reading and writing text
+Contains methods useful for reading and writing text
strings. It is designed to have no dependencies other than the
basic runtime class library.
Many of these methods work with text encoded in UTF-8, an
@@ -7693,11 +7674,9 @@
found in text strings, such as throwing an error or treating the
unpaired surrogate as a replacement character
(U+FFFD).
-
-
- Gets the Unicode code point at the given index of the
+Gets the Unicode code point at the given index of the
string.
The parameter is a text
string.
@@ -7709,11 +7688,9 @@
surrogate code point. If the return value is 65536 (0x10000) or
greater, the code point takes up two UTF-16 code units.
The parameter is null.
-
-
- Gets the Unicode code point at the given index of the
+Gets the Unicode code point at the given index of the
string.
The parameter is a text
string.
@@ -7738,11 +7715,9 @@
Unpaired surrogate */ } Console.WriteLine("codePoint:"+codePoint); if
(codePoint >= 0x10000) { i++; /* Supplementary code point */ } } .
-
-
- Gets the Unicode code point just before the given index of
+Gets the Unicode code point just before the given index of
the string.
The parameter is a text
string.
@@ -7754,11 +7729,9 @@
surrogate code point. If the return value is 65536 (0x10000) or
greater, the code point takes up two UTF-16 code units.
The parameter is null.
-
-
- Gets the Unicode code point just before the given index of
+Gets the Unicode code point just before the given index of
the string.
The parameter is a text
string.
@@ -7776,11 +7749,9 @@
return value is 65536 (0x10000) or greater, the code point takes up
two UTF-16 code units.
The parameter is null.
-
-
- Compares two strings in Unicode code point order. Unpaired
+Compares two strings in Unicode code point order. Unpaired
surrogate code points are treated as individual code
points.
The first string. Can be null.
@@ -7792,11 +7763,9 @@
null and a isn't; or the first code point that's different is
greater in A than in B; or a starts with b and is longer than
b.
-
-
- Finds the number of Unicode code points in the given text
+Finds the number of Unicode code points in the given text
string. Unpaired surrogate code points increase this number by 1.
This is not necessarily the length of the string in "char"
s.
@@ -7805,11 +7774,9 @@
The number of Unicode code points in the given
string.
The parameter is null.
-
-
- Encodes a string in UTF-8 as a byte array. This method does
+Encodes a string in UTF-8 as a byte array. This method does
not insert a byte-order mark (U+FEFF) at the beginning of the
encoded byte array.
REMARK: It is not recommended to use
@@ -7826,11 +7793,9 @@
The string contains an unpaired
surrogate code point and is false, or an
internal error occurred.
-
-
- Encodes a string in UTF-8 as a byte array. This method does
+Encodes a string in UTF-8 as a byte array. This method does
not insert a byte-order mark (U+FEFF) at the beginning of the
encoded byte array.
REMARK: It is not recommended to use
@@ -7850,11 +7815,9 @@
The string contains an unpaired
surrogate code point and is false, or an
internal error occurred.
-
-
- Calculates the number of bytes needed to encode a string
+Calculates the number of bytes needed to encode a string
in UTF-8.
The parameter is a text
string.
@@ -7865,11 +7828,9 @@
UTF-8, or -1 if the string contains an unpaired surrogate code
point and is false.
The parameter is null.
-
-
- Generates a text string from a UTF-8 byte array.
+Generates a text string from a UTF-8 byte array.
A byte array containing text encoded in
UTF-8.
If true, replaces invalid encoding with the
@@ -7879,11 +7840,9 @@
The parameter is null.
The string is not valid UTF-8
and is false.
-
-
- Generates a text string from a portion of a UTF-8 byte
+Generates a text string from a portion of a UTF-8 byte
array.
A byte array containing text encoded in
UTF-8.
@@ -7902,11 +7861,9 @@
The parameter is less than 0, is
less than 0, or offset plus bytesCount is greater than the length
of "data" .
-
-
- Reads a string in UTF-8 encoding from a data
+Reads a string in UTF-8 encoding from a data
stream.
A readable data stream.
The length, in bytes, of the string. If
@@ -7925,11 +7882,9 @@
occurred.
The parameter is null or is
null.
-
-
- Reads a string in UTF-8 encoding from a byte
+Reads a string in UTF-8 encoding from a byte
array.
A byte array containing a UTF-8 text
string.
@@ -7950,11 +7905,9 @@
The parameter is less than 0, is
less than 0, or offset plus bytesCount is greater than the length
of .
-
-
- Reads a string in UTF-8 encoding from a data stream in
+Reads a string in UTF-8 encoding from a data stream in
full and returns that string. Replaces invalid encoding with the
replacement character (U+FFFD).
A readable data stream.
@@ -7962,11 +7915,9 @@
An I/O error
occurred.
The parameter is null.
-
-
- Reads a string in UTF-8 encoding from a data stream and
+Reads a string in UTF-8 encoding from a data stream and
returns that string.
A readable data stream.
The length, in bytes, of the string. If
@@ -7980,33 +7931,27 @@
the string is not valid UTF-8 and is
false.
The parameter is null.
-
-
- Returns a string with the basic upper-case letters A to Z
+Returns a string with the basic upper-case letters A to Z
(U+0041 to U+005A) converted to the corresponding basic lower-case
letters. Other characters remain unchanged.
The parameter is a text
string.
The converted string, or null if is
null.
-
-
- Returns a string with the basic lower-case letters A to Z
+Returns a string with the basic lower-case letters A to Z
(U+0061 to U+007A) converted to the corresponding basic upper-case
letters. Other characters remain unchanged.
The parameter is a text
string.
The converted string, or null if is
null.
-
-
- Writes a string in UTF-8 encoding to a data
+Writes a string in UTF-8 encoding to a data
stream.
A string to write.
A writable data stream.
@@ -8019,11 +7964,9 @@
null.
An I/O error
occurred.
-
-
- Writes a portion of a string in UTF-8 encoding to a data
+Writes a portion of a string in UTF-8 encoding to a data
stream.
A string to write.
The Index starting at 0 where the string
@@ -8044,11 +7987,9 @@
Either or is less than 0 or
greater than 's length, or 's length minus is less than
.
-
-
- Writes a portion of a string in UTF-8 encoding to a data
+Writes a portion of a string in UTF-8 encoding to a data
stream.
A string to write.
The Index starting at 0 where the string
@@ -8072,6 +8013,5 @@
is greater than the string's length.
An I/O error
occurred.
-
diff --git a/CBOR/rules.ruleset b/CBOR/rules.ruleset
index 648cbd40..83ba9119 100644
--- a/CBOR/rules.ruleset
+++ b/CBOR/rules.ruleset
@@ -1,41 +1,47 @@
-
-
+
+
-
+
-
-
+
+
+
-
+
-
+
+
-
+
+
-
-
+
+
+
+
+
-
-
-
+
+
+
diff --git a/CBORDocs2/DocVisitor.cs b/CBORDocs2/DocVisitor.cs
index c5dbb2f3..e95a7768 100644
--- a/CBORDocs2/DocVisitor.cs
+++ b/CBORDocs2/DocVisitor.cs
@@ -369,7 +369,8 @@ public static string FormatTypeRaw(Type type) {
}
public static string FormatTypeSig(Type typeInfo) {
- bool isPublic = typeInfo.IsNested ? typeInfo.IsNestedPublic : typeInfo.IsPublic;
+ bool isPublic = typeInfo.IsNested ? typeInfo.IsNestedPublic :
+typeInfo.IsPublic;
var builder = new StringBuilder();
_ = builder.Append(FourSpaces);
_ = isPublic ? builder.Append("public ") : builder.Append("internal ");
@@ -800,8 +801,8 @@ private static string Heading(MemberInfo info) {
} else if (info is PropertyInfo property) {
return property.Name;
} else {
- return (info is FieldInfo field) ? field.Name : ret;
-}
+ return (info is FieldInfo field) ? field.Name : ret;
+ }
}
private static string HeadingUnambiguous(MemberInfo info) {
diff --git a/CBORDocs2/TypeNameUtil.cs b/CBORDocs2/TypeNameUtil.cs
index b9a9fb83..1356f6d6 100644
--- a/CBORDocs2/TypeNameUtil.cs
+++ b/CBORDocs2/TypeNameUtil.cs
@@ -128,10 +128,10 @@ public static string XmlDocMemberName(object obj) {
if (!first) {
_ = msb.Append(',');
}
- _ = msb.Append(XmlDocTypeName(
+ string typeNameString = XmlDocTypeName(
p.ParameterType,
true,
- genericMethod));
+ genericMethod);
first = false;
}
_ = msb.Append(')');
diff --git a/CBORTest/BEncoding.cs b/CBORTest/BEncoding.cs
index eb2b1a4b..494e3b1e 100644
--- a/CBORTest/BEncoding.cs
+++ b/CBORTest/BEncoding.cs
@@ -90,21 +90,23 @@ public static CBORObject Read(Stream stream) {
private static CBORObject ReadObject(Stream stream, bool allowEnd) {
int c = stream.ReadByte();
- if (c == 'd') {
- return ReadDictionary(stream);
- }
- return c == 'l' ? ReadList(stream) : allowEnd && c == 'e' ? null :
- c == 'i' ? ReadInteger(stream) :
- c is >= '0' and <= '9' ? ReadString(stream, (char)c) : throw new
-CBORException("Object expected");
+ return c switch {
+ 'd' => ReadDictionary(stream),
+ 'l' => ReadList(stream),
+ 'i' => ReadInteger(stream),
+ 'e' => allowEnd ? null : throw new CBORException("Object expected"),
+ '0' or '1' or '2' or '3' or '4' or '5' or '6' or '7' or '8' or '9'
+=> ReadString(stream, (char)c),
+ _ => throw new CBORException("Object expected"),
+ };
}
private const string ValueDigits = "0123456789";
public static string LongToString(long longValue) {
- return longValue == long.MinValue ?
+ return longValue == Int64.MinValue ?
"-9223372036854775808" : longValue == 0L ?
- "0" : (longValue == int.MinValue) ? "-2147483648" :
+ "0" : (longValue == Int32.MinValue) ? "-2147483648" :
EInteger.FromInt64(longValue).ToString();
}
diff --git a/CBORTest/CBORGenerator.cs b/CBORTest/CBORGenerator.cs
index 5396ab0e..8894c73d 100644
--- a/CBORTest/CBORGenerator.cs
+++ b/CBORTest/CBORGenerator.cs
@@ -8,17 +8,19 @@ private sealed class ByteWriter {
public ByteWriter Write(int b) {
if (this.ByteLength < this.bytes.Length) {
- this.bytes[this.ByteLength++] = (byte)b;
+ this.bytes[this.ByteLength] = (byte)b;
+ ++this.ByteLength;
} else {
var newbytes = new byte[this.bytes.Length * 2];
Array.Copy(this.bytes, 0, newbytes, 0, this.bytes.Length);
this.bytes = newbytes;
- this.bytes[this.ByteLength++] = (byte)b;
+ this.bytes[this.ByteLength] = (byte)b;
+ ++this.ByteLength;
}
return this;
}
- public int ByteLength { get; private set; }
+ public int ByteLength { get; set; }
public byte[] ToBytes() {
var newbytes = new byte[this.ByteLength];
@@ -245,8 +247,11 @@ private void Generate(IRandomGenExtended r, int depth, ByteWriter bs) {
break;
case 1:
_ = bs.Write((majorType * 0x20) + 0x18);
- _ = majorType == 7 ? bs.Write(32 + r.GetInt32(224)) :
-bs.Write(r.GetInt32(256));
+ if (majorType == 7) {
+ bs.Write(32 + r.GetInt32(224));
+ } else {
+ bs.Write(r.GetInt32(256));
+ }
break;
case 2:
_ = bs.Write((majorType * 0x20) + 0x19);
diff --git a/CBORTest/CBORNumberTest.cs b/CBORTest/CBORNumberTest.cs
index 0071176c..93719885 100644
--- a/CBORTest/CBORNumberTest.cs
+++ b/CBORTest/CBORNumberTest.cs
@@ -206,8 +206,9 @@ public void TestMultiply() {
for (int i = 0; i < 3000; ++i) {
CBORObject o1 = CBORTestCommon.RandomNumber(r);
CBORObject o2 = CBORTestCommon.RandomNumber(r);
- EDecimal cmpDecFrac = AsED(o1).Multiply(AsED(o2));
- var cmpCobj = ToCN(o1).Multiply(ToCN(o2)).ToEDecimal();
+ EDecimal cmpDecFrac, cmpCobj;
+ cmpDecFrac = AsED(o1).Multiply(AsED(o2));
+ cmpCobj = ToCN(o1).Multiply(ToCN(o2)).ToEDecimal();
if (!cmpDecFrac.Equals(cmpCobj)) {
TestCommon.CompareTestEqual(
cmpDecFrac,
diff --git a/CBORTest/CBORObjectTest.cs b/CBORTest/CBORObjectTest.cs
index 2a1eac96..36aa310a 100644
--- a/CBORTest/CBORObjectTest.cs
+++ b/CBORTest/CBORObjectTest.cs
@@ -11,10 +11,16 @@ namespace Test {
[TestFixture]
#pragma warning disable CS0618
public class CBORObjectTest {
+ /*
+ private static readonly string[] ValueJsonSurrogateFails = {
+ "\"\\ud800-udc00\"",
+ "\"-ud800\\udc00\"",
+ "[\"-ud800\\udc00\"]", "[\"\\ud800-udc00\"]",
+ }
+ */
+
private static readonly string[] ValueJsonFails = {
- "\"\\uxxxx\"",
- "\"\\ud800\udc00\"",
- "\"\ud800\\udc00\"", "\"\\U0023\"", "\"\\u002x\"", "\"\\u00xx\"",
+ "\"\\uxxxx\"", "\"\\U0023\"", "\"\\u002x\"", "\"\\u00xx\"",
"\"\\u0xxx\"", "\"\\u0\"", "\"\\u00\"", "\"\\u000\"", "trbb",
"trub", "falsb", "nulb", "[true", "[true,", "[true]!", "tr\u0020",
"tr", "fa", "nu", "True", "False", "Null", "TRUE", "FALSE", "NULL",
@@ -22,9 +28,9 @@ public class CBORObjectTest {
"[tr]", "[fa]",
"[nu]", "[True]", "[False]", "[Null]", "[TRUE]", "[FALSE]", "[NULL]",
"[truE]", "[falsE]",
+ "[\"\\udc00\ud800\udc00\"]", "[\"\\ud800\ud800\udc00\"]",
"[nulL]", "[tRUE]", "[fALSE]", "[nULL]", "[tRuE]", "[fAlSe]", "[nUlL]",
"fa ", "nu ", "fa lse", "nu ll", "tr ue",
- "[\"\ud800\\udc00\"]", "[\"\\ud800\udc00\"]",
"[\"\\udc00\ud800\udc00\"]", "[\"\\ud800\ud800\udc00\"]",
"[\"\\ud800\"]", "[1,2,", "[1,2,3", "{,\"0\":0,\"1\":1}",
"{\"0\"::0}", "{\"0\":0,,\"1\":1}",
@@ -1514,9 +1520,9 @@ public void TestCanTruncatedIntFitInInt32() {
.AsNumber().CanTruncatedIntFitInInt32());
Assert.IsTrue(ToObjectTest.TestToFromObjectRoundTrip(2.5)
.AsNumber().CanTruncatedIntFitInInt32());
- Assert.IsTrue(ToObjectTest.TestToFromObjectRoundTrip(int.MinValue)
+ Assert.IsTrue(ToObjectTest.TestToFromObjectRoundTrip(Int32.MinValue)
.AsNumber().CanTruncatedIntFitInInt32());
- Assert.IsTrue(ToObjectTest.TestToFromObjectRoundTrip(int.MaxValue)
+ Assert.IsTrue(ToObjectTest.TestToFromObjectRoundTrip(Int32.MaxValue)
.AsNumber().CanTruncatedIntFitInInt32());
var negint32 = new object[] {
double.PositiveInfinity,
@@ -1732,6 +1738,15 @@ public void TestSlowCompareTo2() {
TestCommon.CompareTestGreater(cbor1.AsNumber(), cbor2.AsNumber());
}
+ [Test]
+ public void TestSuccessfulDecode() {
+ CBORObject.DecodeFromBytes(new byte[] {
+ (byte)0xc0, 0x78, 0x18, 0x31,
+ 0x39, 0x36, 0x39, 0x2d, 0x31, 0x32, 0x2d, 0x33, 0x31, 0x54, 0x32, 0x33,
+ 0x3a, 0x35, 0x39, 0x3a, 0x35, 0x39, 0x2e, 0x39, 0x39, 0x39, 0x5a,
+ });
+ }
+
[Test]
[Timeout(1000)]
public void TestSlowCompareTo6() {
@@ -4161,8 +4176,9 @@ public void TestAsNumberMultiply() {
for (int i = 0; i < 3000; ++i) {
CBORObject o1 = CBORTestCommon.RandomNumber(r);
CBORObject o2 = CBORTestCommon.RandomNumber(r);
- EDecimal cmpDecFrac = AsED(o1).Multiply(AsED(o2));
- var cmpCobj = o1.AsNumber().Multiply(o2.AsNumber()).ToEDecimal();
+ EDecimal cmpDecFrac, cmpCobj;
+ cmpDecFrac = AsED(o1).Multiply(AsED(o2));
+ cmpCobj = o1.AsNumber().Multiply(o2.AsNumber()).ToEDecimal();
if (!cmpDecFrac.Equals(cmpCobj)) {
TestCommon.CompareTestEqual(
cmpDecFrac,
@@ -6753,7 +6769,7 @@ public static void TestWriteExtraOne(long longValue) {
TestWriteObj(bigintVal, bigintVal);
}
- if (longValue is >= int.MinValue and <= int.MaxValue) {
+ if (longValue is >= Int32.MinValue and <= Int32.MaxValue) {
var intval = (int)longValue;
{
CBORObject cborTemp1 =
@@ -6937,8 +6953,8 @@ public void TestWriteExtra() {
-32768, -65536, -32769, -65537,
0x7fffff, 0x7fff7f, 0x7fff7fff, 0x7fff7fff7fL, 0x7fff7fff7fffL,
0x7fff7fff7fff7fL, 0x7fff7fff7fff7fffL,
- long.MaxValue, long.MinValue, int.MinValue,
- int.MaxValue,
+ Int64.MaxValue, Int64.MinValue, Int32.MinValue,
+ Int32.MaxValue,
};
for (int i = 0; i < values.Length; ++i) {
TestWriteExtraOne(values[i]);
@@ -7650,6 +7666,7 @@ public void TestWriteValue() {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
}
+ {
using var ms = new Test.DelayingStream();
try {
_ = CBORObject.WriteValue(ms, -1, 0);
@@ -7679,7 +7696,7 @@ public void TestWriteValue() {
throw new InvalidOperationException(String.Empty, ex);
}
try {
- _ = CBORObject.WriteValue(ms, 7, int.MaxValue);
+ _ = CBORObject.WriteValue(ms, 7, Int32.MaxValue);
Assert.Fail("Should have failed");
} catch (ArgumentException) {
// NOTE: Intentionally empty
@@ -7688,7 +7705,7 @@ public void TestWriteValue() {
throw new InvalidOperationException(String.Empty, ex);
}
try {
- _ = CBORObject.WriteValue(ms, 7, long.MaxValue);
+ _ = CBORObject.WriteValue(ms, 7, Int64.MaxValue);
Assert.Fail("Should have failed");
} catch (ArgumentException) {
// NOTE: Intentionally empty
@@ -7707,7 +7724,7 @@ public void TestWriteValue() {
throw new InvalidOperationException(String.Empty, ex);
}
try {
- _ = CBORObject.WriteValue(ms, i, int.MinValue);
+ _ = CBORObject.WriteValue(ms, i, Int32.MinValue);
Assert.Fail("Should have failed");
} catch (ArgumentException) {
// NOTE: Intentionally empty
@@ -7725,7 +7742,7 @@ public void TestWriteValue() {
throw new InvalidOperationException(String.Empty, ex);
}
try {
- _ = CBORObject.WriteValue(ms, i, long.MinValue);
+ _ = CBORObject.WriteValue(ms, i, Int64.MinValue);
Assert.Fail("Should have failed");
} catch (ArgumentException) {
// NOTE: Intentionally empty
@@ -7736,13 +7753,13 @@ public void TestWriteValue() {
}
for (int i = 0; i <= 6; ++i) {
try {
- _ = CBORObject.WriteValue(ms, i, int.MaxValue);
+ _ = CBORObject.WriteValue(ms, i, Int32.MaxValue);
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
}
try {
- _ = CBORObject.WriteValue(ms, i, long.MaxValue);
+ _ = CBORObject.WriteValue(ms, i, Int64.MaxValue);
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
@@ -7787,6 +7804,7 @@ public void TestWriteValue() {
bj += EInteger.One;
}
}
+ }
} catch (IOException ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(ex.ToString(), ex);
@@ -9172,8 +9190,9 @@ private static string RandomQueryStringLike(IRandomGenExtended irg) {
_ = sb.Append(hex[irg.GetInt32(hex.Length)]);
_ = sb.Append(hex[irg.GetInt32(hex.Length)]);
} else {
- _ = x < 95 ? sb.Append((char)(irg.GetInt32(0x5e) + 0x21)) :
-sb.Append((char)irg.GetInt32(0x80));
+ char charToAppend = x < 95 ? ((char)(irg.GetInt32(0x5e) + 0x21)) :
+ ((char)irg.GetInt32(0x80));
+ sb.Append(charToAppend);
}
}
return sb.ToString();
@@ -9766,7 +9785,7 @@ public void TestFromJsonLeadingTrailingCTL() {
public void TestFromJsonStringSmallDoubleSpec() {
var rg = new RandomGenerator();
for (int i = 0; i < 10000; ++i) {
- int rv = rg.GetInt32(int.MaxValue) * ((rg.GetInt32(2) * 2) - 1);
+ int rv = rg.GetInt32(Int32.MaxValue) * ((rg.GetInt32(2) * 2) - 1);
string rvstring = TestCommon.IntToString(rv);
AssertJSONDouble(
rvstring,
@@ -9780,17 +9799,17 @@ public void TestFromJsonStringSmallDoubleSpec() {
AssertJSONDouble("511", "double", 511);
AssertJSONDouble("-511", "double", -511);
AssertJSONDouble(
- TestCommon.IntToString(int.MaxValue),
+ TestCommon.IntToString(Int32.MaxValue),
"double",
- int.MaxValue);
+ Int32.MaxValue);
AssertJSONDouble(
- TestCommon.IntToString(int.MaxValue),
+ TestCommon.IntToString(Int32.MaxValue),
"double",
- int.MaxValue);
+ Int32.MaxValue);
AssertJSONDouble(
- TestCommon.IntToString(int.MinValue),
+ TestCommon.IntToString(Int32.MinValue),
"double",
- int.MinValue);
+ Int32.MinValue);
}
[Test]
diff --git a/CBORTest/CBORPlistWriter.cs b/CBORTest/CBORPlistWriter.cs
index b1760b82..68539830 100644
--- a/CBORTest/CBORPlistWriter.cs
+++ b/CBORTest/CBORPlistWriter.cs
@@ -330,8 +330,10 @@ internal static void WritePlistToInternalCore(
break;
}
default:
- str = key.ToJSONString(options);
- break;
+ {
+ str = key.ToJSONString(options);
+ break;
+ }
}
if (stringMap.ContainsKey(str)) {
throw new CBORException(
diff --git a/CBORTest/CBORSupplementTest.cs b/CBORTest/CBORSupplementTest.cs
index 5648dd0e..9397ce66 100644
--- a/CBORTest/CBORSupplementTest.cs
+++ b/CBORTest/CBORSupplementTest.cs
@@ -356,7 +356,7 @@ public void TestNestingDepth() {
}
// Maximum nesting depth not reached, so shouldn't throw
try {
- _ = CBORObject.DecodeFromBytes(ms.ToArray());
+ CBORObject.DecodeFromBytes(ms.ToArray());
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
@@ -700,8 +700,9 @@ public static void TestMiniCBOR() {
Assert.AreEqual(-1 - 7, MiniCBOR.ReadInt32(ms5));
}
bytes = new byte[] { 0x37 };
- using var ms6 = new Test.DelayingStream(bytes);
- Assert.AreEqual(-1 - 0x17, MiniCBOR.ReadInt32(ms6));
+ using (var ms6 = new Test.DelayingStream(bytes)) {
+ Assert.AreEqual(-1 - 0x17, MiniCBOR.ReadInt32(ms6));
+ }
} catch (IOException ioex) {
Assert.Fail(ioex.Message);
}
diff --git a/CBORTest/CBORTest.cs b/CBORTest/CBORTest.cs
index 276170c0..7db299d7 100644
--- a/CBORTest/CBORTest.cs
+++ b/CBORTest/CBORTest.cs
@@ -1899,10 +1899,10 @@ public void TestJSONEscapedChars() {
public void TestLong() {
long[] ranges = {
0, 65539, 0xfffff000L, 0x100000400L,
- long.MaxValue - 1000,
- long.MaxValue,
- long.MinValue,
- long.MinValue + 1000,
+ Int64.MaxValue - 1000,
+ Int64.MaxValue,
+ Int64.MinValue,
+ Int64.MinValue + 1000,
};
ranges[0] = -65539;
var jso = new JSONOptions("numberconversion=full");
@@ -2388,7 +2388,8 @@ public static void TestRandomOne(byte[] array) {
}
} catch (CBORException ex) {
// Expected exception
- Console.Write(ex.Message[..0]);
+ string exmessage = ex.Message;
+ Console.Write(exmessage[..0]);
} catch (InvalidOperationException ex) {
string failString = ex.ToString() +
(ex.InnerException == null ? String.Empty : "\n" +
@@ -2397,8 +2398,8 @@ public static void TestRandomOne(byte[] array) {
failString += "\nstart pos: " + oldPos + ", truelen=" +
(inputStream.Position - oldPos);
failString += "\n" + TestCommon.ToByteArrayString(array);
- failString = failString[
-..Math.Min(2000, failString.Length)];
+ int endPos = Math.Min(2000, failString.Length);
+ failString = failString[..endPos];
throw new InvalidOperationException(failString, ex);
}
}
@@ -2468,10 +2469,10 @@ public void TestUnsignedLong() {
TestUnsignedLongOne(0xFFFFFFFFL, "ffffffff");
TestUnsignedLongOne(-1, "ffffffffffffffff");
TestUnsignedLongOne(-3, "fffffffffffffffd");
- TestUnsignedLongOne(long.MaxValue, "7fffffffffffffff");
- TestUnsignedLongOne(long.MaxValue - 1, "7ffffffffffffffe");
- TestUnsignedLongOne(long.MinValue, "8000000000000000");
- TestUnsignedLongOne(long.MinValue + 1, "8000000000000001");
+ TestUnsignedLongOne(Int64.MaxValue, "7fffffffffffffff");
+ TestUnsignedLongOne(Int64.MaxValue - 1, "7ffffffffffffffe");
+ TestUnsignedLongOne(Int64.MinValue, "8000000000000000");
+ TestUnsignedLongOne(Int64.MinValue + 1, "8000000000000001");
}
[Test]
@@ -3793,35 +3794,35 @@ private static void TestFailingDecode(byte[] bytes, CBOREncodeOptions
new int[] { 11, 31, 0, 0, 0, 0, 0 },
new int[] { 12, 32, 0, 0, 0, 0, 0 },
new int[] { 13, 1, 0, 0, 0, 0, 0 },
- new int[] { int.MinValue, 1, 0, 0, 0, 0, 0 },
- new int[] { int.MaxValue, 1, 0, 0, 0, 0, 0 },
+ new int[] { Int32.MinValue, 1, 0, 0, 0, 0, 0 },
+ new int[] { Int32.MaxValue, 1, 0, 0, 0, 0, 0 },
new int[] { 1, 0, 0, 0, 0, 0, 0 },
new int[] { 1, -1, 0, 0, 0, 0, 0 },
- new int[] { 1, int.MinValue, 0, 0, 0, 0, 0 },
+ new int[] { 1, Int32.MinValue, 0, 0, 0, 0, 0 },
new int[] { 1, 32, 0, 0, 0, 0, 0 },
- new int[] { 1, int.MaxValue, 0, 0, 0, 0, 0 },
+ new int[] { 1, Int32.MaxValue, 0, 0, 0, 0, 0 },
new int[] { 1, 1, -1, 0, 0, 0, 0 },
- new int[] { 1, 1, int.MinValue, 0, 0, 0, 0 },
+ new int[] { 1, 1, Int32.MinValue, 0, 0, 0, 0 },
new int[] { 1, 1, 24, 0, 0, 0, 0 },
new int[] { 1, 1, 59, 0, 0, 0, 0 },
new int[] { 1, 1, 60, 0, 0, 0, 0 },
- new int[] { 1, 1, int.MaxValue, 0, 0, 0, 0 },
+ new int[] { 1, 1, Int32.MaxValue, 0, 0, 0, 0 },
new int[] { 1, 1, 0, -1, 0, 0, 0 },
- new int[] { 1, 1, 0, int.MinValue, 0, 0, 0 },
+ new int[] { 1, 1, 0, Int32.MinValue, 0, 0, 0 },
new int[] { 1, 1, 0, 60, 0, 0, 0 },
- new int[] { 1, 1, 0, int.MaxValue, 0, 0, 0 },
+ new int[] { 1, 1, 0, Int32.MaxValue, 0, 0, 0 },
new int[] { 1, 1, 0, 0, -1, 0, 0 },
- new int[] { 1, 1, 0, 0, int.MinValue, 0, 0 },
+ new int[] { 1, 1, 0, 0, Int32.MinValue, 0, 0 },
new int[] { 1, 1, 0, 0, 60, 0, 0 },
- new int[] { 1, 1, 0, 0, int.MaxValue, 0, 0 },
+ new int[] { 1, 1, 0, 0, Int32.MaxValue, 0, 0 },
new int[] { 1, 1, 0, 0, 0, -1, 0 },
- new int[] { 1, 1, 0, 0, 0, int.MinValue, 0 },
+ new int[] { 1, 1, 0, 0, 0, Int32.MinValue, 0 },
new int[] { 1, 1, 0, 0, 0, 1000 * 1000 * 1000, 0 },
- new int[] { 1, 1, 0, 0, 0, int.MaxValue, 0 },
+ new int[] { 1, 1, 0, 0, 0, Int32.MaxValue, 0 },
new int[] { 1, 1, 0, 0, 0, 0, -1440 },
- new int[] { 1, 1, 0, 0, 0, 0, int.MinValue },
+ new int[] { 1, 1, 0, 0, 0, 0, Int32.MinValue },
new int[] { 1, 1, 0, 0, 0, 0, 1440 },
- new int[] { 1, 1, 0, 0, 0, 0, int.MaxValue },
+ new int[] { 1, 1, 0, 0, 0, 0, Int32.MaxValue },
};
private static void TestBadDateFieldsOne(CBORDateConverter conv) {
@@ -4185,10 +4186,6 @@ public void TestBigNumberThresholds() {
false, false, false, false, true, false, true,
false,
};
- _ = new bool[] {
- false, false, false, false, true, true, true,
- true,
- };
for (int i = 0; i < eints.Length; ++i) {
CBORObject cbor;
bool isNegative = eints[i].Sign < 0;
@@ -4252,9 +4249,10 @@ public void TestBigNumberThresholds() {
Assert.AreEqual(CBORType.Integer, cbor[0].Type);
Assert.AreEqual(0, cbor[0].TagCount);
}
- using var ms2 = new Test.DelayingStream();
- CBORObject.Write(ed, ms2);
- cbor = CBORObject.DecodeFromBytes(ms2.ToArray());
+ using (var ms2 = new Test.DelayingStream()) {
+ CBORObject.Write(ed, ms2);
+ cbor = CBORObject.DecodeFromBytes(ms2.ToArray());
+ }
Assert.IsTrue(cbor.IsNumber, cbor.ToString());
if (isPastCbor[i]) {
Assert.IsTrue(cbor.HasOneTag(264));
@@ -4631,8 +4629,9 @@ private static ERational AsER(CBORObject obj) {
}
private static void AddSubCompare(CBORObject o1, CBORObject o2) {
- EDecimal cmpDecFrac = AsED(o1).Add(AsED(o2));
- var cmpCobj = o1.AsNumber().Add(o2.AsNumber()).ToEDecimal();
+ EDecimal cmpDecFrac, cmpCobj;
+ cmpDecFrac = AsED(o1).Add(AsED(o2));
+ cmpCobj = o1.AsNumber().Add(o2.AsNumber()).ToEDecimal();
TestCommon.CompareTestEqual(cmpDecFrac, cmpCobj);
cmpDecFrac = AsED(o1).Subtract(AsED(o2));
cmpCobj = o1.AsNumber().Subtract(o2.AsNumber()).ToEDecimal();
diff --git a/CBORTest/JSONGenerator.cs b/CBORTest/JSONGenerator.cs
index fd467956..c144af68 100644
--- a/CBORTest/JSONGenerator.cs
+++ b/CBORTest/JSONGenerator.cs
@@ -10,17 +10,19 @@ private sealed class ByteWriter {
public ByteWriter Write(int b) {
if (this.ByteLength < this.bytes.Length) {
- this.bytes[this.ByteLength++] = (byte)b;
+ this.bytes[this.ByteLength] = (byte)b;
+ ++this.ByteLength;
} else {
var newbytes = new byte[this.bytes.Length * 2];
Array.Copy(this.bytes, 0, newbytes, 0, this.bytes.Length);
this.bytes = newbytes;
- this.bytes[this.ByteLength++] = (byte)b;
+ this.bytes[this.ByteLength] = (byte)b;
+ ++this.ByteLength;
}
return this;
}
- public int ByteLength { get; private set; }
+ public int ByteLength { get; set; }
public byte[] ToBytes() {
var newbytes = new byte[this.ByteLength];
@@ -56,8 +58,9 @@ private static void GenerateCodeUnit(
var shift = 12;
for (int i = 0; i < 4; ++i) {
c = (cu >> shift) & 0xf;
- _ = c < 10 ? bs.Write(0x30 + c) : bs.Write(0x41 + (c - 10) +
-(ra.GetInt32(2) * 0x20));
+ int bw = c < 10 ? (0x30 + c) : (0x41 + (c - 10) +
+ (ra.GetInt32(2) * 0x20));
+ bs.Write(bw);
shift -= 4;
}
}
@@ -278,8 +281,10 @@ private static void GenerateJsonString(
int r = ra.GetInt32(10);
if (r > 2) {
int x = 0x20 + ra.GetInt32(60);
- _ = x == '\"' ? bs.Write('\\').Write(x) : x == '\\' ?
-bs.Write('\\').Write(x) : bs.Write(x);
+ if (x is '\"' or '\\') {
+ bs.Write('\\');
+ }
+ bs.Write(x);
++i;
} else if (r == 1) {
_ = bs.Write('\\');
diff --git a/CBORTest/JSONWithComments.cs b/CBORTest/JSONWithComments.cs
index e41b30e6..a47792d2 100644
--- a/CBORTest/JSONWithComments.cs
+++ b/CBORTest/JSONWithComments.cs
@@ -420,7 +420,7 @@ private string GetJSONPointer() {
_ = sb.Append("/");
string str = obj.AsString();
for (int j = 0; j < str.Length; ++j) {
- _ = str[j] == '/' ? sb.Append("~1") : str[j] == '~' ?
+ sb = str[j] == '/' ? sb.Append("~1") : str[j] == '~' ?
sb.Append("~0") : sb.Append(str[j]);
}
} else {
diff --git a/CBORTest/MiniCBOR.cs b/CBORTest/MiniCBOR.cs
index deef6cd0..9c1c9f53 100644
--- a/CBORTest/MiniCBOR.cs
+++ b/CBORTest/MiniCBOR.cs
@@ -118,8 +118,11 @@ public static bool ReadBoolean(Stream stream) {
}
b = stream.ReadByte();
}
- return b != 0xf4 && (b == 0xf5 ? true : throw new IOException("Not a" +
-"\u0020boolean"));
+ return b switch {
+ 0xf4 => false,
+ 0xf5 => true,
+ _ => throw new IOException("Not a boolean"),
+ };
}
public static void WriteBoolean(bool value, Stream stream) {
@@ -200,12 +203,6 @@ private static long ReadInteger(
bytes[3] != 0)) {
throw new IOException("Not a 32-bit integer");
}
- if (!check32bit) {
- _ = ((long)bytes[0]) & 0xff;
- _ = ((long)bytes[1]) & 0xff;
- _ = ((long)bytes[2]) & 0xff;
- _ = ((long)bytes[3]) & 0xff;
- }
b = ((long)bytes[4]) & 0xff;
b <<= 8;
b |= ((long)bytes[5]) & 0xff;
@@ -366,7 +363,7 @@ public static int ReadInt32(Stream stream) {
throw new IOException("Not a 32-bit integer");
}
dbl = (dbl < 0) ? Math.Ceiling(dbl) : Math.Floor(dbl);
- return dbl is < int.MinValue or > int.MaxValue ? throw new
+ return dbl is < Int32.MinValue or > Int32.MaxValue ? throw new
IOException("Not a 32-bit integer") : (int)dbl;
}
return (b & 0xdc) == 0x18 ? (int)ReadInteger(stream, b, true) : throw
diff --git a/CBORTest/QueryStringHelper.cs b/CBORTest/QueryStringHelper.cs
index 698b9d7e..160c6e7c 100644
--- a/CBORTest/QueryStringHelper.cs
+++ b/CBORTest/QueryStringHelper.cs
@@ -11,11 +11,11 @@ namespace Test {
public sealed class QueryStringHelper {
private QueryStringHelper() {
}
- private static string[] SplitAt(string s, string delimiter) {
+ private static string[] SplitAt(string stringToSplit, string delimiter) {
if (delimiter == null || delimiter.Length == 0) {
throw new ArgumentException();
}
- if (s == null || s.Length == 0) {
+ if (stringToSplit == null || stringToSplit.Length == 0) {
return new string[] { String.Empty };
}
var index = 0;
@@ -23,19 +23,22 @@ private static string[] SplitAt(string s, string delimiter) {
List strings = null;
int delimLength = delimiter.Length;
while (true) {
- int index2 = s.IndexOf(delimiter, index, StringComparison.Ordinal);
+ int index2 = stringToSplit.IndexOf(
+ delimiter,
+ index,
+ StringComparison.Ordinal);
if (index2 < 0) {
if (first) {
- return new string[] { s };
+ return new string[] { stringToSplit };
}
- strings.Add(s[index..]);
+ strings.Add(stringToSplit[index..]);
break;
} else {
if (first) {
strings = new List();
first = false;
}
- string newstr = s[index..index2];
+ string newstr = stringToSplit[index..index2];
strings.Add(newstr);
index = index2 + delimLength;
}
@@ -235,7 +238,7 @@ public static string IntToString(int value) {
if (value == 0) {
return "0";
}
- if (value == int.MinValue) {
+ if (value == Int32.MinValue) {
return "-2147483648";
}
bool neg = value < 0;
diff --git a/CBORTest/StringAndBigInt.cs b/CBORTest/StringAndBigInt.cs
index cc19f9c7..28067361 100644
--- a/CBORTest/StringAndBigInt.cs
+++ b/CBORTest/StringAndBigInt.cs
@@ -14,6 +14,11 @@ internal sealed class StringAndBigInt {
public EInteger BigIntValue { get; private set; }
+ private StringAndBigInt(string sv, EInteger biv) {
+ this.StringValue = sv;
+ this.BigIntValue = biv;
+ }
+
public static StringAndBigInt Generate(IRandomGenExtended rand, int radix) {
return Generate(rand, radix, 50);
}
@@ -31,7 +36,6 @@ public static StringAndBigInt Generate(
") is more than 36");
}
EInteger bv = EInteger.Zero;
- var sabi = new StringAndBigInt();
int numDigits = 1 + rand.GetInt32(maxNumDigits);
var negative = false;
var builder = new StringBuilder();
@@ -54,13 +58,13 @@ public static StringAndBigInt Generate(
int digit4 = digitvalues % radix;
count += 4;
int bits = rand.GetInt32(16);
- _ = (bits & 0x01) == 0 ? builder.Append(ValueDigits[digit]) :
+ builder = (bits & 0x01) == 0 ? builder.Append(ValueDigits[digit]) :
builder.Append(ValueDigitsLower[digit]);
- _ = (bits & 0x02) == 0 ? builder.Append(ValueDigits[digit2]) :
+ builder = (bits & 0x02) == 0 ? builder.Append(ValueDigits[digit2]) :
builder.Append(ValueDigitsLower[digit2]);
- _ = (bits & 0x04) == 0 ? builder.Append(ValueDigits[digit3]) :
+ builder = (bits & 0x04) == 0 ? builder.Append(ValueDigits[digit3]) :
builder.Append(ValueDigitsLower[digit3]);
- _ = (bits & 0x08) == 0 ? builder.Append(ValueDigits[digit4]) :
+ builder = (bits & 0x08) == 0 ? builder.Append(ValueDigits[digit4]) :
builder.Append(ValueDigitsLower[digit4]);
int digits = (((((digit * radix) + digit2) *
radix) + digit3) * radix) + digit4;
@@ -70,7 +74,7 @@ public static StringAndBigInt Generate(
}
for (int i = count; i < numDigits; ++i) {
int digit = rand.GetInt32(radix);
- _ = rand.GetInt32(2) == 0 ? builder.Append(ValueDigits[digit]) :
+ builder = rand.GetInt32(2) == 0 ? builder.Append(ValueDigits[digit]) :
builder.Append(ValueDigitsLower[digit]);
bv *= radixpow1;
var bigintTmp = (EInteger)digit;
@@ -79,9 +83,7 @@ public static StringAndBigInt Generate(
if (negative) {
bv = -bv;
}
- sabi.BigIntValue = bv;
- sabi.StringValue = builder.ToString();
- return sabi;
+ return new StringAndBigInt(builder.ToString(), bv);
}
}
}
diff --git a/CBORTest/TestCommon.cs b/CBORTest/TestCommon.cs
index baa84c84..a56777b0 100644
--- a/CBORTest/TestCommon.cs
+++ b/CBORTest/TestCommon.cs
@@ -40,7 +40,7 @@ public static int StringToInt(string str) {
if (ret == 2147483640) {
if (neg && x == 8) {
return i != str.Length ? throw new FormatException() :
-int.MinValue;
+Int32.MinValue;
}
if (x > 7) {
throw new FormatException();
@@ -80,7 +80,7 @@ public static long StringToLong(string str) {
if (ret == 9223372036854775800L) {
if (neg && x == 8) {
return i != str.Length ? throw new FormatException() :
-long.MinValue;
+Int64.MinValue;
}
if (x > 7) {
throw new FormatException();
@@ -488,7 +488,7 @@ public static string IntToString(int value) {
if (value == 0) {
return "0";
}
- if (value == int.MinValue) {
+ if (value == Int32.MinValue) {
return "-2147483648";
}
bool neg = value < 0;
@@ -547,7 +547,7 @@ public static string IntToString(int value) {
}
public static string LongToString(long longValue) {
- if (longValue == long.MinValue) {
+ if (longValue == Int64.MinValue) {
return "-9223372036854775808";
}
if (longValue == 0L) {
@@ -692,10 +692,12 @@ public static string ToByteArrayString(
if (i > 0) {
_ = sb.Append(',');
}
- _ = (bytes[offset + i] & 0x80) != 0 ? sb.Append("(byte)0x") :
-sb.Append("0x");
- _ = sb.Append(ValueHex[(bytes[offset + i] >> 4) & 0xf]);
- _ = sb.Append(ValueHex[bytes[offset + i] & 0xf]);
+ if ((bytes[offset + i] & 0x80) != 0) {
+ sb.Append("(byte)");
+ }
+ sb.Append("0x");
+ sb.Append(ValueHex[(bytes[offset + i] >> 4) & 0xf]);
+ sb.Append(ValueHex[bytes[offset + i] & 0xf]);
}
_ = sb.Append('}');
return sb.ToString();
diff --git a/CBORTest/ToObjectTest.cs b/CBORTest/ToObjectTest.cs
index 2a778afc..7ba1edb5 100644
--- a/CBORTest/ToObjectTest.cs
+++ b/CBORTest/ToObjectTest.cs
@@ -1042,12 +1042,13 @@ public void TestAsSingle() {
ToObjectTest.TestToFromObjectRoundTrip(EDecimal.FromString(
(string)numberinfo["number"].ToObject(typeof(string))));
- var f1 =
-(float)EDecimal.FromString((string)numberinfo["number"].ToObject(
+ float f1, f2;
+ f1 = (float)EDecimal.FromString(
+ (string)numberinfo["number"].ToObject(
typeof(string))).ToSingle();
- object f2 = cbornumber.ToObject(typeof(float));
- if (!f1.Equals(f2)) {
- Assert.Fail();
+ f2 = (float)cbornumber.ToObject(typeof(float));
+ if (!EFloat.FromSingle(f1).Equals(EFloat.FromSingle(f2))) {
+ Assert.Fail("f1="+f1+"\nf2="+f2);
}
}
}
@@ -1629,8 +1630,21 @@ public static CBORObject TestToFromObjectRoundTrip(object obj) {
}
// Tests for DecodeObjectFromBytes
byte[] encdata = cbor.EncodeToBytes();
- object obj3 =
- CBORObject.DecodeFromBytes(encdata).ToObject(obj.GetType());
+ CBORObject cbor2 = null;
+ try {
+ cbor2 = CBORObject.DecodeFromBytes(encdata);
+ } catch (Exception ex) {
+ string failString = String.Empty + encdata.Length;
+ if (encdata.Length < 200) {
+ failString += " ";
+ failString += TestCommon.ToByteArrayString(encdata);
+ }
+ throw new InvalidOperationException(failString, ex);
+ }
+ if (cbor2 == null) {
+ Assert.Fail();
+ }
+ object obj3 = cbor2.ToObject(obj.GetType());
object obj4 = CBORObject.DecodeObjectFromBytes(encdata, obj.GetType());
TestCommon.AssertEqualsHashCode(obj, obj2);
TestCommon.AssertEqualsHashCode(obj, obj3);
diff --git a/docs/APIDocs.md b/docs/APIDocs.md
index ac41af33..0aa5db49 100644
--- a/docs/APIDocs.md
+++ b/docs/APIDocs.md
@@ -29,5 +29,3 @@
* [PeterO.Cbor.JSONOptions.ConversionMode](PeterO.Cbor.JSONOptions.ConversionMode.md) - Specifies how JSON numbers are converted to CBOR objects when decoding JSON (such as via FromJSONString or ReadJSON ).
* [PeterO.Cbor.PODOptions](PeterO.Cbor.PODOptions.md) - Options for controlling how certain DotNET or Java objects, such as so-called "plain old data" objects (better known as POCOs in DotNET or POJOs in Java), are converted to CBOR objects.
-
- * [PeterO.DataUtilities](PeterO.DataUtilities.md) - Contains methods useful for reading and writing text strings.
diff --git a/docs/PeterO.Cbor.CBORDataUtilities.md b/docs/PeterO.Cbor.CBORDataUtilities.md
index 782d482e..ad821e69 100644
--- a/docs/PeterO.Cbor.CBORDataUtilities.md
+++ b/docs/PeterO.Cbor.CBORDataUtilities.md
@@ -24,7 +24,7 @@ Contains methods useful for reading and writing data, with a focus on CBOR.
public static PeterO.Cbor.CBORObject ParseJSONNumber(
byte[] bytes);
-Parses a number from a byte sequence whose format follows the JSON specification. The method uses a JSONOptions with all default properties except for a PreserveNegativeZero property of false.
+Parses a number from a byte sequence whose format follows the JSON specification. The method uses a JSONOptions with all default properties.
Parameters:
@@ -32,7 +32,7 @@ Parses a number from a byte sequence whose format follows the JSON specification
Return Value:
-A CBOR object that represents the parsed number. Returns positive zero if the number is a zero that starts with a minus sign (such as "-0" or "-0.0"). Returns null if the parsing fails, including if the byte sequence is null or empty.
+A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the byte sequence is null or empty.
### ParseJSONNumber
@@ -143,7 +143,7 @@ A CBOR object that represents the parsed number. Returns null if the parsing fai
public static PeterO.Cbor.CBORObject ParseJSONNumber(
char[] chars);
-Parses a number from a sequence of `char` s whose format follows the JSON specification. The method uses a JSONOptions with all default properties except for a PreserveNegativeZero property of false.
+Parses a number from a sequence of `char` s whose format follows the JSON specification. The method uses a JSONOptions with all default properties.
Parameters:
@@ -151,7 +151,7 @@ Parses a number from a sequence of `char` s whose format follows the JSON spec
Return Value:
-A CBOR object that represents the parsed number. Returns positive zero if the number is a zero that starts with a minus sign (such as "-0" or "-0.0"). Returns null if the parsing fails, including if the sequence of `char` s is null or empty.
+A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the sequence of `char` s is null or empty.
### ParseJSONNumber
@@ -262,7 +262,7 @@ A CBOR object that represents the parsed number. Returns null if the parsing fai
public static PeterO.Cbor.CBORObject ParseJSONNumber(
string str);
-Parses a number whose format follows the JSON specification. The method uses a JSONOptions with all default properties except for a PreserveNegativeZero property of false.
+Parses a number whose format follows the JSON specification. The method uses a JSONOptions with all default properties.
Parameters:
@@ -270,7 +270,7 @@ Parses a number whose format follows the JSON specification. The method uses a J
Return Value:
-A CBOR object that represents the parsed number. Returns positive zero if the number is a zero that starts with a minus sign (such as "-0" or "-0.0"). Returns null if the parsing fails, including if the string is null or empty.
+A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the string is null or empty.
### ParseJSONNumber
diff --git a/docs/PeterO.Cbor.CBORDateConverter.md b/docs/PeterO.Cbor.CBORDateConverter.md
index b9dd76a9..8d4fd9d9 100644
--- a/docs/PeterO.Cbor.CBORDateConverter.md
+++ b/docs/PeterO.Cbor.CBORDateConverter.md
@@ -298,10 +298,3 @@ Tries to extract the fields of a date and time in the form of a CBOR object.
Return Value:
Either `true` if the method is successful, or `false` otherwise.
-
-Exceptions:
-
- * System.ArgumentNullException:
-The parameter year
- or lesserFields
- is null, or contains fewer elements than required.
diff --git a/docs/PeterO.Cbor.CBORNumber.md b/docs/PeterO.Cbor.CBORNumber.md
index d348398f..68a8120f 100644
--- a/docs/PeterO.Cbor.CBORNumber.md
+++ b/docs/PeterO.Cbor.CBORNumber.md
@@ -45,6 +45,7 @@ An instance of a number that CBOR or certain CBOR tags can represent. For this p
* [ToByteIfExact()](#ToByteIfExact)
- Converts this number's value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) without rounding to a different numerical value.
* [ToByteUnchecked()](#ToByteUnchecked)
- Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a byte (from 0 to 255).
* [ToCBORObject()](#ToCBORObject)
- Converts this object's value to a CBOR object.
+* [ToDecimal()](#ToDecimal)
- Converts this number's value to a CLR decimal.
* [ToEDecimal()](#ToEDecimal)
- Converts this object to a decimal number.
* [ToEFloat()](#ToEFloat)
- Converts this object to an arbitrary-precision binary floating point number.
* [ToEInteger()](#ToEInteger)
- Converts this object to an arbitrary-precision integer.
@@ -677,6 +678,22 @@ Converts this object's value to a CBOR object.
A CBOR object that stores this object's value.
+
+### ToDecimal
+
+ public decimal ToDecimal();
+
+Converts this number's value to a CLR decimal.
+
+Return Value:
+
+This number's value, converted to a decimal as though by `(decimal)this.ToEDecimal()` .
+
+Exceptions:
+
+ * System.OverflowException:
+This value is infinity or not-a-number.
+
### ToEDecimal
diff --git a/docs/PeterO.Cbor.CBORObject.md b/docs/PeterO.Cbor.CBORObject.md
index e373a9ea..326bbd1d 100644
--- a/docs/PeterO.Cbor.CBORObject.md
+++ b/docs/PeterO.Cbor.CBORObject.md
@@ -48,7 +48,6 @@ The ReadJSON and FromJSONString methods currently have nesting depths of 1000.
* [Add(PeterO.Cbor.CBORObject)](#Add_PeterO_Cbor_CBORObject)
- Adds a new object to the end of this array.
* [ApplyJSONPatch(PeterO.Cbor.CBORObject)](#ApplyJSONPatch_PeterO_Cbor_CBORObject)
- Returns a copy of this object after applying the operations in a JSON patch, in the form of a CBOR object.
* [AsBoolean()](#AsBoolean)
- Returns false if this object is a CBOR false, null, or undefined value (whether or not the object has tags); otherwise, true.
-* [AsDecimal()](#AsDecimal)
- Deprecated: Instead, use .ToObject<decimal>().
* [AsDouble()](#AsDouble)
- Converts this object to a 64-bit floating point number.
* [AsDoubleBits()](#AsDoubleBits)
- Converts this object to the bits of a 64-bit floating-point number if this CBOR object's type is FloatingPoint.
* [AsDoubleValue()](#AsDoubleValue)
- Converts this object to a 64-bit floating-point number if this CBOR object's type is FloatingPoint.
@@ -57,12 +56,8 @@ The ReadJSON and FromJSONString methods currently have nesting depths of 1000.
* [AsInt32Value()](#AsInt32Value)
- Converts this object to a 32-bit signed integer if this CBOR object's type is Integer.
* [AsInt64Value()](#AsInt64Value)
- Converts this object to a 64-bit signed integer if this CBOR object's type is Integer.
* [AsNumber()](#AsNumber)
- Converts this object to a CBOR number.
-* [AsSByte()](#AsSByte)
- Deprecated: Instead, use the following: (cbor.AsNumber().ToSByteChecked()), or .ToObject<sbyte>().
* [AsSingle()](#AsSingle)
- Converts this object to a 32-bit floating point number.
* [AsString()](#AsString)
- Gets the value of this object as a text string.
-* [AsUInt16()](#AsUInt16)
- Deprecated: Instead, use the following: (cbor.AsNumber().ToUInt16Checked()), or .ToObject<ushort>().
-* [AsUInt32()](#AsUInt32)
- Deprecated: Instead, use the following: (cbor.AsNumber().ToUInt32Checked()), or .ToObject<uint>().
-* [AsUInt64()](#AsUInt64)
- Deprecated: Instead, use the following: (cbor.AsNumber().ToUInt64Checked()), or .ToObject<ulong>().
* [AtJSONPointer(string)](#AtJSONPointer_string)
- Gets the CBOR object referred to by a JSON Pointer according to RFC6901.
* [AtJSONPointer(string, PeterO.Cbor.CBORObject)](#AtJSONPointer_string_PeterO_Cbor_CBORObject)
- Gets the CBOR object referred to by a JSON Pointer according to RFC6901, or a default value if the operation fails.
* [CalcEncodedSize()](#CalcEncodedSize)
- Calculates the number of bytes this CBOR object takes when serialized as a byte array using the EncodeToBytes() method.
@@ -642,27 +637,6 @@ Returns false if this object is a CBOR false, null, or undefined value (whether
False if this object is a CBOR false, null, or undefined value; otherwise, true.
-
-### AsDecimal
-
- public decimal AsDecimal();
-
-Deprecated. Instead, use .ToObject<decimal>().
-
-Converts this object to a DotNet decimal.
-
-Return Value:
-
-The closest big integer to this object.
-
-Exceptions:
-
- * System.InvalidOperationException:
-This object does not represent a number (for this purpose, infinities and not-a-number or NaN values, but not CBORObject.Null, are considered numbers).
-
- * System.OverflowException:
-This object's value exceeds the range of a DotNet decimal.
-
### AsDouble
@@ -829,21 +803,6 @@ The number represented by this object.
* System.InvalidOperationException:
This object does not represent a number (for this purpose, infinities and not-a-number or NaN values, but not CBORObject.Null, are considered numbers).
-
-### AsSByte
-
- public sbyte AsSByte();
-
-Deprecated. Instead, use the following: (cbor.AsNumber().ToSByteChecked()), or .ToObject<sbyte>().
-
-This API is not CLS-compliant.
-
-Converts this object to an 8-bit signed integer.
-
-Return Value:
-
-An 8-bit signed integer.
-
### AsSingle
@@ -879,75 +838,6 @@ Gets this object's string.
This object's type is not a text string (for the purposes of this method, infinity and not-a-number values, but not `CBORObject.Null` , are considered numbers). To check the CBOR object for null before conversion, use the following idiom (originally written in C# for the.NET version): `(cbor == null || cbor.IsNull) ? null :
cbor.AsString()` .
-
-### AsUInt16
-
- public ushort AsUInt16();
-
-Deprecated. Instead, use the following: (cbor.AsNumber().ToUInt16Checked()), or .ToObject<ushort>().
-
-This API is not CLS-compliant.
-
-Converts this object to a 16-bit unsigned integer after discarding any fractional part, if any, from its value.
-
-Return Value:
-
-A 16-bit unsigned integer.
-
-Exceptions:
-
- * System.InvalidOperationException:
-This object does not represent a number (for this purpose, infinities and not-a-number or NaN values, but not CBORObject.Null, are considered numbers).
-
- * System.OverflowException:
-This object's value, if converted to an integer by discarding its fractional part, is outside the range of a 16-bit unsigned integer.
-
-
-### AsUInt32
-
- public uint AsUInt32();
-
-Deprecated. Instead, use the following: (cbor.AsNumber().ToUInt32Checked()), or .ToObject<uint>().
-
-This API is not CLS-compliant.
-
-Converts this object to a 32-bit unsigned integer after discarding any fractional part, if any, from its value.
-
-Return Value:
-
-A 32-bit unsigned integer.
-
-Exceptions:
-
- * System.InvalidOperationException:
-This object does not represent a number (for this purpose, infinities and not-a-number or NaN values, but not CBORObject.Null, are considered numbers).
-
- * System.OverflowException:
-This object's value, if converted to an integer by discarding its fractional part, is outside the range of a 32-bit unsigned integer.
-
-
-### AsUInt64
-
- public ulong AsUInt64();
-
-Deprecated. Instead, use the following: (cbor.AsNumber().ToUInt64Checked()), or .ToObject<ulong>().
-
-This API is not CLS-compliant.
-
-Converts this object to a 64-bit unsigned integer after discarding any fractional part, if any, from its value.
-
-Return Value:
-
-A 64-bit unsigned integer.
-
-Exceptions:
-
- * System.InvalidOperationException:
-This object does not represent a number (for this purpose, infinities and not-a-number or NaN values, but not CBORObject.Null, are considered numbers).
-
- * System.OverflowException:
-This object's value, if converted to an integer by discarding its fractional part, is outside the range of a 64-bit unsigned integer.
-
### AtJSONPointer