- Preserved commented out FriendAccessAllowed on types and methods that are still used as friends in System.Runtime.WindowsRuntime
#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}
<!-- Sources -->
<ItemGroup>
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\RuntimeHelpers.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\FriendAccessAllowedAttribute.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\TypeDependencyAttribute.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\jithelpers.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\Unsafe.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\ICustomPropertyProvider.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\ICustomProperty.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CustomPropertyImpl.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\WindowsRuntimeBufferHelper.cs" />
</ItemGroup>
<ItemGroup Condition="'$(FeatureCominterop)' == 'true'">
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\IIterable.cs" />
<Compile Include="$(BclSourcesRoot)\System\Attribute.cs" />
<Compile Include="$(BclSourcesRoot)\System\BadImageFormatException.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Buffer.cs" />
- <Compile Include="$(BclSourcesRoot)\System\CompatibilitySwitches.cs" />
<Compile Include="$(BclSourcesRoot)\System\Currency.cs" />
<Compile Include="$(BclSourcesRoot)\System\Decimal.cs" />
<Compile Include="$(BclSourcesRoot)\System\DefaultBinder.CanConvert.cs" />
/// <summary>
/// WindowsEventTask. Custom values must be in the range from 1 through 65534
/// </summary>
-#if (!ES_BUILD_STANDALONE && !ES_BUILD_PN)
- [System.Runtime.CompilerServices.FriendAccessAllowed]
-#endif
public enum EventTask
{
/// <summary>
/// <summary>
/// EventOpcode. Custom values must be in the range from 11 through 239
/// </summary>
-#if (!ES_BUILD_STANDALONE && !ES_BUILD_PN)
- [System.Runtime.CompilerServices.FriendAccessAllowed]
-#endif
public enum EventOpcode
{
/// <summary>
/// EventChannel. Custom values must be in the range from 16 through 255. Currently only predefined values allowed.
/// </summary>
[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
{
/// <summary>
{
get
{
- if ((_objectName == null)) // && !CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
+ if (_objectName == null)
{
return String.Empty;
}
// case where the compat flags have been setup.
Debug.Assert(!_compatFlagsInitialized);
_compatFlagsInitialized = true;
-
- CompatibilitySwitches.InitializeSwitches();
}
/// <summary>
// 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);
+++ /dev/null
-// 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;
- }
- }
-}
//
// 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
{
}
/// <summary>ETW tasks that have start/stop events.</summary>
- [FriendAccessAllowed]
public static class Tasks // this name is important for EventSource
{
/// <summary>Begin / End - GetResponse.</summary>
public const EventTask ThreadTransfer = (EventTask)3;
}
- [FriendAccessAllowed]
public static class Opcodes
{
public const EventOpcode ReceiveHandled = (EventOpcode)11;
}
}
- [FriendAccessAllowed]
+ // [FriendAccessAllowed]
internal void AddExceptionDataForRestrictedErrorInfo(
string restrictedError,
string restrictedErrorReference,
return remoteStackTraceString + tempStackTraceString;
}
- [FriendAccessAllowed]
+ // [FriendAccessAllowed]
internal void SetErrorCode(int hr)
{
HResult = hr;
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()
{
// 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)]
// 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;
/// <returns>The initialized <see cref="AsyncVoidMethodBuilder"/>.</returns>
public static AsyncVoidMethodBuilder Create()
{
- SynchronizationContext sc = SynchronizationContext.CurrentNoFlow;
+ SynchronizationContext sc = SynchronizationContext.Current;
sc?.OperationStarted();
return new AsyncVoidMethodBuilder() { _synchronizationContext = sc };
}
+++ /dev/null
-// 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
-{
- /// <summary>
- /// If AllInternalsVisible is not true for a friend assembly, the FriendAccessAllowed attribute
- /// indicates which internals are shared with that friend assembly.
- /// </summary>
- [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
- {
- }
-}
// 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);
public byte m_arrayData;
}
- [FriendAccessAllowed]
internal static class JitHelpers
{
// The special dll name to be used for DllImport of QCalls
// 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()
// 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);
// 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);
// 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;
namespace System.Runtime.InteropServices.WindowsRuntime
{
- [System.Runtime.CompilerServices.FriendAccessAllowed]
+ // [System.Runtime.CompilerServices.FriendAccessAllowed]
[ComImport]
[Guid("82BA7092-4C88-427D-A7BC-16DD93FEB67E")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+++ /dev/null
-// 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
-{
- /// <summary>
- /// Exposes a helper method that allows <code>WindowsRuntimeBuffer : IBuffer, IBufferInternal</code> which is implemented in
- /// <code>System.Runtime.WindowsRuntime.dll</code> to call into the VM.
- /// </summary>
- [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
/// for the application to be invoked to process the error.
/// </summary>
/// <returns>true if the error was reported, false if not (ie running on Win8)</returns>
- [FriendAccessAllowed]
+ // [FriendAccessAllowed]
internal static bool ReportUnhandledError(Exception e)
{
// Only report to the WinRT global exception handler in modern apps
} // class DateMarshaler
#if FEATURE_COMINTEROP
- [FriendAccessAllowed]
+ // [FriendAccessAllowed]
internal static class InterfaceMarshaler
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[DllImport(JitHelpers.QCall)]
static internal extern void ClearNative(IntPtr pUnk);
- [FriendAccessAllowed]
+ // [FriendAccessAllowed]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static internal extern object ConvertToManagedWithoutUnboxing(IntPtr pNative);
} // class InterfaceMarshaler
}
} // 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;
}
}
- [FriendAccessAllowed]
+ // [FriendAccessAllowed]
[DllImport(JitHelpers.QCall)]
static extern internal IntPtr CreateNativePCEventArgsInstance([MarshalAs(UnmanagedType.HString)]string name);
#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
}
}
- // 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()
{
namespace System.Threading.Tasks
{
- [FriendAccessAllowed]
+ // [FriendAccessAllowed]
internal enum CausalityTraceLevel
{
#if FEATURE_COMINTEROP
#endif
}
- [FriendAccessAllowed]
+ // [FriendAccessAllowed]
internal enum AsyncCausalityStatus
{
#if FEATURE_COMINTEROP
#endif
}
- [FriendAccessAllowed]
+ // [FriendAccessAllowed]
internal static class AsyncCausalityTracer
{
static internal void EnableToETW(bool enabled)
#endif
}
- [FriendAccessAllowed]
internal static bool LoggingOn
{
- [FriendAccessAllowed]
+ // [FriendAccessAllowed]
get
{
#if FEATURE_COMINTEROP
// 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)
{
#endif
}
- [FriendAccessAllowed]
+ // [FriendAccessAllowed]
[MethodImplAttribute(MethodImplOptions.NoInlining)]
internal static void TraceOperationCompletion(CausalityTraceLevel traceLevel, int taskId, AsyncCausalityStatus status)
{
// 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
// 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");
return true;
}
- [FriendAccessAllowed]
+ // [FriendAccessAllowed]
internal static void RemoveFromActiveTasks(int taskId)
{
lock (s_activeTasksLock)
// 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);
// 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);
return task;
}
- /// <summary>Creates a <see cref="Task"/> that's completed due to cancellation with the specified token.</summary>
- /// <param name="cancellationToken">The token with which to complete the task.</param>
- /// <returns>The canceled task.</returns>
- [FriendAccessAllowed]
- internal static Task FromCancellation(CancellationToken cancellationToken)
- {
- return FromCanceled(cancellationToken);
- }
-
- /// <summary>Creates a <see cref="Task{TResult}"/> that's completed due to cancellation with the specified token.</summary>
- /// <typeparam name="TResult">The type of the result returned by the task.</typeparam>
- /// <param name="cancellationToken">The token with which to complete the task.</param>
- /// <returns>The canceled task.</returns>
- [FriendAccessAllowed]
- internal static Task<TResult> FromCancellation<TResult>(CancellationToken cancellationToken)
- {
- return FromCanceled<TResult>(cancellationToken);
- }
-
#endregion
#region Run methods
}
#endregion
- [FriendAccessAllowed]
internal static Task<TResult> CreateUnwrapPromise<TResult>(Task outerTask, bool lookForOce)
{
Debug.Assert(outerTask != null);
{
// 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);
}
{
// 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
{
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)
{
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)
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)