Skip to content

Commit

Permalink
Merge pull request dotnet#35319 from krwq/nullable-xml-1
Browse files Browse the repository at this point in the history
Nullable: System.Xml, part 1
  • Loading branch information
krwq authored Apr 27, 2020
2 parents 5bde93a + 916c23a commit 919925a
Show file tree
Hide file tree
Showing 41 changed files with 937 additions and 500 deletions.
1 change: 1 addition & 0 deletions src/libraries/System.Private.Xml/src/Misc/HResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable
/*
These HRESULTs are used for mapping managed exceptions to COM error codes
and vice versa through COM Interop. For background on COM error codes see
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable
using System;
using System.Collections;
using System.IO;
Expand Down Expand Up @@ -81,4 +82,4 @@ internal enum BinXmlToken
XSD_UNSIGNEDLONG = 0x8B,
XSD_QNAME = 0x8C,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable
using System;
using System.Collections;
using System.IO;
Expand Down Expand Up @@ -46,7 +47,7 @@ public BinXmlSqlDecimal(byte[] data, int offset, bool trim)
11 => 2,
15 => 3,
19 => 4,
_ => throw new XmlException(SR.XmlBinary_InvalidSqlDecimal, (string[])null),
_ => throw new XmlException(SR.XmlBinary_InvalidSqlDecimal, (string[]?)null),
};
m_bPrec = data[offset + 1];
m_bScale = data[offset + 2];
Expand Down Expand Up @@ -109,6 +110,7 @@ out uint iulR // Out | R
iulR = ulCarry;
MpNormalize(rgulU, ref ciulU);
}

// Normalize multi-precision number - remove leading zeroes
private static void MpNormalize(uint[] rgulU, // In | Number
ref int ciulU // InOut| # of digits
Expand All @@ -131,6 +133,7 @@ ref int ciulU // InOut| # of digits
private static ReadOnlySpan<byte> RgCLenFromPrec => new byte[] { // rely on C# compiler optimization to eliminate allocation
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
};

private static byte CLenFromPrec(byte bPrec)
{
Debug.Assert(bPrec <= s_maxPrecision && bPrec > 0, "bPrec <= MaxPrecision && bPrec > 0", "Invalid numeric precision");
Expand All @@ -146,7 +149,7 @@ private static char ChFromDigit(uint uiDigit)
public decimal ToDecimal()
{
if ((int)m_data4 != 0 || m_bScale > 28)
throw new XmlException(SR.SqlTypes_ArithOverflow, (string)null);
throw new XmlException(SR.SqlTypes_ArithOverflow, (string?)null);

return new decimal((int)m_data1, (int)m_data2, (int)m_data3, !IsPositive, m_bScale);
}
Expand Down Expand Up @@ -452,7 +455,7 @@ private static void BreakDownXsdDateTime(long val, out int yr, out int mnth, out
goto Error;
return;
Error:
throw new XmlException(SR.SqlTypes_ArithOverflow, (string)null);
throw new XmlException(SR.SqlTypes_ArithOverflow, (string?)null);
}

private static void BreakDownXsdDate(long val, out int yr, out int mnth, out int day, out bool negTimeZone, out int hr, out int min)
Expand All @@ -477,7 +480,7 @@ private static void BreakDownXsdDate(long val, out int yr, out int mnth, out int
goto Error;
return;
Error:
throw new XmlException(SR.SqlTypes_ArithOverflow, (string)null);
throw new XmlException(SR.SqlTypes_ArithOverflow, (string?)null);
}

private static void BreakDownXsdTime(long val, out int hr, out int min, out int sec, out int ms)
Expand All @@ -495,7 +498,7 @@ private static void BreakDownXsdTime(long val, out int hr, out int min, out int
goto Error;
return;
Error:
throw new XmlException(SR.SqlTypes_ArithOverflow, (string)null);
throw new XmlException(SR.SqlTypes_ArithOverflow, (string?)null);
}

public static string XsdDateTimeToString(long val)
Expand Down Expand Up @@ -765,7 +768,7 @@ private static long GetKatmaiTimeTicks(byte[] data, ref int pos)
}
else
{
throw new XmlException(SR.SqlTypes_ArithOverflow, (string)null);
throw new XmlException(SR.SqlTypes_ArithOverflow, (string?)null);
}
return timeTicks * KatmaiTimeScaleMultiplicator[scale];
}
Expand Down
Loading

0 comments on commit 919925a

Please sign in to comment.