From 5304962d18bccdfe84f08c7ffb1230c3c4d1763a Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sun, 19 Nov 2017 07:41:14 -0800 Subject: [PATCH] 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 --- src/inc/corhdr.h | 4 --- src/mscorlib/System.Private.CoreLib.csproj | 3 -- .../shared/System/Diagnostics/Tracing/Winmeta.cs | 9 ------ .../shared/System/ObjectDisposedException.cs | 2 +- src/mscorlib/src/System/AppDomain.cs | 2 -- src/mscorlib/src/System/Buffer.cs | 1 - src/mscorlib/src/System/CompatibilitySwitches.cs | 27 ------------------ .../Diagnostics/Eventing/FrameworkEventSource.cs | 4 +-- src/mscorlib/src/System/Exception.cs | 4 +-- src/mscorlib/src/System/IO/MemoryStream.cs | 9 ------ src/mscorlib/src/System/Number.CoreCLR.cs | 1 - .../src/System/Resources/ResourceManager.cs | 19 ++++++------- .../Runtime/CompilerServices/AsyncMethodBuilder.cs | 2 +- .../FriendAccessAllowedAttribute.cs | 26 ----------------- .../Runtime/CompilerServices/YieldAwaitable.cs | 2 +- .../System/Runtime/CompilerServices/jithelpers.cs | 1 - .../InteropServices/WindowsRuntime/Attributes.cs | 2 +- .../WindowsRuntime/CLRIReferenceImpl.cs | 8 ++---- .../WindowsRuntime/EventRegistrationTokenTable.cs | 2 +- .../WindowsRuntime/IRestrictedErrorInfo.cs | 2 +- .../WindowsRuntime/WindowsRuntimeBufferHelper.cs | 33 ---------------------- .../WindowsRuntime/WindowsRuntimeMarshal.cs | 2 +- src/mscorlib/src/System/StubHelpers.cs | 10 +++---- .../src/System/Threading/SynchronizationContext.cs | 17 ++--------- .../System/Threading/Tasks/AsyncCausalityTracer.cs | 13 ++++----- src/mscorlib/src/System/Threading/Tasks/Task.cs | 30 ++++---------------- .../src/System/Threading/Tasks/TaskContinuation.cs | 4 +-- src/vm/compile.cpp | 5 +--- src/vm/ecalllist.h | 12 -------- 29 files changed, 43 insertions(+), 213 deletions(-) delete mode 100644 src/mscorlib/src/System/CompatibilitySwitches.cs delete mode 100644 src/mscorlib/src/System/Runtime/CompilerServices/FriendAccessAllowedAttribute.cs delete mode 100644 src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeBufferHelper.cs diff --git a/src/inc/corhdr.h b/src/inc/corhdr.h index 4b75742..e878c21 100644 --- a/src/inc/corhdr.h +++ b/src/inc/corhdr.h @@ -1796,10 +1796,6 @@ typedef enum CorAttributeTargets #define FRIEND_ASSEMBLY_TYPE "System.Runtime.CompilerServices.InternalsVisibleToAttribute" #define FRIEND_ASSEMBLY_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 2, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING, ELEMENT_TYPE_BOOLEAN} -#define FRIEND_ACCESS_ALLOWED_ATTRIBUTE_TYPE_W L"System.Runtime.CompilerServices.FriendAccessAllowedAttribute" -#define FRIEND_ACCESS_ALLOWED_ATTRIBUTE_TYPE "System.Runtime.CompilerServices.FriendAccessAllowedAttribute" -#define FRIEND_ACCESS_ALLOWED_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 0, ELEMENT_TYPE_VOID} - #define SUBJECT_ASSEMBLY_TYPE_W L"System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute" #define SUBJECT_ASSEMBLY_TYPE "System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute" #define SUBJECT_ASSEMBLY_SIG {IMAGE_CEE_CS_CALLCONV_DEFAULT_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING} diff --git a/src/mscorlib/System.Private.CoreLib.csproj b/src/mscorlib/System.Private.CoreLib.csproj index 149acfd..c6a87ce 100644 --- a/src/mscorlib/System.Private.CoreLib.csproj +++ b/src/mscorlib/System.Private.CoreLib.csproj @@ -119,7 +119,6 @@ - @@ -253,7 +252,6 @@ - @@ -334,7 +332,6 @@ - diff --git a/src/mscorlib/shared/System/Diagnostics/Tracing/Winmeta.cs b/src/mscorlib/shared/System/Diagnostics/Tracing/Winmeta.cs index ac756b6..c60ca5b 100644 --- a/src/mscorlib/shared/System/Diagnostics/Tracing/Winmeta.cs +++ b/src/mscorlib/shared/System/Diagnostics/Tracing/Winmeta.cs @@ -55,9 +55,6 @@ namespace System.Diagnostics.Tracing /// /// WindowsEventTask. Custom values must be in the range from 1 through 65534 /// -#if (!ES_BUILD_STANDALONE && !ES_BUILD_PN) - [System.Runtime.CompilerServices.FriendAccessAllowed] -#endif public enum EventTask { /// @@ -68,9 +65,6 @@ namespace System.Diagnostics.Tracing /// /// EventOpcode. Custom values must be in the range from 11 through 239 /// -#if (!ES_BUILD_STANDALONE && !ES_BUILD_PN) - [System.Runtime.CompilerServices.FriendAccessAllowed] -#endif public enum EventOpcode { /// @@ -124,9 +118,6 @@ namespace System.Diagnostics.Tracing /// EventChannel. Custom values must be in the range from 16 through 255. Currently only predefined values allowed. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32", Justification = "Backwards compatibility")] -#if (!ES_BUILD_STANDALONE && !ES_BUILD_PN) - [System.Runtime.CompilerServices.FriendAccessAllowed] -#endif public enum EventChannel : byte { /// diff --git a/src/mscorlib/shared/System/ObjectDisposedException.cs b/src/mscorlib/shared/System/ObjectDisposedException.cs index be80c6d..3daed13 100644 --- a/src/mscorlib/shared/System/ObjectDisposedException.cs +++ b/src/mscorlib/shared/System/ObjectDisposedException.cs @@ -72,7 +72,7 @@ namespace System { get { - if ((_objectName == null)) // && !CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) + if (_objectName == null) { return String.Empty; } diff --git a/src/mscorlib/src/System/AppDomain.cs b/src/mscorlib/src/System/AppDomain.cs index 302d623..813b2b5 100644 --- a/src/mscorlib/src/System/AppDomain.cs +++ b/src/mscorlib/src/System/AppDomain.cs @@ -242,8 +242,6 @@ namespace System // case where the compat flags have been setup. Debug.Assert(!_compatFlagsInitialized); _compatFlagsInitialized = true; - - CompatibilitySwitches.InitializeSwitches(); } /// diff --git a/src/mscorlib/src/System/Buffer.cs b/src/mscorlib/src/System/Buffer.cs index 4fef6f9..a015e56 100644 --- a/src/mscorlib/src/System/Buffer.cs +++ b/src/mscorlib/src/System/Buffer.cs @@ -243,7 +243,6 @@ namespace System // This behavioral difference is unfortunate but intentional because // 1. This method is given access to other internal dlls and this close to release we do not want to change it. // 2. It is difficult to get this right for arm and again due to release dates we would like to visit it later. - [FriendAccessAllowed] #if ARM [MethodImplAttribute(MethodImplOptions.InternalCall)] internal unsafe static extern void Memcpy(byte* dest, byte* src, int len); diff --git a/src/mscorlib/src/System/CompatibilitySwitches.cs b/src/mscorlib/src/System/CompatibilitySwitches.cs deleted file mode 100644 index 58dd640..0000000 --- a/src/mscorlib/src/System/CompatibilitySwitches.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.CompilerServices; - -namespace System -{ - [FriendAccessAllowed] - internal static class CompatibilitySwitches - { - private static bool s_AreSwitchesSet; - - public static bool IsCompatibilityBehaviorDefined - { - get - { - return s_AreSwitchesSet; - } - } - - internal static void InitializeSwitches() - { - s_AreSwitchesSet = true; - } - } -} diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs b/src/mscorlib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs index d746f58..1afe82d 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs @@ -27,7 +27,7 @@ namespace System.Diagnostics.Tracing // // This will produce an XML file, where each event is pretty-printed with all its arguments nicely parsed. // - [FriendAccessAllowed] + // [FriendAccessAllowed] [EventSource(Guid = "8E9F5090-2D75-4d03-8A81-E5AFBF85DAF1", Name = "System.Diagnostics.Eventing.FrameworkEventSource")] sealed internal class FrameworkEventSource : EventSource { @@ -52,7 +52,6 @@ namespace System.Diagnostics.Tracing } /// ETW tasks that have start/stop events. - [FriendAccessAllowed] public static class Tasks // this name is important for EventSource { /// Begin / End - GetResponse. @@ -63,7 +62,6 @@ namespace System.Diagnostics.Tracing public const EventTask ThreadTransfer = (EventTask)3; } - [FriendAccessAllowed] public static class Opcodes { public const EventOpcode ReceiveHandled = (EventOpcode)11; diff --git a/src/mscorlib/src/System/Exception.cs b/src/mscorlib/src/System/Exception.cs index 3de41ca..625f006 100644 --- a/src/mscorlib/src/System/Exception.cs +++ b/src/mscorlib/src/System/Exception.cs @@ -183,7 +183,7 @@ namespace System } } - [FriendAccessAllowed] + // [FriendAccessAllowed] internal void AddExceptionDataForRestrictedErrorInfo( string restrictedError, string restrictedErrorReference, @@ -335,7 +335,7 @@ namespace System return remoteStackTraceString + tempStackTraceString; } - [FriendAccessAllowed] + // [FriendAccessAllowed] internal void SetErrorCode(int hr) { HResult = hr; diff --git a/src/mscorlib/src/System/IO/MemoryStream.cs b/src/mscorlib/src/System/IO/MemoryStream.cs index 6039dc7..85930df 100644 --- a/src/mscorlib/src/System/IO/MemoryStream.cs +++ b/src/mscorlib/src/System/IO/MemoryStream.cs @@ -232,15 +232,6 @@ namespace System.IO return _buffer; } - // PERF: Get origin and length - used in ResourceWriter. - [FriendAccessAllowed] - internal void InternalGetOriginAndLength(out int origin, out int length) - { - if (!_isOpen) __Error.StreamIsClosed(); - origin = _origin; - length = _length; - } - // PERF: True cursor position, we don't need _origin for direct access internal int InternalGetPosition() { diff --git a/src/mscorlib/src/System/Number.CoreCLR.cs b/src/mscorlib/src/System/Number.CoreCLR.cs index 6104ebe..24dcc3d 100644 --- a/src/mscorlib/src/System/Number.CoreCLR.cs +++ b/src/mscorlib/src/System/Number.CoreCLR.cs @@ -275,7 +275,6 @@ namespace System // by the Parse methods if the NumberStyles.Any style is // specified. Note, however, that the Parse methods do not accept // NaNs or Infinities. - [FriendAccessAllowed] internal static partial class Number { [MethodImpl(MethodImplOptions.InternalCall)] diff --git a/src/mscorlib/src/System/Resources/ResourceManager.cs b/src/mscorlib/src/System/Resources/ResourceManager.cs index 490a322..f730d86 100644 --- a/src/mscorlib/src/System/Resources/ResourceManager.cs +++ b/src/mscorlib/src/System/Resources/ResourceManager.cs @@ -38,25 +38,24 @@ namespace System.Resources // allowing us to ask for a WinRT-specific ResourceManager. // It is important to have WindowsRuntimeResourceManagerBase as regular class with virtual methods and default implementations. // Defining WindowsRuntimeResourceManagerBase as abstract class or interface will cause issues when adding more methods to it - // because it�ll create dependency between mscorlib and System.Runtime.WindowsRuntime which will require always shipping both DLLs together. - // Also using interface or abstract class will not play nice with FriendAccessAllowed. + // because it'll create dependency between mscorlib and System.Runtime.WindowsRuntime which will require always shipping both DLLs together. // - [FriendAccessAllowed] - internal class WindowsRuntimeResourceManagerBase + // [FriendAccessAllowed] + internal abstract class WindowsRuntimeResourceManagerBase { - public virtual bool Initialize(string libpath, string reswFilename, out PRIExceptionInfo exceptionInfo) { exceptionInfo = null; return false; } + public abstract bool Initialize(string libpath, string reswFilename, out PRIExceptionInfo exceptionInfo); - public virtual String GetString(String stringName, String startingCulture, String neutralResourcesCulture) { return null; } + public abstract String GetString(String stringName, String startingCulture, String neutralResourcesCulture); - public virtual CultureInfo GlobalResourceContextBestFitCultureInfo + public abstract CultureInfo GlobalResourceContextBestFitCultureInfo { - get { return null; } + get; } - public virtual bool SetGlobalResourceContextDefaultCulture(CultureInfo ci) { return false; } + public abstract bool SetGlobalResourceContextDefaultCulture(CultureInfo ci); } - [FriendAccessAllowed] + // [FriendAccessAllowed] internal class PRIExceptionInfo { public string _PackageSimpleName; diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs b/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs index 85eb17c..0a61b68 100644 --- a/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs +++ b/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs @@ -38,7 +38,7 @@ namespace System.Runtime.CompilerServices /// The initialized . public static AsyncVoidMethodBuilder Create() { - SynchronizationContext sc = SynchronizationContext.CurrentNoFlow; + SynchronizationContext sc = SynchronizationContext.Current; sc?.OperationStarted(); return new AsyncVoidMethodBuilder() { _synchronizationContext = sc }; } diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/FriendAccessAllowedAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/FriendAccessAllowedAttribute.cs deleted file mode 100644 index 9d380e1..0000000 --- a/src/mscorlib/src/System/Runtime/CompilerServices/FriendAccessAllowedAttribute.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Runtime.CompilerServices -{ - /// - /// If AllInternalsVisible is not true for a friend assembly, the FriendAccessAllowed attribute - /// indicates which internals are shared with that friend assembly. - /// - [AttributeUsage(AttributeTargets.Class | - AttributeTargets.Constructor | - AttributeTargets.Enum | - AttributeTargets.Event | - AttributeTargets.Field | - AttributeTargets.Interface | - AttributeTargets.Method | - AttributeTargets.Property | - AttributeTargets.Struct, - AllowMultiple = false, - Inherited = false)] - [FriendAccessAllowed] - internal sealed class FriendAccessAllowedAttribute : Attribute - { - } -} diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs b/src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs index e2e4374..3bf6e8c 100644 --- a/src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs +++ b/src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs @@ -85,7 +85,7 @@ namespace System.Runtime.CompilerServices // post the continuation to it. However, treat the base type // as if there wasn't a SynchronizationContext, since that's what it // logically represents. - var syncCtx = SynchronizationContext.CurrentNoFlow; + var syncCtx = SynchronizationContext.Current; if (syncCtx != null && syncCtx.GetType() != typeof(SynchronizationContext)) { syncCtx.Post(s_sendOrPostCallbackRunAction, continuation); diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs b/src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs index f89f201..1441593 100644 --- a/src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs +++ b/src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs @@ -66,7 +66,6 @@ namespace System.Runtime.CompilerServices public byte m_arrayData; } - [FriendAccessAllowed] internal static class JitHelpers { // The special dll name to be used for DllImport of QCalls diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs index d78aae2..d11b436 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs @@ -32,7 +32,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // implement the CLR's support for WinRT, so this type is internal as marking tdWindowsRuntime should // generally be done via winmdexp for user code. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Delegate, Inherited = false)] - [System.Runtime.CompilerServices.FriendAccessAllowed] + // [System.Runtime.CompilerServices.FriendAccessAllowed] internal sealed class WindowsRuntimeImportAttribute : Attribute { internal WindowsRuntimeImportAttribute() diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs index 9747385..ccbb1f1 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs @@ -49,9 +49,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // the get_Value property, allocate an appropriately-sized managed object, marshal the native object // to the managed object, and free the native method. Also we want the return value boxed (aka normal value type boxing). // - // This method is called by VM. Mark the method with FriendAccessAllowed attribute to ensure that the unreferenced method - // optimization skips it and the code will be saved into NGen image. - [System.Runtime.CompilerServices.FriendAccessAllowed] + // This method is called by VM. internal static Object UnboxHelper(Object wrapper) { Debug.Assert(wrapper != null); @@ -212,9 +210,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // the get_Value property, allocate an appropriately-sized managed object, marshal the native object // to the managed object, and free the native method. // - // This method is called by VM. Mark the method with FriendAccessAllowed attribute to ensure that the unreferenced method - // optimization skips it and the code will be saved into NGen image. - [System.Runtime.CompilerServices.FriendAccessAllowed] + // This method is called by VM. internal static Object UnboxHelper(Object wrapper) { Debug.Assert(wrapper != null); diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs index 2ecd418..1a210a0 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs @@ -95,7 +95,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // Get the delegate associated with an event registration token if it exists. Additionally, // remove the registration from the table at the same time. If the token is not registered, // Extract returns null and does not modify the table. - [System.Runtime.CompilerServices.FriendAccessAllowed] + // [System.Runtime.CompilerServices.FriendAccessAllowed] internal T ExtractHandler(EventRegistrationToken token) { T handler = null; diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IRestrictedErrorInfo.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IRestrictedErrorInfo.cs index 9de5e3f..ca19d94 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IRestrictedErrorInfo.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IRestrictedErrorInfo.cs @@ -8,7 +8,7 @@ using System; namespace System.Runtime.InteropServices.WindowsRuntime { - [System.Runtime.CompilerServices.FriendAccessAllowed] + // [System.Runtime.CompilerServices.FriendAccessAllowed] [ComImport] [Guid("82BA7092-4C88-427D-A7BC-16DD93FEB67E")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeBufferHelper.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeBufferHelper.cs deleted file mode 100644 index f871d94..0000000 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeBufferHelper.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.CompilerServices; -using System.Runtime.ConstrainedExecution; -using System.Runtime.Versioning; -using System.Security; -using System.Threading; - - -namespace System.Runtime.InteropServices.WindowsRuntime -{ - /// - /// Exposes a helper method that allows WindowsRuntimeBuffer : IBuffer, IBufferInternal which is implemented in - /// System.Runtime.WindowsRuntime.dll to call into the VM. - /// - [FriendAccessAllowed] - internal static class WindowsRuntimeBufferHelper - { - [DllImport(JitHelpers.QCall)] - private unsafe extern static void StoreOverlappedPtrInCCW(ObjectHandleOnStack windowsRuntimeBuffer, NativeOverlapped* overlapped); - - - [FriendAccessAllowed] - internal unsafe static void StoreOverlappedInCCW(Object windowsRuntimeBuffer, NativeOverlapped* overlapped) - { - StoreOverlappedPtrInCCW(JitHelpers.GetObjectHandleOnStack(ref windowsRuntimeBuffer), overlapped); - } - } // class WindowsRuntimeBufferHelper -} // namespace - -// WindowsRuntimeBufferHelper.cs diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs index 2d23c31..684a9c0 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs @@ -1125,7 +1125,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime /// for the application to be invoked to process the error. /// /// true if the error was reported, false if not (ie running on Win8) - [FriendAccessAllowed] + // [FriendAccessAllowed] internal static bool ReportUnhandledError(Exception e) { // Only report to the WinRT global exception handler in modern apps diff --git a/src/mscorlib/src/System/StubHelpers.cs b/src/mscorlib/src/System/StubHelpers.cs index 2c7bc04..888f25c 100644 --- a/src/mscorlib/src/System/StubHelpers.cs +++ b/src/mscorlib/src/System/StubHelpers.cs @@ -624,7 +624,7 @@ namespace System.StubHelpers } // class DateMarshaler #if FEATURE_COMINTEROP - [FriendAccessAllowed] + // [FriendAccessAllowed] internal static class InterfaceMarshaler { [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -636,7 +636,7 @@ namespace System.StubHelpers [DllImport(JitHelpers.QCall)] static internal extern void ClearNative(IntPtr pUnk); - [FriendAccessAllowed] + // [FriendAccessAllowed] [MethodImplAttribute(MethodImplOptions.InternalCall)] static internal extern object ConvertToManagedWithoutUnboxing(IntPtr pNative); } // class InterfaceMarshaler @@ -660,10 +660,10 @@ namespace System.StubHelpers } } // class InterfaceMarshaler - [FriendAccessAllowed] + // [FriendAccessAllowed] internal static class EventArgsMarshaler { - [FriendAccessAllowed] + // [FriendAccessAllowed] static internal IntPtr CreateNativeNCCEventArgsInstance(int action, object newItems, object oldItems, int newIndex, int oldIndex) { IntPtr newItemsIP = IntPtr.Zero; @@ -688,7 +688,7 @@ namespace System.StubHelpers } } - [FriendAccessAllowed] + // [FriendAccessAllowed] [DllImport(JitHelpers.QCall)] static extern internal IntPtr CreateNativePCEventArgsInstance([MarshalAs(UnmanagedType.HString)]string name); diff --git a/src/mscorlib/src/System/Threading/SynchronizationContext.cs b/src/mscorlib/src/System/Threading/SynchronizationContext.cs index f4ca1ae..07bcdb7 100644 --- a/src/mscorlib/src/System/Threading/SynchronizationContext.cs +++ b/src/mscorlib/src/System/Threading/SynchronizationContext.cs @@ -35,12 +35,11 @@ namespace System.Threading #if FEATURE_COMINTEROP && FEATURE_APPX // // This is implemented in System.Runtime.WindowsRuntime, allowing us to ask that assembly for a WinRT-specific SyncCtx. - // I'd like this to be an interface, or at least an abstract class - but neither seems to play nice with FriendAccessAllowed. // - [FriendAccessAllowed] - internal class WinRTSynchronizationContextFactoryBase + // [FriendAccessAllowed] + internal abstract class WinRTSynchronizationContextFactoryBase { - public virtual SynchronizationContext Create(object coreDispatcher) { return null; } + public abstract SynchronizationContext Create(object coreDispatcher); } #endif //FEATURE_COMINTEROP @@ -172,16 +171,6 @@ namespace System.Threading } } - // Get the last SynchronizationContext that was set explicitly (not flowed via ExecutionContext.Capture/Run) - internal static SynchronizationContext CurrentNoFlow - { - [FriendAccessAllowed] - get - { - return Current; // SC never flows - } - } - #if FEATURE_APPX private static SynchronizationContext GetWinRTContext() { diff --git a/src/mscorlib/src/System/Threading/Tasks/AsyncCausalityTracer.cs b/src/mscorlib/src/System/Threading/Tasks/AsyncCausalityTracer.cs index 2b14f37..322b4f8 100644 --- a/src/mscorlib/src/System/Threading/Tasks/AsyncCausalityTracer.cs +++ b/src/mscorlib/src/System/Threading/Tasks/AsyncCausalityTracer.cs @@ -20,7 +20,7 @@ using WFD = Windows.Foundation.Diagnostics; namespace System.Threading.Tasks { - [FriendAccessAllowed] + // [FriendAccessAllowed] internal enum CausalityTraceLevel { #if FEATURE_COMINTEROP @@ -34,7 +34,7 @@ namespace System.Threading.Tasks #endif } - [FriendAccessAllowed] + // [FriendAccessAllowed] internal enum AsyncCausalityStatus { #if FEATURE_COMINTEROP @@ -80,7 +80,7 @@ namespace System.Threading.Tasks #endif } - [FriendAccessAllowed] + // [FriendAccessAllowed] internal static class AsyncCausalityTracer { static internal void EnableToETW(bool enabled) @@ -93,10 +93,9 @@ namespace System.Threading.Tasks #endif } - [FriendAccessAllowed] internal static bool LoggingOn { - [FriendAccessAllowed] + // [FriendAccessAllowed] get { #if FEATURE_COMINTEROP @@ -175,7 +174,7 @@ namespace System.Threading.Tasks // The TraceXXX methods should be called only if LoggingOn property returned true // - [FriendAccessAllowed] + // [FriendAccessAllowed] [MethodImplAttribute(MethodImplOptions.NoInlining)] // Tracking is slow path. Disable inlining for it. internal static void TraceOperationCreation(CausalityTraceLevel traceLevel, int taskId, string operationName, ulong relatedContext) { @@ -195,7 +194,7 @@ namespace System.Threading.Tasks #endif } - [FriendAccessAllowed] + // [FriendAccessAllowed] [MethodImplAttribute(MethodImplOptions.NoInlining)] internal static void TraceOperationCompletion(CausalityTraceLevel traceLevel, int taskId, AsyncCausalityStatus status) { diff --git a/src/mscorlib/src/System/Threading/Tasks/Task.cs b/src/mscorlib/src/System/Threading/Tasks/Task.cs index 37ae347..5c9754f 100644 --- a/src/mscorlib/src/System/Threading/Tasks/Task.cs +++ b/src/mscorlib/src/System/Threading/Tasks/Task.cs @@ -200,7 +200,7 @@ namespace System.Threading.Tasks // A private flag that would be set (only) by the debugger // When true the Async Causality logging trace is enabled as well as a dictionary to relate operation ids with Tasks - [FriendAccessAllowed] + // [FriendAccessAllowed] internal static bool s_asyncDebuggingEnabled; //false by default // This dictonary relates the task id, from an operation id located in the Async Causality log to the actual @@ -210,7 +210,7 @@ namespace System.Threading.Tasks // These methods are a way to access the dictionary both from this class and for other classes that also // activate dummy tasks. Specifically the AsyncTaskMethodBuilder and AsyncTaskMethodBuilder<> - [FriendAccessAllowed] + // [FriendAccessAllowed] internal static bool AddToActiveTasks(Task task) { Debug.Assert(task != null, "Null Task objects can't be added to the ActiveTasks collection"); @@ -222,7 +222,7 @@ namespace System.Threading.Tasks return true; } - [FriendAccessAllowed] + // [FriendAccessAllowed] internal static void RemoveFromActiveTasks(int taskId) { lock (s_activeTasksLock) @@ -2580,7 +2580,7 @@ namespace System.Threading.Tasks // then ignore it. This helps with performance by avoiding unnecessary posts and queueing // of work items, but more so it ensures that if code happens to publish the default context // as current, it won't prevent usage of a current task scheduler if there is one. - var syncCtx = SynchronizationContext.CurrentNoFlow; + var syncCtx = SynchronizationContext.Current; if (syncCtx != null && syncCtx.GetType() != typeof(SynchronizationContext)) { tc = new SynchronizationContextAwaitTaskContinuation(syncCtx, continuationAction, flowExecutionContext); @@ -2641,7 +2641,7 @@ namespace System.Threading.Tasks // fall back to using the state machine's delegate. if (continueOnCapturedContext) { - SynchronizationContext syncCtx = SynchronizationContext.CurrentNoFlow; + SynchronizationContext syncCtx = SynchronizationContext.Current; if (syncCtx != null && syncCtx.GetType() != typeof(SynchronizationContext)) { var tc = new SynchronizationContextAwaitTaskContinuation(syncCtx, stateMachineBox.MoveNextAction, flowExecutionContext: false); @@ -5151,25 +5151,6 @@ namespace System.Threading.Tasks return task; } - /// Creates a that's completed due to cancellation with the specified token. - /// The token with which to complete the task. - /// The canceled task. - [FriendAccessAllowed] - internal static Task FromCancellation(CancellationToken cancellationToken) - { - return FromCanceled(cancellationToken); - } - - /// Creates a that's completed due to cancellation with the specified token. - /// The type of the result returned by the task. - /// The token with which to complete the task. - /// The canceled task. - [FriendAccessAllowed] - internal static Task FromCancellation(CancellationToken cancellationToken) - { - return FromCanceled(cancellationToken); - } - #endregion #region Run methods @@ -6138,7 +6119,6 @@ namespace System.Threading.Tasks } #endregion - [FriendAccessAllowed] internal static Task CreateUnwrapPromise(Task outerTask, bool lookForOce) { Debug.Assert(outerTask != null); diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs b/src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs index 8835eb5..42fc40e 100644 --- a/src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs +++ b/src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs @@ -401,7 +401,7 @@ namespace System.Threading.Tasks { // If we're allowed to inline, run the action on this thread. if (canInlineContinuationTask && - m_syncContext == SynchronizationContext.CurrentNoFlow) + m_syncContext == SynchronizationContext.Current) { RunCallback(GetInvokeActionCallback(), m_action, ref Task.t_currentTask); } @@ -614,7 +614,7 @@ namespace System.Threading.Tasks { // If there's a SynchronizationContext, we'll be conservative and say // this is a bad location to inline. - var ctx = SynchronizationContext.CurrentNoFlow; + var ctx = SynchronizationContext.Current; if (ctx != null && ctx.GetType() != typeof(SynchronizationContext)) return false; // Similarly, if there's a non-default TaskScheduler, we'll be conservative diff --git a/src/vm/compile.cpp b/src/vm/compile.cpp index 327f0f1..7040ffc 100644 --- a/src/vm/compile.cpp +++ b/src/vm/compile.cpp @@ -4903,10 +4903,7 @@ static bool IsMethodAccessibleOutsideItsAssembly(MethodDesc * pMD) { STANDARD_VM_CONTRACT; - // Note that this ignores unrestricted friend access. This friend access allowed attribute can be used to - // prevent methods from getting trimmed if necessary. - if (pMD->GetMDImport()->GetCustomAttributeByName(pMD->GetMemberDef(), FRIEND_ACCESS_ALLOWED_ATTRIBUTE_TYPE, NULL, NULL) == S_OK) - return true; + // Note that this ignores friend access. switch (pMD->GetAttrs() & mdMemberAccessMask) { diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h index b1f9b2b..f3118f4 100644 --- a/src/vm/ecalllist.h +++ b/src/vm/ecalllist.h @@ -1196,13 +1196,6 @@ FCFuncStart(gStreamFuncs) FCFuncEnd() -#ifdef FEATURE_COMINTEROP -FCFuncStart(gWindowsRuntimeBufferHelperFuncs) - QCFuncElement("StoreOverlappedPtrInCCW", WindowsRuntimeBufferHelper::StoreOverlappedPtrInCCW) - //QCFuncElement("ReleaseOverlapped", WindowsRuntimeBufferHelper::ReleaseOverlapped) -FCFuncEnd() -#endif // ifdef FEATURE_COMINTEROP - #if defined(FEATURE_EVENTSOURCE_XPLAT) FCFuncStart(gEventLogger) QCFuncElement("IsEventSourceLoggingEnabled", XplatEventSourceLogger::IsEventSourceLoggingEnabled) @@ -1431,11 +1424,6 @@ FCClassElement("WeakReference`1", "System", gWeakReferenceOfTFuncs) FCClassElement("WinRTTypeNameConverter", "System.StubHelpers", gWinRTTypeNameConverterFuncs) #endif // FEATURE_COMINTEROP -#ifdef FEATURE_COMINTEROP -FCClassElement("WindowsRuntimeBufferHelper", "System.Runtime.InteropServices.WindowsRuntime", gWindowsRuntimeBufferHelperFuncs) -#endif - - #if defined(FEATURE_EVENTSOURCE_XPLAT) FCClassElement("XplatEventLogger", "System.Diagnostics.Tracing", gEventLogger) -- 2.7.4