Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Update the code for DateTimeFormatInfo to not use BinaryCompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGhiondea committed Nov 30, 2016
1 parent 2994491 commit 9d0b9b2
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions src/mscorlib/src/System/Globalization/DateTimeFormatInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2877,35 +2877,13 @@ void InsertHash(TokenHashValue[] hashTable, String str, TokenType tokenType, int
int nTokenType = (int)tokenType;
int nCurrentTokenTypeInHash = (int)value.tokenType;

// The idea behind this check is:
// - if the app is targetting 4.5.1 or above OR the compat flag is set, use the correct behavior by default.
// - if the app is targetting 4.5 or below AND the compat switch is set, use the correct behavior
// - if the app is targetting 4.5 or below AND the compat switch is NOT set, use the incorrect behavior
if (preferExistingTokens)
if (((nCurrentTokenTypeInHash & (int)TokenType.RegularTokenMask) == 0) && ((nTokenType & (int)TokenType.RegularTokenMask) != 0) ||
((nCurrentTokenTypeInHash & (int)TokenType.SeparatorTokenMask) == 0) && ((nTokenType & (int)TokenType.SeparatorTokenMask) != 0))
{
if (((nCurrentTokenTypeInHash & (int)TokenType.RegularTokenMask) == 0) && ((nTokenType & (int)TokenType.RegularTokenMask) != 0) ||
((nCurrentTokenTypeInHash & (int)TokenType.SeparatorTokenMask) == 0) && ((nTokenType & (int)TokenType.SeparatorTokenMask) != 0))
value.tokenType |= tokenType;
if (tokenValue != 0)
{
value.tokenType |= tokenType;
if (tokenValue != 0)
{
value.tokenValue = tokenValue;
}
}
}
else
{
// The following logic is incorrect and causes updates to happen depending on the bitwise relationship between the existing token type and the
// the stored token type. It was this way in .NET 4 RTM. The behavior above is correct and will be adopted going forward.

if ((((nTokenType | nCurrentTokenTypeInHash) & (int)TokenType.RegularTokenMask) == nTokenType) ||
(((nTokenType | nCurrentTokenTypeInHash) & (int)TokenType.SeparatorTokenMask) == nTokenType))
{
value.tokenType |= tokenType;
if (tokenValue != 0)
{
value.tokenValue = tokenValue;
}
value.tokenValue = tokenValue;
}
}
// The token to be inserted is already in the table. Skip it.
Expand Down

0 comments on commit 9d0b9b2

Please sign in to comment.