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

Remove the BinaryCompatibility class as it is not useful on .NET Core… #8396

Merged
merged 3 commits into from
Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/mscorlib/mscorlib.shared.sources.props
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,6 @@
<SerializationSources Include="$(BclSourcesRoot)\System\Runtime\Serialization\SafeSerializationManager.cs" />
</ItemGroup>
<ItemGroup>
<VersioningSources Include="$(BclSourcesRoot)\System\Runtime\Versioning\BinaryCompatibility.cs" />
<VersioningSources Include="$(BclSourcesRoot)\System\Runtime\Versioning\TargetFrameworkAttribute.cs" />
<VersioningSources Include="$(BclSourcesRoot)\System\Runtime\Versioning\TargetFrameworkId.cs" />
<VersioningSources Include="$(BclSourcesRoot)\System\Runtime\Versioning\CompatibilitySwitch.cs" />
Expand Down
11 changes: 1 addition & 10 deletions src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,7 @@ internal static int FloorLog2(int n)
}

internal static void ThrowOrIgnoreBadComparer(Object comparer) {
// This is hit when an invarant of QuickSort is violated due to a bad IComparer implementation (for
// example, imagine an IComparer that returns 0 when items are equal but -1 all other times).
//
// We could have thrown this exception on v4, but due to changes in v4.5 around how we partition arrays
// there are different sets of input where we would throw this exception. In order to reduce overall risk from
// an app compat persective, we're changing to never throw on v4. Instead, we'll return with a partially
// sorted array.
if(BinaryCompatibility.TargetsAtLeast_Desktop_V4_5) {
throw new ArgumentException(Environment.GetResourceString("Arg_BogusIComparer", comparer));
}
throw new ArgumentException(Environment.GetResourceString("Arg_BogusIComparer", comparer));
}

}
Expand Down
4 changes: 2 additions & 2 deletions src/mscorlib/src/System/Collections/Generic/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,13 @@ public void ForEach(Action<T> action) {
int version = _version;

for(int i = 0 ; i < _size; i++) {
if (version != _version && BinaryCompatibility.TargetsAtLeast_Desktop_V4_5) {
if (version != _version) {
break;
}
action(_items[i]);
}

if (version != _version && BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
if (version != _version)
ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion();
}

Expand Down
44 changes: 5 additions & 39 deletions src/mscorlib/src/System/Globalization/DateTimeFormatInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,6 @@ public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider
// genitive form or leap year month names.
[OptionalField(VersionAdded = 2)]
internal DateTimeFormatFlags formatFlags = DateTimeFormatFlags.NotInitialized;
internal static bool preferExistingTokens = InitPreferExistingTokens();


[System.Security.SecuritySafeCritical]
static bool InitPreferExistingTokens()
{
bool ret = false;
#if !FEATURE_CORECLR
ret = DateTime.LegacyParseMode();
#endif
return ret;
}

private String CultureName
{
Expand Down Expand Up @@ -2877,35 +2865,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 || BinaryCompatibility.TargetsAtLeast_Desktop_V4_5_1)
{
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.tokenValue = tokenValue;
}
}
}
else
if (((nCurrentTokenTypeInHash & (int)TokenType.RegularTokenMask) == 0) && ((nTokenType & (int)TokenType.RegularTokenMask) != 0) ||
((nCurrentTokenTypeInHash & (int)TokenType.SeparatorTokenMask) == 0) && ((nTokenType & (int)TokenType.SeparatorTokenMask) != 0))
{
// 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.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
Loading