<Compile Include="$(BclSourcesRoot)\System\Threading\ClrThreadPoolPreAllocatedOverlapped.cs" />
</ItemGroup>
<ItemGroup>
- <Compile Include="$(BclSourcesRoot)\System\IO\BinaryReader.cs" />
<Compile Include="$(BclSourcesRoot)\System\IO\FileLoadException.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\IO\FileNotFoundException.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\IO\Stream.CoreCLR.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\InvalidOperationException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\InvalidProgramException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\InvalidTimeZoneException.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\IO\BinaryReader.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\BinaryWriter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\DirectoryNotFoundException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\EncodingCache.cs" />
**
============================================================*/
-using System;
-using System.Runtime;
+using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
-using System.Globalization;
-using System.Diagnostics;
-using System.Security;
namespace System.IO
{
Debug.Assert(charsRead < 2, "BinaryReader::ReadOneChar - assuming we only got 0 or 1 char, not 2!");
}
- if (charsRead == 0)
- return -1;
+ Debug.Assert(charsRead > 0);
return _singleChar[0];
}
// do ~1+log(n) reads to read n characters.
numBytes = charsRemaining;
- // special case for DecoderNLS subclasses when there is a hanging byte from the previous loop
- DecoderNLS decoder = _decoder as DecoderNLS;
- if (decoder != null && decoder.HasState && numBytes > 1)
- {
- numBytes -= 1;
- }
-
if (_2BytesPerChar)
+ {
numBytes <<= 1;
+ }
if (numBytes > MaxCharBytesSize)
{
numBytes = MaxCharBytesSize;
//
public Decimal(int value)
{
- // JIT today can't inline methods that contains "starg" opcode.
- // For more details, see DevDiv Bugs 81184: x86 JIT CQ: Removing the inline striction of "starg".
- int value_copy = value;
- if (value_copy >= 0)
+ if (value >= 0)
{
flags = 0;
}
else
{
flags = SignMask;
- value_copy = -value_copy;
+ value = -value;
}
- lo = value_copy;
+ lo = value;
mid = 0;
hi = 0;
}
//
public Decimal(long value)
{
- // JIT today can't inline methods that contains "starg" opcode.
- // For more details, see DevDiv Bugs 81184: x86 JIT CQ: Removing the inline striction of "starg".
- long value_copy = value;
- if (value_copy >= 0)
+ if (value >= 0)
{
flags = 0;
}
else
{
flags = SignMask;
- value_copy = -value_copy;
+ value = -value;
}
- lo = (int)value_copy;
- mid = (int)(value_copy >> 32);
+ lo = (int)value;
+ mid = (int)(value >> 32);
hi = 0;
}
//
public Decimal(int[] bits)
{
- lo = 0;
- mid = 0;
- hi = 0;
- flags = 0;
- SetBits(bits);
- }
-
- private void SetBits(int[] bits)
- {
if (bits == null)
throw new ArgumentNullException(nameof(bits));
if (bits.Length == 4)
// OnSerializing is called before serialization of an object
try
{
- SetBits(GetBits(this));
+ // Run the constructor to validate the decimal
+ new decimal(lo, mid, hi, flags);
}
catch (ArgumentException e)
{
// This callback method performs decimal validation after being deserialized.
try
{
- SetBits(GetBits(this));
+ // Run the constructor to validate the decimal
+ new decimal(lo, mid, hi, flags);
}
catch (ArgumentException e)
{