Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.

Commit 83bcbe0

Browse files
committed
Adds TypeForwardedFrom attributes to serializable CoreLib types and makes the internal ones public so that we can build the mscorlib facade in corefx for them. Fixes hundreds of serialization tests.
[tfs-changeset: 1661754]
1 parent 5a706a2 commit 83bcbe0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+633
-14
lines changed

src/System.Private.CoreLib/shared/System/StringComparer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public int GetHashCode(object obj)
172172

173173
[Serializable]
174174
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
175-
internal sealed class CultureAwareComparer : StringComparer
175+
public sealed class CultureAwareComparer : StringComparer
176176
{
177177
private readonly CompareInfo _compareInfo; // Do not rename (binary serialization)
178178
private readonly bool _ignoreCase; // Do not rename (binary serialization)
@@ -228,7 +228,7 @@ public override int GetHashCode()
228228

229229
[Serializable]
230230
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
231-
internal sealed class OrdinalComparer : StringComparer
231+
public sealed class OrdinalComparer : StringComparer
232232
{
233233
public override int Compare(string x, string y) => string.CompareOrdinal(x, y);
234234

@@ -254,7 +254,7 @@ public override int GetHashCode(string obj)
254254

255255
[Serializable]
256256
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
257-
internal sealed class OrdinalIgnoreCaseComparer : StringComparer
257+
public sealed class OrdinalIgnoreCaseComparer : StringComparer
258258
{
259259
public override int Compare(string x, string y) => string.Compare(x, y, StringComparison.OrdinalIgnoreCase);
260260

src/System.Private.CoreLib/src/Internal/IntrinsicSupport/ComparerHelpers.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ namespace System.Collections.Generic
156156
// Because these are serializable, they must not be renamed
157157
//-----------------------------------------------------------------------
158158
[Serializable]
159-
internal sealed class GenericComparer<T> : Comparer<T> where T : IComparable<T>
159+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
160+
public sealed class GenericComparer<T> : Comparer<T> where T : IComparable<T>
160161
{
161162
public sealed override int Compare(T x, T y)
162163
{
@@ -181,7 +182,8 @@ public sealed override int Compare(T x, T y)
181182
}
182183

183184
[Serializable]
184-
internal sealed class NullableComparer<T> : Comparer<Nullable<T>> where T : struct, IComparable<T>
185+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
186+
public sealed class NullableComparer<T> : Comparer<Nullable<T>> where T : struct, IComparable<T>
185187
{
186188
public sealed override int Compare(Nullable<T> x, Nullable<T> y)
187189
{
@@ -206,7 +208,8 @@ public sealed override int Compare(Nullable<T> x, Nullable<T> y)
206208
}
207209

208210
[Serializable]
209-
internal sealed class ObjectComparer<T> : Comparer<T>
211+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
212+
public sealed class ObjectComparer<T> : Comparer<T>
210213
{
211214
public sealed override int Compare(T x, T y)
212215
{

src/System.Private.CoreLib/src/Internal/IntrinsicSupport/EqualityComparerHelpers.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ namespace System.Collections.Generic
180180
// The methods in this class look identical to the inherited methods, but the calls
181181
// to Equal bind to IEquatable<T>.Equals(T) instead of Object.Equals(Object)
182182
[Serializable]
183-
internal sealed class GenericEqualityComparer<T> : EqualityComparer<T> where T : IEquatable<T>
183+
public sealed class GenericEqualityComparer<T> : EqualityComparer<T> where T : IEquatable<T>
184184
{
185185
public sealed override bool Equals(T x, T y)
186186
{
@@ -212,7 +212,8 @@ public sealed override int GetHashCode(T obj)
212212
}
213213

214214
[Serializable]
215-
internal sealed class NullableEqualityComparer<T> : EqualityComparer<Nullable<T>> where T : struct, IEquatable<T>
215+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
216+
public sealed class NullableEqualityComparer<T> : EqualityComparer<Nullable<T>> where T : struct, IEquatable<T>
216217
{
217218
public sealed override bool Equals(Nullable<T> x, Nullable<T> y)
218219
{
@@ -242,7 +243,8 @@ public sealed override int GetHashCode(Nullable<T> obj)
242243
}
243244

244245
[Serializable]
245-
public sealed class EnumEqualityComparer<T> : EqualityComparer<T>, ISerializable where T : struct
246+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
247+
public class EnumEqualityComparer<T> : EqualityComparer<T>, ISerializable where T : struct
246248
{
247249
public sealed override bool Equals(T x, T y)
248250
{
@@ -268,13 +270,14 @@ public void GetObjectData(SerializationInfo info, StreamingContext context)
268270
}
269271

270272
// Equals method for the comparer itself.
271-
public sealed override bool Equals(Object obj) => obj is EnumEqualityComparer<T>;
273+
public override bool Equals(Object obj) => obj is EnumEqualityComparer<T>;
272274

273-
public sealed override int GetHashCode() => typeof(EnumEqualityComparer<T>).GetHashCode();
275+
public override int GetHashCode() => typeof(EnumEqualityComparer<T>).GetHashCode();
274276
}
275277

276278
[Serializable]
277-
internal sealed class ObjectEqualityComparer<T> : EqualityComparer<T>
279+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
280+
public sealed class ObjectEqualityComparer<T> : EqualityComparer<T>
278281
{
279282
public sealed override bool Equals(T x, T y)
280283
{

src/System.Private.CoreLib/src/System.Private.CoreLib.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
44
<PropertyGroup>
@@ -189,6 +189,7 @@
189189
<Compile Include="System\Collections\Concurrent\LowLevelConcurrentQueue.cs" />
190190
<Compile Include="System\Collections\Generic\ArraySortHelper.cs" />
191191
<Compile Include="System\Collections\Generic\Comparer.cs" />
192+
<Compile Include="System\Collections\Generic\CompatibilityEqualityComparers.cs" />
192193
<Compile Include="System\Collections\Generic\DebugView.cs" />
193194
<Compile Include="System\Collections\Generic\EqualityComparer.cs" />
194195
<Compile Include="System\Collections\Generic\EqualOnlyComparer.cs" />
@@ -197,6 +198,7 @@
197198
<Compile Include="System\Collections\Generic\Dictionary.cs" />
198199
<Compile Include="System\Collections\Generic\IDictionaryDebugView.cs" />
199200
<Compile Include="System\Collections\Generic\NonRandomizedStringEqualityComparer.cs" />
201+
<Compile Include="System\Collections\ListDictionaryInternal.cs" />
200202
<Compile Include="System\Collections\LowLevelListDictionary.cs" />
201203
<Compile Include="System\Collections\LowLevelComparer.cs" />
202204
<Compile Include="System\Collections\ObjectEqualityComparer.cs" />

src/System.Private.CoreLib/src/System/AggregateException.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace System
2828
/// </remarks>
2929
[Serializable]
3030
[DebuggerDisplay("Count = {InnerExceptionCount}")]
31+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
3132
public class AggregateException : Exception
3233
{
3334
private ReadOnlyCollection<Exception> _innerExceptions; // Complete set of exceptions.

src/System.Private.CoreLib/src/System/Array.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace System
1616
{
1717
[Serializable]
18+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
1819
public abstract partial class Array : ICollection, IEnumerable, IList, IStructuralComparable, IStructuralEquatable, ICloneable
1920
{
2021
public static Array CreateInstance(Type elementType, params long[] lengths)

src/System.Private.CoreLib/src/System/ArraySegment.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace System
2626
// three fields from an ArraySegment may not see the same ArraySegment from one call to another
2727
// (ie, users could assign a new value to the old location).
2828
[Serializable]
29+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
2930
public struct ArraySegment<T> : IList<T>, IReadOnlyList<T>
3031
{
3132
// Do not replace the array allocation with Array.Empty. We don't want to have the overhead of

src/System.Private.CoreLib/src/System/Attribute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace System
88
{
99
[AttributeUsageAttribute(AttributeTargets.All, Inherited = true, AllowMultiple = false)]
1010
[Serializable]
11+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
1112
public abstract partial class Attribute
1213
{
1314
protected Attribute() { }

src/System.Private.CoreLib/src/System/Boolean.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace System
2121
// The Boolean class provides the
2222
// object representation of the boolean primitive type.
2323
[Serializable]
24+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
2425
public struct Boolean : IComparable, IComparable<Boolean>, IEquatable<Boolean>, IConvertible
2526
{
2627
//

src/System.Private.CoreLib/src/System/Byte.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace System
2424
//
2525
[System.Runtime.InteropServices.StructLayout(LayoutKind.Sequential)]
2626
[Serializable]
27+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
2728
public struct Byte : IComparable, IFormattable, IComparable<Byte>, IEquatable<Byte>, IConvertible
2829
{
2930
private byte m_value; // Do not rename (binary serialization)

0 commit comments

Comments
 (0)