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

Commit 5304962

Browse files
authored
Delete FriendAccessAllowedAttribute and associated dead code (#15101)
- Preserved commented out FriendAccessAllowed on types and methods that are still used as friends in System.Runtime.WindowsRuntime
1 parent b785ee1 commit 5304962

29 files changed

+43
-213
lines changed

src/inc/corhdr.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,10 +1796,6 @@ typedef enum CorAttributeTargets
17961796
#define FRIEND_ASSEMBLY_TYPE "System.Runtime.CompilerServices.InternalsVisibleToAttribute"
17971797
#define FRIEND_ASSEMBLY_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 2, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING, ELEMENT_TYPE_BOOLEAN}
17981798

1799-
#define FRIEND_ACCESS_ALLOWED_ATTRIBUTE_TYPE_W L"System.Runtime.CompilerServices.FriendAccessAllowedAttribute"
1800-
#define FRIEND_ACCESS_ALLOWED_ATTRIBUTE_TYPE "System.Runtime.CompilerServices.FriendAccessAllowedAttribute"
1801-
#define FRIEND_ACCESS_ALLOWED_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID}
1802-
18031799
#define SUBJECT_ASSEMBLY_TYPE_W L"System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute"
18041800
#define SUBJECT_ASSEMBLY_TYPE "System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute"
18051801
#define SUBJECT_ASSEMBLY_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING}

src/mscorlib/System.Private.CoreLib.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119
<!-- Sources -->
120120
<ItemGroup>
121121
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\RuntimeHelpers.cs" />
122-
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\FriendAccessAllowedAttribute.cs" />
123122
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\TypeDependencyAttribute.cs" />
124123
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\jithelpers.cs" />
125124
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\Unsafe.cs" />
@@ -253,7 +252,6 @@
253252
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\ICustomPropertyProvider.cs" />
254253
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\ICustomProperty.cs" />
255254
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CustomPropertyImpl.cs" />
256-
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\WindowsRuntimeBufferHelper.cs" />
257255
</ItemGroup>
258256
<ItemGroup Condition="'$(FeatureCominterop)' == 'true'">
259257
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\IIterable.cs" />
@@ -334,7 +332,6 @@
334332
<Compile Include="$(BclSourcesRoot)\System\Attribute.cs" />
335333
<Compile Include="$(BclSourcesRoot)\System\BadImageFormatException.CoreCLR.cs" />
336334
<Compile Include="$(BclSourcesRoot)\System\Buffer.cs" />
337-
<Compile Include="$(BclSourcesRoot)\System\CompatibilitySwitches.cs" />
338335
<Compile Include="$(BclSourcesRoot)\System\Currency.cs" />
339336
<Compile Include="$(BclSourcesRoot)\System\Decimal.cs" />
340337
<Compile Include="$(BclSourcesRoot)\System\DefaultBinder.CanConvert.cs" />

src/mscorlib/shared/System/Diagnostics/Tracing/Winmeta.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ public enum EventLevel
5555
/// <summary>
5656
/// WindowsEventTask. Custom values must be in the range from 1 through 65534
5757
/// </summary>
58-
#if (!ES_BUILD_STANDALONE && !ES_BUILD_PN)
59-
[System.Runtime.CompilerServices.FriendAccessAllowed]
60-
#endif
6158
public enum EventTask
6259
{
6360
/// <summary>
@@ -68,9 +65,6 @@ public enum EventTask
6865
/// <summary>
6966
/// EventOpcode. Custom values must be in the range from 11 through 239
7067
/// </summary>
71-
#if (!ES_BUILD_STANDALONE && !ES_BUILD_PN)
72-
[System.Runtime.CompilerServices.FriendAccessAllowed]
73-
#endif
7468
public enum EventOpcode
7569
{
7670
/// <summary>
@@ -124,9 +118,6 @@ public enum EventOpcode
124118
/// EventChannel. Custom values must be in the range from 16 through 255. Currently only predefined values allowed.
125119
/// </summary>
126120
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32", Justification = "Backwards compatibility")]
127-
#if (!ES_BUILD_STANDALONE && !ES_BUILD_PN)
128-
[System.Runtime.CompilerServices.FriendAccessAllowed]
129-
#endif
130121
public enum EventChannel : byte
131122
{
132123
/// <summary>

src/mscorlib/shared/System/ObjectDisposedException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public String ObjectName
7272
{
7373
get
7474
{
75-
if ((_objectName == null)) // && !CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
75+
if (_objectName == null)
7676
{
7777
return String.Empty;
7878
}

src/mscorlib/src/System/AppDomain.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ private void InitializeCompatibilityFlags()
242242
// case where the compat flags have been setup.
243243
Debug.Assert(!_compatFlagsInitialized);
244244
_compatFlagsInitialized = true;
245-
246-
CompatibilitySwitches.InitializeSwitches();
247245
}
248246

249247
/// <summary>

src/mscorlib/src/System/Buffer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ internal unsafe static void Memcpy(byte* pDest, int destIndex, byte[] src, int s
243243
// This behavioral difference is unfortunate but intentional because
244244
// 1. This method is given access to other internal dlls and this close to release we do not want to change it.
245245
// 2. It is difficult to get this right for arm and again due to release dates we would like to visit it later.
246-
[FriendAccessAllowed]
247246
#if ARM
248247
[MethodImplAttribute(MethodImplOptions.InternalCall)]
249248
internal unsafe static extern void Memcpy(byte* dest, byte* src, int len);

src/mscorlib/src/System/CompatibilitySwitches.cs

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

src/mscorlib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace System.Diagnostics.Tracing
2727
//
2828
// This will produce an XML file, where each event is pretty-printed with all its arguments nicely parsed.
2929
//
30-
[FriendAccessAllowed]
30+
// [FriendAccessAllowed]
3131
[EventSource(Guid = "8E9F5090-2D75-4d03-8A81-E5AFBF85DAF1", Name = "System.Diagnostics.Eventing.FrameworkEventSource")]
3232
sealed internal class FrameworkEventSource : EventSource
3333
{
@@ -52,7 +52,6 @@ public static class Keywords
5252
}
5353

5454
/// <summary>ETW tasks that have start/stop events.</summary>
55-
[FriendAccessAllowed]
5655
public static class Tasks // this name is important for EventSource
5756
{
5857
/// <summary>Begin / End - GetResponse.</summary>
@@ -63,7 +62,6 @@ public static class Keywords
6362
public const EventTask ThreadTransfer = (EventTask)3;
6463
}
6564

66-
[FriendAccessAllowed]
6765
public static class Opcodes
6866
{
6967
public const EventOpcode ReceiveHandled = (EventOpcode)11;

src/mscorlib/src/System/Exception.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public object RealErrorObject
183183
}
184184
}
185185

186-
[FriendAccessAllowed]
186+
// [FriendAccessAllowed]
187187
internal void AddExceptionDataForRestrictedErrorInfo(
188188
string restrictedError,
189189
string restrictedErrorReference,
@@ -335,7 +335,7 @@ private string GetStackTrace(bool needFileInfo)
335335
return remoteStackTraceString + tempStackTraceString;
336336
}
337337

338-
[FriendAccessAllowed]
338+
// [FriendAccessAllowed]
339339
internal void SetErrorCode(int hr)
340340
{
341341
HResult = hr;

src/mscorlib/src/System/IO/MemoryStream.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,6 @@ internal byte[] InternalGetBuffer()
232232
return _buffer;
233233
}
234234

235-
// PERF: Get origin and length - used in ResourceWriter.
236-
[FriendAccessAllowed]
237-
internal void InternalGetOriginAndLength(out int origin, out int length)
238-
{
239-
if (!_isOpen) __Error.StreamIsClosed();
240-
origin = _origin;
241-
length = _length;
242-
}
243-
244235
// PERF: True cursor position, we don't need _origin for direct access
245236
internal int InternalGetPosition()
246237
{

0 commit comments

Comments
 (0)