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

Commit 4b95b41

Browse files
authored
Cleanup InternalsVisibleTo (#17185)
Remove InternalsVisibleTo for mscorlib and make sure that corefx still builds with it. Delete global constants that were left-overs from .NET Framework build system.
1 parent f56f7a5 commit 4b95b41

File tree

16 files changed

+36
-93
lines changed

16 files changed

+36
-93
lines changed

dependencies.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<CurrentRefXmlPath>$(MSBuildThisFileFullPath)</CurrentRefXmlPath>
6262
</PropertyGroup>
6363

64-
<!-- ILLinik.Tasks package version -->
64+
<!-- ILLink.Tasks package version -->
6565
<PropertyGroup>
6666
<ILLinkTasksPackage>ILLink.Tasks</ILLinkTasksPackage>
6767
<ILLinkTasksPackageVersion>0.1.5-preview-1461378</ILLinkTasksPackageVersion>

src/mscorlib/Common/Preprocessed/AssemblyRefs.g.cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/mscorlib/ILLinkTrim.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@
1919
<!-- Methods is used by VS Tasks Window. -->
2020
<method name="GetActiveTaskFromId" />
2121
</type>
22+
<!-- Accessed via private reflection by tracing controller. -->
23+
<type fullname="System.Diagnostics.Tracing.EventPipe*" />
2224
</assembly>
2325
</linker>

src/mscorlib/System.Private.CoreLib.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,11 @@
624624
</ItemGroup>
625625
<!-- Include additional sources shared files in the compilation -->
626626
<ItemGroup>
627-
<!-- These are files are preprocessed -->
628-
<Compile Include="$(CommonPath)\Preprocessed\AssemblyRefs.g.cs" />
629627
<!-- These files are shared with other framework components and don't live the same folder as the rest of them-->
630628
<Compile Include="$(CommonPath)\NotImplemented.cs" />
631629
<Compile Include="$(CommonPath)\System\SR.cs" />
632630
<!-- Include Internals visible to file in the compilation -->
633-
<Compile Include="$(BclSourcesRoot)\mscorlib.Friends.cs" />
631+
<Compile Include="$(BclSourcesRoot)\mscorlib.Friends.cs" Condition="'$(FeatureCominterop)' == 'true'" />
634632
</ItemGroup>
635633
<ItemGroup>
636634
<Compile Include="src\System\Runtime\RuntimeImports.cs" />

src/mscorlib/shared/System/Collections/Generic/NonRandomizedStringEqualityComparer.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ namespace System.Collections.Generic
1111
// keeps the performance not affected till we hit collision threshold and then we switch to the comparer which is using
1212
// randomized string hashing.
1313
[Serializable] // Required for compatibility with .NET Core 2.0 as we exposed the NonRandomizedStringEqualityComparer inside the serialization blob
14-
#if CORERT
15-
public
16-
#else
17-
internal
18-
#endif
19-
sealed class NonRandomizedStringEqualityComparer : EqualityComparer<string>, ISerializable
14+
// Needs to be public to support binary serialization compatibility
15+
public sealed class NonRandomizedStringEqualityComparer : EqualityComparer<string>, ISerializable
2016
{
2117
internal static new IEqualityComparer<string> Default { get; } = new NonRandomizedStringEqualityComparer();
2218

src/mscorlib/shared/System/Collections/ListDictionaryInternal.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ namespace System.Collections
2020
/// This should not be used if performance is important for large numbers of elements.
2121
[Serializable]
2222
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
23-
#if CORERT
24-
public
25-
#else
26-
internal
27-
#endif
28-
class ListDictionaryInternal : IDictionary
23+
// Needs to be public to support binary serialization compatibility
24+
public class ListDictionaryInternal : IDictionary
2925
{
3026
private DictionaryNode head; // Do not rename (binary serialization)
3127
private int version; // Do not rename (binary serialization)

src/mscorlib/shared/System/UnitySerializationHolder.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ namespace System
1111
/// This only exists for compatibility with .NET Framework.
1212
/// </summary>
1313
[Serializable]
14-
#if CORERT
15-
public
16-
#else
17-
internal
18-
#endif
19-
sealed class UnitySerializationHolder : ISerializable, IObjectReference
14+
// Needs to be public to support binary serialization compatibility
15+
public sealed class UnitySerializationHolder : ISerializable, IObjectReference
2016
{
2117
internal const int NullUnity = 0x0002;
2218
private readonly int _unityType;

src/mscorlib/src/System/Collections/Generic/Comparer.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ int IComparer.Compare(object x, object y)
4545
// for value types.
4646
[Serializable]
4747
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
48-
internal sealed class GenericComparer<T> : Comparer<T> where T : IComparable<T>
48+
// Needs to be public to support binary serialization compatibility
49+
public sealed class GenericComparer<T> : Comparer<T> where T : IComparable<T>
4950
{
5051
public override int Compare(T x, T y)
5152
{
@@ -68,7 +69,8 @@ public override int GetHashCode() =>
6869

6970
[Serializable]
7071
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
71-
internal sealed class NullableComparer<T> : Comparer<T?> where T : struct, IComparable<T>
72+
// Needs to be public to support binary serialization compatibility
73+
public sealed class NullableComparer<T> : Comparer<T?> where T : struct, IComparable<T>
7274
{
7375
public override int Compare(T? x, T? y)
7476
{
@@ -91,7 +93,8 @@ public override int GetHashCode() =>
9193

9294
[Serializable]
9395
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
94-
internal sealed class ObjectComparer<T> : Comparer<T>
96+
// Needs to be public to support binary serialization compatibility
97+
public sealed class ObjectComparer<T> : Comparer<T>
9598
{
9699
public override int Compare(T x, T y)
97100
{

src/mscorlib/src/System/Collections/Generic/EqualityComparer.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ bool IEqualityComparer.Equals(object x, object y)
6868
// to Equal bind to IEquatable<T>.Equals(T) instead of Object.Equals(Object)
6969
[Serializable]
7070
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
71-
internal sealed class GenericEqualityComparer<T> : EqualityComparer<T> where T : IEquatable<T>
71+
// Needs to be public to support binary serialization compatibility
72+
public sealed class GenericEqualityComparer<T> : EqualityComparer<T> where T : IEquatable<T>
7273
{
7374
[MethodImpl(MethodImplOptions.AggressiveInlining)]
7475
public override bool Equals(T x, T y)
@@ -137,7 +138,8 @@ public override int GetHashCode() =>
137138

138139
[Serializable]
139140
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
140-
internal sealed class NullableEqualityComparer<T> : EqualityComparer<T?> where T : struct, IEquatable<T>
141+
// Needs to be public to support binary serialization compatibility
142+
public sealed class NullableEqualityComparer<T> : EqualityComparer<T?> where T : struct, IEquatable<T>
141143
{
142144
[MethodImpl(MethodImplOptions.AggressiveInlining)]
143145
public override bool Equals(T? x, T? y)
@@ -204,7 +206,8 @@ public override int GetHashCode() =>
204206

205207
[Serializable]
206208
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
207-
internal sealed class ObjectEqualityComparer<T> : EqualityComparer<T>
209+
// Needs to be public to support binary serialization compatibility
210+
public sealed class ObjectEqualityComparer<T> : EqualityComparer<T>
208211
{
209212
[MethodImpl(MethodImplOptions.AggressiveInlining)]
210213
public override bool Equals(T x, T y)
@@ -273,7 +276,8 @@ public override int GetHashCode() =>
273276
// We will call the C runtime function memchr, which is optimized.
274277
[Serializable]
275278
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
276-
internal sealed class ByteEqualityComparer : EqualityComparer<byte>
279+
// Needs to be public to support binary serialization compatibility
280+
public sealed class ByteEqualityComparer : EqualityComparer<byte>
277281
{
278282
[MethodImpl(MethodImplOptions.AggressiveInlining)]
279283
public override bool Equals(byte x, byte y)
@@ -310,7 +314,8 @@ public override int GetHashCode() =>
310314

311315
[Serializable]
312316
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
313-
internal sealed class EnumEqualityComparer<T> : EqualityComparer<T>, ISerializable where T : struct
317+
// Needs to be public to support binary serialization compatibility
318+
public sealed class EnumEqualityComparer<T> : EqualityComparer<T>, ISerializable where T : struct
314319
{
315320
internal EnumEqualityComparer() { }
316321

src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,8 @@ public void SetUnwind()
147147

148148
[Serializable]
149149
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
150-
#if CORERT
151-
public // On CoreRT this must be public to support binary serialization with type forwarding.
152-
#else
153-
internal
154-
#endif
155-
sealed class ContractException : Exception
150+
// Needs to be public to support binary serialization compatibility
151+
public sealed class ContractException : Exception
156152
{
157153
private readonly ContractFailureKind _kind;
158154
private readonly string _userMessage;

0 commit comments

Comments
 (0)