Merge pull request #12552 from mikedn/switch-bt
authorBruce Forstall <brucefo@microsoft.com>
Mon, 20 Nov 2017 21:01:09 +0000 (13:01 -0800)
committerGitHub <noreply@github.com>
Mon, 20 Nov 2017 21:01:09 +0000 (13:01 -0800)
Use BT in switch lowering

61 files changed:
BuildToolsVersion.txt
Documentation/botr/mscorlib.md
dependencies.props
src/inc/corhdr.h
src/jit/codegenarm64.cpp
src/jit/lclvars.cpp
src/jit/lsraarm64.cpp
src/mscorlib/Resources/Strings.resx
src/mscorlib/System.Private.CoreLib.csproj
src/mscorlib/shared/System.Private.CoreLib.Shared.projitems
src/mscorlib/shared/System/Diagnostics/DebuggableAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Diagnostics/DebuggerBrowsableAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Diagnostics/DebuggerDisplayAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Diagnostics/DebuggerHiddenAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Diagnostics/DebuggerNonUserCodeAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Diagnostics/DebuggerStepThroughAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Diagnostics/DebuggerStepperBoundaryAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Diagnostics/DebuggerTypeProxyAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Diagnostics/DebuggerVisualizerAttribute.cs [new file with mode: 0644]
src/mscorlib/shared/System/Diagnostics/Tracing/Winmeta.cs
src/mscorlib/shared/System/IO/MemoryStream.cs [moved from src/mscorlib/src/System/IO/MemoryStream.cs with 87% similarity]
src/mscorlib/shared/System/IO/UnmanagedMemoryStream.cs
src/mscorlib/shared/System/Number.Formatting.cs
src/mscorlib/shared/System/ObjectDisposedException.cs
src/mscorlib/shared/System/Text/ValueStringBuilder.cs
src/mscorlib/shared/System/Threading/Tasks/TaskToApm.cs [moved from src/mscorlib/src/System/Threading/Tasks/TaskToApm.cs with 88% similarity]
src/mscorlib/src/System/AppDomain.cs
src/mscorlib/src/System/Buffer.cs
src/mscorlib/src/System/CompatibilitySwitches.cs [deleted file]
src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs [deleted file]
src/mscorlib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs
src/mscorlib/src/System/Exception.cs
src/mscorlib/src/System/IO/BinaryReader.cs
src/mscorlib/src/System/IO/File.cs
src/mscorlib/src/System/IO/Stream.cs
src/mscorlib/src/System/IO/StreamReader.cs
src/mscorlib/src/System/IO/TextReader.cs
src/mscorlib/src/System/IO/__Error.cs [deleted file]
src/mscorlib/src/System/Number.CoreCLR.cs
src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
src/mscorlib/src/System/Resources/ResourceManager.cs
src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
src/mscorlib/src/System/Runtime/CompilerServices/FriendAccessAllowedAttribute.cs [deleted file]
src/mscorlib/src/System/Runtime/CompilerServices/YieldAwaitable.cs
src/mscorlib/src/System/Runtime/CompilerServices/jithelpers.cs
src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs
src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs
src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs
src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IRestrictedErrorInfo.cs
src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeBufferHelper.cs [deleted file]
src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs
src/mscorlib/src/System/StubHelpers.cs
src/mscorlib/src/System/Threading/SynchronizationContext.cs
src/mscorlib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
src/mscorlib/src/System/Threading/Tasks/Task.cs
src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs
src/mscorlib/src/System/TimeZoneInfo.Unix.cs
src/vm/compile.cpp
src/vm/comutilnative.cpp
src/vm/comutilnative.h
src/vm/ecalllist.h

index bf0d48d..de1b8b9 100644 (file)
@@ -1 +1 @@
-2.0.0-prerelease-02217-03
+2.0.0-prerelease-02219-01
index 8086124..d5fc85e 100644 (file)
@@ -82,10 +82,8 @@ Do not replicate the comments into your actual QCall implementation. This is for
 
        class Foo
        {
-           // All QCalls should have the following DllImport and
-           // SuppressUnmanagedCodeSecurity attributes
+           // All QCalls should have the following DllImport attribute
            [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
-           [SuppressUnmanagedCodeSecurity]
            // QCalls should always be static extern.
            private static extern bool Bar(int flags, string inString, StringHandleOnStack retString);
 
index 0c3fe64..4abfa47 100644 (file)
 
   <!-- Source of truth for dependency tooling: the commit hash of the dotnet/versions master branch as of the last auto-upgrade. -->
   <PropertyGroup>
-    <CoreFxCurrentRef>aa4fb5d5604af80d55d4c8ddb8f7775e5a541558</CoreFxCurrentRef>
-    <CoreClrCurrentRef>aa4fb5d5604af80d55d4c8ddb8f7775e5a541558</CoreClrCurrentRef>
-    <BuildToolsCurrentRef>aa4fb5d5604af80d55d4c8ddb8f7775e5a541558</BuildToolsCurrentRef>
+    <CoreFxCurrentRef>e57b24cdf9893390fa838d11557234c3f1e4aeda</CoreFxCurrentRef>
+    <CoreClrCurrentRef>e57b24cdf9893390fa838d11557234c3f1e4aeda</CoreClrCurrentRef>
+    <BuildToolsCurrentRef>e57b24cdf9893390fa838d11557234c3f1e4aeda</BuildToolsCurrentRef>
     <PgoDataCurrentRef>aa4fb5d5604af80d55d4c8ddb8f7775e5a541558</PgoDataCurrentRef>
   </PropertyGroup>
 
   <!-- Tests/infrastructure dependency versions. -->
   <PropertyGroup>
-    <MicrosoftPrivateCoreFxNETCoreAppPackageVersion>4.5.0-preview1-25917-04</MicrosoftPrivateCoreFxNETCoreAppPackageVersion>
-    <MicrosoftNETCorePlatformsPackageVersion>2.1.0-preview1-25917-04</MicrosoftNETCorePlatformsPackageVersion>
+    <MicrosoftPrivateCoreFxNETCoreAppPackageVersion>4.5.0-preview1-25920-01</MicrosoftPrivateCoreFxNETCoreAppPackageVersion>
+    <MicrosoftNETCorePlatformsPackageVersion>2.1.0-preview1-25920-01</MicrosoftNETCorePlatformsPackageVersion>
     <PgoDataPackageVersion>99.99.99-master-20171116-0044</PgoDataPackageVersion>
-    <MicrosoftNETCoreRuntimeCoreCLRPackageVersion>2.1.0-preview1-25918-04</MicrosoftNETCoreRuntimeCoreCLRPackageVersion>
+    <MicrosoftNETCoreRuntimeCoreCLRPackageVersion>2.1.0-preview1-25920-01</MicrosoftNETCoreRuntimeCoreCLRPackageVersion>
     <XunitPackageVersion>2.2.0-beta2-build3300</XunitPackageVersion>
     <XunitConsoleNetcorePackageVersion>1.0.2-prerelease-00177</XunitConsoleNetcorePackageVersion>
     <XunitPerformanceApiPackageVersion>1.0.0-beta-build0012</XunitPerformanceApiPackageVersion>
@@ -45,7 +45,7 @@
   <!-- Package versions used as toolsets -->
   <PropertyGroup>
     <FeedTasksPackage>Microsoft.DotNet.Build.Tasks.Feed</FeedTasksPackage>
-    <FeedTasksPackageVersion>1.0.0-prerelease-02217-03</FeedTasksPackageVersion>
+    <FeedTasksPackageVersion>1.0.0-prerelease-02219-01</FeedTasksPackageVersion>
   </PropertyGroup>
 
   <!-- Package dependency verification/auto-upgrade configuration. -->
index 4b75742..e878c21 100644 (file)
@@ -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}
index 95a56df..a0478f3 100644 (file)
@@ -4662,6 +4662,7 @@ void CodeGen::genSIMDIntrinsicSetItem(GenTreeSIMD* simdNode)
     assert(genIsValidFloatReg(targetReg));
     assert(genIsValidFloatReg(op1Reg));
     assert(genIsValidIntReg(op2Reg) || genIsValidFloatReg(op2Reg));
+    assert(targetReg != op2Reg);
 
     emitAttr attr = emitTypeSize(baseType);
 
index d7d1f6e..169b483 100644 (file)
@@ -7303,7 +7303,7 @@ Compiler::fgWalkResult Compiler::lvaStressLclFldCB(GenTreePtr* pTree, fgWalkData
 #ifdef _TARGET_ARM_
         // We need to support alignment requirements to access memory on ARM
         unsigned alignment = 1;
-        pComp->codeGen->InferOpSizeAlign(tree, &alignment);
+        pComp->codeGen->InferOpSizeAlign(lcl, &alignment);
         alignment = roundUp(alignment, TARGET_POINTER_SIZE);
         padding   = roundUp(padding, alignment);
 #endif // _TARGET_ARM_
index 8f3d034..22fb56e 100644 (file)
@@ -842,10 +842,6 @@ void LinearScan::TreeNodeInfoInitSIMD(GenTreeSIMD* simdTree)
         case SIMDIntrinsicBitwiseXor:
         case SIMDIntrinsicMin:
         case SIMDIntrinsicMax:
-        case SIMDIntrinsicSetX:
-        case SIMDIntrinsicSetY:
-        case SIMDIntrinsicSetZ:
-        case SIMDIntrinsicSetW:
         case SIMDIntrinsicEqual:
         case SIMDIntrinsicLessThan:
         case SIMDIntrinsicGreaterThan:
@@ -854,6 +850,10 @@ void LinearScan::TreeNodeInfoInitSIMD(GenTreeSIMD* simdTree)
             info->srcCount = 2;
             break;
 
+        case SIMDIntrinsicSetX:
+        case SIMDIntrinsicSetY:
+        case SIMDIntrinsicSetZ:
+        case SIMDIntrinsicSetW:
         case SIMDIntrinsicNarrow:
             info->srcCount = 2;
 
index 8fde41a..a905183 100644 (file)
     <value>Search pattern '{0}' cannot contain ".." to move up directories and can be contained only internally in file/directory names, as in "a..b".</value>
   </data>
   <data name="Arg_InvalidTypeInRetType" xml:space="preserve">
-    <value>The return Type contains some invalid type (i.e. null, ByRef)</value>
+    <value>The return Type must be a type provided by the runtime.</value>
   </data>
   <data name="Arg_InvalidTypeInSignature" xml:space="preserve">
     <value>The signature Type array contains some invalid type (i.e. null, void)</value>
   <data name="IndexOutOfRange_ArrayRankIndex" xml:space="preserve">
     <value>Array does not have that many dimensions.</value>
   </data>
-  <data name="IndexOutOfRange_IORaceCondition" xml:space="preserve">
-    <value>Probable I/O race condition detected while copying memory. The I/O package is not thread safe by default. In multithreaded applications, a stream must be accessed in a thread-safe way, such as a thread-safe wrapper returned by TextReader's or TextWriter's Synchronized methods. This also applies to classes like StreamWriter and StreamReader.</value>
-  </data>
   <data name="IndexOutOfRange_UMSPosition" xml:space="preserve">
     <value>Unmanaged memory stream position was beyond the capacity of the stream.</value>
   </data>
   <data name="NotSupported_SignatureType" xml:space="preserve">
     <value>This method is not supported on signature types.</value>
   </data>
-    <data name="Memory_ThrowIfDisposed" xml:space="preserve">
+  <data name="Memory_ThrowIfDisposed" xml:space="preserve">
     <value>Memory&lt;T&gt; has been disposed.</value>
   </data>
   <data name="Memory_OutstandingReferences" xml:space="preserve">
index cae3d42..4bae50a 100644 (file)
   <!-- 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" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\ConcurrentExclusiveSchedulerPair.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\ProducerConsumerQueues.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\TPLETWProvider.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\TaskToApm.cs" />
     <Compile Condition="'$(FeatureCominterop)' == 'true'" Include="$(BclSourcesRoot)\System\Threading\Tasks\IAsyncCausalityTracerStatics.cs" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="$(BclSourcesRoot)\System\Threading\ClrThreadPoolPreAllocatedOverlapped.cs" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="$(BclSourcesRoot)\System\IO\__Error.cs" />
     <Compile Include="$(BclSourcesRoot)\System\IO\BinaryReader.cs" />
     <Compile Include="$(BclSourcesRoot)\System\IO\Directory.cs" />
     <Compile Include="$(BclSourcesRoot)\System\IO\SearchOption.cs" />
     <Compile Include="$(BclSourcesRoot)\System\IO\File.cs" />
     <Compile Include="$(BclSourcesRoot)\System\IO\FileLoadException.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\IO\FileNotFoundException.CoreCLR.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\IO\MemoryStream.cs" />
     <Compile Include="$(BclSourcesRoot)\System\IO\Stream.cs" />
     <Compile Include="$(BclSourcesRoot)\System\IO\UnmanagedMemoryAccessor.cs" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="$(BclSourcesRoot)\System\Diagnostics\Debugger.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Diagnostics\DebuggerAttributes.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Diagnostics\ICustomDebuggerNotification.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Diagnostics\Stacktrace.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Diagnostics\Stackframe.cs" />
index 79b9dca..e5507df 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\CodeAnalysis\SuppressMessageAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\ConditionalAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\Debug.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggableAttribute.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerBrowsableAttribute.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerDisplayAttribute.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerHiddenAttribute.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerNonUserCodeAttribute.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerStepThroughAttribute.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerStepperBoundaryAttribute.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerTypeProxyAttribute.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebuggerVisualizerAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\StackTraceHiddenAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\DivideByZeroException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\DllNotFoundException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\IO\FileShare.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\IO\FileStream.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\IO\IOException.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\IO\MemoryStream.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\IO\Path.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\IO\PathInternal.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\IO\PathTooLongException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\SynchronizationLockException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskCanceledException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskExtensions.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskToApm.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskSchedulerException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\ValueTask.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadAbortException.cs" />
diff --git a/src/mscorlib/shared/System/Diagnostics/DebuggableAttribute.cs b/src/mscorlib/shared/System/Diagnostics/DebuggableAttribute.cs
new file mode 100644 (file)
index 0000000..d05f847
--- /dev/null
@@ -0,0 +1,54 @@
+// 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.Diagnostics
+{
+    // Attribute class used by the compiler to mark modules.  
+    // If present, then debugging information for everything in the
+    // assembly was generated by the compiler, and will be preserved
+    // by the Runtime so that the debugger can provide full functionality
+    // in the case of JIT attach. If not present, then the compiler may
+    // or may not have included debugging information, and the Runtime
+    // won't preserve the debugging info, which will make debugging after
+    // a JIT attach difficult.
+    [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module, AllowMultiple = false)]
+    public sealed class DebuggableAttribute : Attribute
+    {
+        [Flags]
+        public enum DebuggingModes
+        {
+            None = 0x0,
+            Default = 0x1,
+            DisableOptimizations = 0x100,
+            IgnoreSymbolStoreSequencePoints = 0x2,
+            EnableEditAndContinue = 0x4
+        }
+
+        public DebuggableAttribute(bool isJITTrackingEnabled, bool isJITOptimizerDisabled)
+        {
+            DebuggingFlags = 0;
+
+            if (isJITTrackingEnabled)
+            {
+                DebuggingFlags |= DebuggingModes.Default;
+            }
+
+            if (isJITOptimizerDisabled)
+            {
+                DebuggingFlags |= DebuggingModes.DisableOptimizations;
+            }
+        }
+
+        public DebuggableAttribute(DebuggingModes modes)
+        {
+            DebuggingFlags = modes;
+        }
+
+        public bool IsJITTrackingEnabled => (DebuggingFlags & DebuggingModes.Default) != 0;
+
+        public bool IsJITOptimizerDisabled => (DebuggingFlags & DebuggingModes.DisableOptimizations) != 0;
+
+        public DebuggingModes DebuggingFlags { get; }
+    }
+}
diff --git a/src/mscorlib/shared/System/Diagnostics/DebuggerBrowsableAttribute.cs b/src/mscorlib/shared/System/Diagnostics/DebuggerBrowsableAttribute.cs
new file mode 100644 (file)
index 0000000..b9d6222
--- /dev/null
@@ -0,0 +1,41 @@
+// 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.Diagnostics
+{
+    //  DebuggerBrowsableState states are defined as follows:
+    //      Never       never show this element
+    //      Expanded    expansion of the class is done, so that all visible internal members are shown
+    //      Collapsed   expansion of the class is not performed. Internal visible members are hidden
+    //      RootHidden  The target element itself should not be shown, but should instead be 
+    //                  automatically expanded to have its members displayed.
+    //  Default value is collapsed
+
+    //  Please also change the code which validates DebuggerBrowsableState variable (in this file)
+    //  if you change this enum.
+    public enum DebuggerBrowsableState
+    {
+        Never = 0,
+        //Expanded is not supported in this release
+        //Expanded = 1, 
+        Collapsed = 2,
+        RootHidden = 3
+    }
+
+
+    // the one currently supported with the csee.dat 
+    // (mcee.dat, autoexp.dat) file. 
+    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
+    public sealed class DebuggerBrowsableAttribute : Attribute
+    {
+        public DebuggerBrowsableAttribute(DebuggerBrowsableState state)
+        {
+            if (state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden)
+                throw new ArgumentOutOfRangeException(nameof(state));
+
+            State = state;
+        }
+        public DebuggerBrowsableState State { get; }
+    }
+}
diff --git a/src/mscorlib/shared/System/Diagnostics/DebuggerDisplayAttribute.cs b/src/mscorlib/shared/System/Diagnostics/DebuggerDisplayAttribute.cs
new file mode 100644 (file)
index 0000000..7aae4b9
--- /dev/null
@@ -0,0 +1,51 @@
+// 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.Diagnostics
+{
+    // This attribute is used to control what is displayed for the given class or field 
+    // in the data windows in the debugger.  The single argument to this attribute is
+    // the string that will be displayed in the value column for instances of the type.  
+    // This string can include text between { and } which can be either a field, 
+    // property or method (as will be documented in mscorlib).  In the C# case, 
+    // a general expression will be allowed which only has implicit access to the this pointer 
+    // for the current instance of the target type. The expression will be limited, 
+    // however: there is no access to aliases, locals, or pointers. 
+    // In addition, attributes on properties referenced in the expression are not processed.
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Delegate | AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Assembly, AllowMultiple = true)]
+    public sealed class DebuggerDisplayAttribute : Attribute
+    {
+        private Type _target;
+
+        public DebuggerDisplayAttribute(string value)
+        {
+            Value = value ?? "";
+            Name = "";
+            Type = "";
+        }
+
+        public string Value { get; }
+
+        public string Name { get; set; }
+
+        public string Type { get; set; }
+
+        public Type Target
+        {
+            get => _target;
+            set
+            {
+                if (value == null)
+                {
+                    throw new ArgumentNullException(nameof(value));
+                }
+
+                TargetTypeName = value.AssemblyQualifiedName;
+                _target = value;
+            }
+        }
+
+        public string TargetTypeName { get; set; }
+    }
+}
diff --git a/src/mscorlib/shared/System/Diagnostics/DebuggerHiddenAttribute.cs b/src/mscorlib/shared/System/Diagnostics/DebuggerHiddenAttribute.cs
new file mode 100644 (file)
index 0000000..ace452e
--- /dev/null
@@ -0,0 +1,12 @@
+// 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.Diagnostics
+{
+    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor, Inherited = false)]
+    public sealed class DebuggerHiddenAttribute : Attribute
+    {
+        public DebuggerHiddenAttribute() { }
+    }
+}
diff --git a/src/mscorlib/shared/System/Diagnostics/DebuggerNonUserCodeAttribute.cs b/src/mscorlib/shared/System/Diagnostics/DebuggerNonUserCodeAttribute.cs
new file mode 100644 (file)
index 0000000..1b61cb7
--- /dev/null
@@ -0,0 +1,12 @@
+// 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.Diagnostics
+{
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor | AttributeTargets.Struct, Inherited = false)]
+    public sealed class DebuggerNonUserCodeAttribute : Attribute
+    {
+        public DebuggerNonUserCodeAttribute() { }
+    }
+}
diff --git a/src/mscorlib/shared/System/Diagnostics/DebuggerStepThroughAttribute.cs b/src/mscorlib/shared/System/Diagnostics/DebuggerStepThroughAttribute.cs
new file mode 100644 (file)
index 0000000..82a1647
--- /dev/null
@@ -0,0 +1,16 @@
+// 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.Diagnostics
+{
+#if PROJECTN
+    // Used by the IL2IL toolchain to mark generated code to control debugger stepping policy
+    [System.Runtime.CompilerServices.DependencyReductionRoot]
+#endif
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
+    public sealed class DebuggerStepThroughAttribute : Attribute
+    {
+        public DebuggerStepThroughAttribute() { }
+    }
+}
diff --git a/src/mscorlib/shared/System/Diagnostics/DebuggerStepperBoundaryAttribute.cs b/src/mscorlib/shared/System/Diagnostics/DebuggerStepperBoundaryAttribute.cs
new file mode 100644 (file)
index 0000000..647f2fd
--- /dev/null
@@ -0,0 +1,13 @@
+// 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.Diagnostics
+{
+    /// <summary>Indicates the code following the attribute is to be executed in run, not step, mode.</summary>
+    [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)]
+    public sealed class DebuggerStepperBoundaryAttribute : Attribute
+    {
+        public DebuggerStepperBoundaryAttribute() { }
+    }
+}
diff --git a/src/mscorlib/shared/System/Diagnostics/DebuggerTypeProxyAttribute.cs b/src/mscorlib/shared/System/Diagnostics/DebuggerTypeProxyAttribute.cs
new file mode 100644 (file)
index 0000000..445834e
--- /dev/null
@@ -0,0 +1,46 @@
+// 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.Diagnostics
+{
+    [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
+    public sealed class DebuggerTypeProxyAttribute : Attribute
+    {
+        private Type _target;
+
+        public DebuggerTypeProxyAttribute(Type type)
+        {
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
+
+            ProxyTypeName = type.AssemblyQualifiedName;
+        }
+
+        public DebuggerTypeProxyAttribute(string typeName)
+        {
+            ProxyTypeName = typeName;
+        }
+
+        public string ProxyTypeName { get; }
+
+        public Type Target
+        {
+            get => _target;
+            set
+            {
+                if (value == null)
+                {
+                    throw new ArgumentNullException(nameof(value));
+                }
+
+                TargetTypeName = value.AssemblyQualifiedName;
+                _target = value;
+            }        
+        }
+
+        public string TargetTypeName { get; set; }
+    }
+}
diff --git a/src/mscorlib/shared/System/Diagnostics/DebuggerVisualizerAttribute.cs b/src/mscorlib/shared/System/Diagnostics/DebuggerVisualizerAttribute.cs
new file mode 100644 (file)
index 0000000..032eca8
--- /dev/null
@@ -0,0 +1,97 @@
+// 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.Diagnostics
+{
+    /// <summary>
+    /// Signifies that the attributed type has a visualizer which is pointed
+    /// to by the parameter type name strings.
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
+    public sealed class DebuggerVisualizerAttribute : Attribute
+    {
+        private Type _target;
+
+        public DebuggerVisualizerAttribute(string visualizerTypeName)
+        {
+            VisualizerTypeName = visualizerTypeName;
+        }
+
+        public DebuggerVisualizerAttribute(string visualizerTypeName, string visualizerObjectSourceTypeName)
+        {
+            VisualizerTypeName = visualizerTypeName;
+            VisualizerObjectSourceTypeName = visualizerObjectSourceTypeName;
+        }
+
+        public DebuggerVisualizerAttribute(string visualizerTypeName, Type visualizerObjectSource)
+        {
+            if (visualizerObjectSource == null)
+            {
+                throw new ArgumentNullException(nameof(visualizerObjectSource));
+            }
+
+            VisualizerTypeName = visualizerTypeName;
+            VisualizerObjectSourceTypeName = visualizerObjectSource.AssemblyQualifiedName;
+        }
+
+        public DebuggerVisualizerAttribute(Type visualizer)
+        {
+            if (visualizer == null)
+            {
+                throw new ArgumentNullException(nameof(visualizer));
+            }
+
+            VisualizerTypeName = visualizer.AssemblyQualifiedName;
+        }
+
+        public DebuggerVisualizerAttribute(Type visualizer, Type visualizerObjectSource)
+        {
+            if (visualizer == null)
+            {
+                throw new ArgumentNullException(nameof(visualizer));
+            }
+            if (visualizerObjectSource == null)
+            {
+                throw new ArgumentNullException(nameof(visualizerObjectSource));
+            }
+
+            VisualizerTypeName = visualizer.AssemblyQualifiedName;
+            VisualizerObjectSourceTypeName = visualizerObjectSource.AssemblyQualifiedName;
+        }
+
+        public DebuggerVisualizerAttribute(Type visualizer, string visualizerObjectSourceTypeName)
+        {
+            if (visualizer == null)
+            {
+                throw new ArgumentNullException(nameof(visualizer));
+            }
+
+            VisualizerTypeName = visualizer.AssemblyQualifiedName;
+            VisualizerObjectSourceTypeName = visualizerObjectSourceTypeName;
+        }
+
+        public string VisualizerObjectSourceTypeName { get; }
+
+        public string VisualizerTypeName { get; }
+
+        public string Description { get; set; }
+        
+        public Type Target
+        {
+            get => _target;
+            set
+            {
+                if (value == null)
+                {
+                    throw new ArgumentNullException(nameof(value));
+                }
+
+                TargetTypeName = value.AssemblyQualifiedName;
+                _target = value;
+            }
+        }
+
+        public string TargetTypeName { get; set; }
+    }
+}
index ac756b6..c60ca5b 100644 (file)
@@ -55,9 +55,6 @@ namespace System.Diagnostics.Tracing
     /// <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>
@@ -68,9 +65,6 @@ namespace System.Diagnostics.Tracing
     /// <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>
@@ -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.
     /// </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>
similarity index 87%
rename from src/mscorlib/src/System/IO/MemoryStream.cs
rename to src/mscorlib/shared/System/IO/MemoryStream.cs
index 6039dc7..0af1237 100644 (file)
@@ -2,24 +2,9 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-/*============================================================
-**
-** 
-** 
-**
-**
-** Purpose: A Stream whose backing store is memory.  Great
-** for temporary storage without creating a temp file.  Also
-** lets users expose a byte[] as a stream.
-**
-**
-===========================================================*/
-
 using System;
-using System.Runtime;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
 using System.Diagnostics;
+using System.Runtime.CompilerServices;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -49,7 +34,7 @@ namespace System.IO
 
         private Task<int> _lastReadTask; // The last successful task returned from ReadAsync
 
-        private const int MemStreamMaxLength = Int32.MaxValue;
+        private const int MemStreamMaxLength = int.MaxValue;
 
         public MemoryStream()
             : this(0)
@@ -59,9 +44,7 @@ namespace System.IO
         public MemoryStream(int capacity)
         {
             if (capacity < 0)
-            {
                 throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_NegativeCapacity);
-            }
 
             _buffer = capacity != 0 ? new byte[capacity] : Array.Empty<byte>();
             _capacity = capacity;
@@ -79,7 +62,9 @@ namespace System.IO
 
         public MemoryStream(byte[] buffer, bool writable)
         {
-            if (buffer == null) throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer);
+            if (buffer == null)
+                throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer);
+
             _buffer = buffer;
             _length = _capacity = buffer.Length;
             _writable = writable;
@@ -118,24 +103,22 @@ namespace System.IO
             _isOpen = true;
         }
 
-        public override bool CanRead
-        {
-            get { return _isOpen; }
-        }
+        public override bool CanRead => _isOpen;
 
-        public override bool CanSeek
-        {
-            get { return _isOpen; }
-        }
+        public override bool CanSeek => _isOpen;
 
-        public override bool CanWrite
+        public override bool CanWrite => _writable;
+
+        private void EnsureNotClosed()
         {
-            get { return _writable; }
+            if (!_isOpen)
+                throw Error.GetStreamIsClosed();
         }
 
         private void EnsureWriteable()
         {
-            if (!CanWrite) __Error.WriteNotSupported();
+            if (!CanWrite)
+                throw Error.GetWriteNotSupported();
         }
 
         protected override void Dispose(bool disposing)
@@ -164,19 +147,28 @@ namespace System.IO
             // Check for overflow
             if (value < 0)
                 throw new IOException(SR.IO_StreamTooLong);
+
             if (value > _capacity)
             {
                 int newCapacity = value;
                 if (newCapacity < 256)
+                {
                     newCapacity = 256;
+                }
+
                 // We are ok with this overflowing since the next statement will deal
                 // with the cases where _capacity*2 overflows.
                 if (newCapacity < _capacity * 2)
+                {
                     newCapacity = _capacity * 2;
-                // We want to expand the array up to Array.MaxArrayLengthOneDimensional
+                }
+
+                // We want to expand the array up to Array.MaxByteArrayLength
                 // And we want to give the user the value that they asked for
                 if ((uint)(_capacity * 2) > Array.MaxByteArrayLength)
+                {
                     newCapacity = value > Array.MaxByteArrayLength ? value : Array.MaxByteArrayLength;
+                }
 
                 Capacity = newCapacity;
                 return true;
@@ -232,33 +224,22 @@ 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()
         {
-            if (!_isOpen) __Error.StreamIsClosed();
             return _position;
         }
 
         // PERF: Takes out Int32 as fast as possible
         internal int InternalReadInt32()
         {
-            if (!_isOpen)
-                __Error.StreamIsClosed();
+            EnsureNotClosed();
 
             int pos = (_position += 4); // use temp to avoid a race condition
             if (pos > _length)
             {
                 _position = _length;
-                __Error.EndOfFile();
+                throw Error.GetEndOfFile();
             }
             return (int)(_buffer[pos - 4] | _buffer[pos - 3] << 8 | _buffer[pos - 2] << 16 | _buffer[pos - 1] << 24);
         }
@@ -266,11 +247,13 @@ namespace System.IO
         // PERF: Get actual length of bytes available for read; do sanity checks; shift position - i.e. everything except actual copying bytes
         internal int InternalEmulateRead(int count)
         {
-            if (!_isOpen) __Error.StreamIsClosed();
+            EnsureNotClosed();
 
             int n = _length - _position;
-            if (n > count) n = count;
-            if (n < 0) n = 0;
+            if (n > count)
+                n = count;
+            if (n < 0)
+                n = 0;
 
             Debug.Assert(_position + n >= 0, "_position + n >= 0");  // len is less than 2^31 -1.
             _position += n;
@@ -285,17 +268,20 @@ namespace System.IO
         {
             get
             {
-                if (!_isOpen) __Error.StreamIsClosed();
+                EnsureNotClosed();
                 return _capacity - _origin;
             }
             set
             {
                 // Only update the capacity if the MS is expandable and the value is different than the current capacity.
                 // Special behavior if the MS isn't expandable: we don't throw if value is the same as the current capacity
-                if (value < Length) throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_SmallCapacity);
+                if (value < Length)
+                    throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_SmallCapacity);
 
-                if (!_isOpen) __Error.StreamIsClosed();
-                if (!_expandable && (value != Capacity)) __Error.MemoryStreamNotExpandable();
+                EnsureNotClosed();
+
+                if (!_expandable && (value != Capacity))
+                    throw new NotSupportedException(SR.NotSupported_MemStreamNotExpandable);
 
                 // MemoryStream has this invariant: _origin > 0 => !expandable (see ctors)
                 if (_expandable && value != _capacity)
@@ -303,7 +289,10 @@ namespace System.IO
                     if (value > 0)
                     {
                         byte[] newBuffer = new byte[value];
-                        if (_length > 0) Buffer.InternalBlockCopy(_buffer, 0, newBuffer, 0, _length);
+                        if (_length > 0)
+                        {
+                            Buffer.BlockCopy(_buffer, 0, newBuffer, 0, _length);
+                        }
                         _buffer = newBuffer;
                     }
                     else
@@ -319,7 +308,7 @@ namespace System.IO
         {
             get
             {
-                if (!_isOpen) __Error.StreamIsClosed();
+                EnsureNotClosed();
                 return _length - _origin;
             }
         }
@@ -328,7 +317,7 @@ namespace System.IO
         {
             get
             {
-                if (!_isOpen) __Error.StreamIsClosed();
+                EnsureNotClosed();
                 return _position - _origin;
             }
             set
@@ -336,7 +325,7 @@ namespace System.IO
                 if (value < 0)
                     throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_NeedNonNegNum);
 
-                if (!_isOpen) __Error.StreamIsClosed();
+                EnsureNotClosed();
 
                 if (value > MemStreamMaxLength)
                     throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_StreamLength);
@@ -344,7 +333,7 @@ namespace System.IO
             }
         }
 
-        public override int Read([In, Out] byte[] buffer, int offset, int count)
+        public override int Read(byte[] buffer, int offset, int count)
         {
             if (buffer == null)
                 throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer);
@@ -355,10 +344,11 @@ namespace System.IO
             if (buffer.Length - offset < count)
                 throw new ArgumentException(SR.Argument_InvalidOffLen);
 
-            if (!_isOpen) __Error.StreamIsClosed();
+            EnsureNotClosed();
 
             int n = _length - _position;
-            if (n > count) n = count;
+            if (n > count)
+                n = count;
             if (n <= 0)
                 return 0;
 
@@ -371,7 +361,7 @@ namespace System.IO
                     buffer[offset + byteCount] = _buffer[_position + byteCount];
             }
             else
-                Buffer.InternalBlockCopy(_buffer, _position, buffer, offset, n);
+                Buffer.BlockCopy(_buffer, _position, buffer, offset, n);
             _position += n;
 
             return n;
@@ -387,18 +377,13 @@ namespace System.IO
                 return base.Read(destination);
             }
 
-            if (!_isOpen)
-            {
-                __Error.StreamIsClosed();
-            }
+            EnsureNotClosed();
 
             int n = Math.Min(_length - _position, destination.Length);
             if (n <= 0)
-            {
                 return 0;
-            }
 
-            // TODO https://github.com/dotnet/corefx/issues/22388:
+            // TODO https://github.com/dotnet/coreclr/issues/15076:
             // Read(byte[], int, int) has an n <= 8 optimization, presumably based
             // on benchmarking.  Determine if/where such a cut-off is here and add
             // an equivalent optimization if necessary.
@@ -477,12 +462,12 @@ namespace System.IO
             }
         }
 
-
         public override int ReadByte()
         {
-            if (!_isOpen) __Error.StreamIsClosed();
+            EnsureNotClosed();
 
-            if (_position >= _length) return -1;
+            if (_position >= _length)
+                return -1;
 
             return _buffer[_position++];
         }
@@ -517,7 +502,7 @@ namespace System.IO
             }
         }
 
-        public override Task CopyToAsync(Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
+        public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
         {
             // This implementation offers beter performance compared to the base class version.
 
@@ -527,7 +512,7 @@ namespace System.IO
             // since it does not call through to ReadAsync() which a subclass might have overridden.  
             // To be safe we will only use this implementation in cases where we know it is safe to do so,
             // and delegate to our base class (which will call into ReadAsync) when we are not sure.
-            if (this.GetType() != typeof(MemoryStream))
+            if (GetType() != typeof(MemoryStream))
                 return base.CopyToAsync(destination, bufferSize, cancellationToken);
 
             // If cancelled - return fast:
@@ -538,8 +523,8 @@ namespace System.IO
             //   (require that InternalEmulateRead does not throw,
             //    otherwise it needs to be wrapped into try-catch-Task.FromException like memStrDest.Write below)
 
-            Int32 pos = _position;
-            Int32 n = InternalEmulateRead(_length - _position);
+            int pos = _position;
+            int n = InternalEmulateRead(_length - _position);
 
             // If we were already at or past the end, there's no copying to do so just quit.
             if (n == 0)
@@ -565,10 +550,11 @@ namespace System.IO
 
         public override long Seek(long offset, SeekOrigin loc)
         {
-            if (!_isOpen) __Error.StreamIsClosed();
+            EnsureNotClosed();
 
             if (offset > MemStreamMaxLength)
                 throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_StreamLength);
+
             switch (loc)
             {
                 case SeekOrigin.Begin:
@@ -605,41 +591,42 @@ namespace System.IO
 
         // Sets the length of the stream to a given value.  The new
         // value must be nonnegative and less than the space remaining in
-        // the array, Int32.MaxValue - origin
+        // the array, int.MaxValue - origin
         // Origin is 0 in all cases other than a MemoryStream created on
         // top of an existing array and a specific starting offset was passed 
         // into the MemoryStream constructor.  The upper bounds prevents any 
         // situations where a stream may be created on top of an array then 
         // the stream is made longer than the maximum possible length of the 
-        // array (Int32.MaxValue).
+        // array (int.MaxValue).
         // 
         public override void SetLength(long value)
         {
-            if (value < 0 || value > Int32.MaxValue)
-            {
+            if (value < 0 || value > int.MaxValue)
                 throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_StreamLength);
-            }
+
             EnsureWriteable();
 
             // Origin wasn't publicly exposed above.
-            Debug.Assert(MemStreamMaxLength == Int32.MaxValue);  // Check parameter validation logic in this method if this fails.
-            if (value > (Int32.MaxValue - _origin))
-            {
+            Debug.Assert(MemStreamMaxLength == int.MaxValue);  // Check parameter validation logic in this method if this fails.
+            if (value > (int.MaxValue - _origin))
                 throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_StreamLength);
-            }
 
             int newLength = _origin + (int)value;
             bool allocatedNewArray = EnsureCapacity(newLength);
             if (!allocatedNewArray && newLength > _length)
                 Array.Clear(_buffer, _length, newLength - _length);
             _length = newLength;
-            if (_position > newLength) _position = newLength;
+            if (_position > newLength)
+                _position = newLength;
         }
 
         public virtual byte[] ToArray()
         {
-            byte[] copy = new byte[_length - _origin];
-            Buffer.InternalBlockCopy(_buffer, _origin, copy, 0, _length - _origin);
+            int count = _length - _origin;
+            if (count == 0)
+                return Array.Empty<byte>();
+            byte[] copy = new byte[count];
+            Buffer.BlockCopy(_buffer, _origin, copy, 0, count);
             return copy;
         }
 
@@ -654,7 +641,7 @@ namespace System.IO
             if (buffer.Length - offset < count)
                 throw new ArgumentException(SR.Argument_InvalidOffLen);
 
-            if (!_isOpen) __Error.StreamIsClosed();
+            EnsureNotClosed();
             EnsureWriteable();
 
             int i = _position + count;
@@ -669,20 +656,28 @@ namespace System.IO
                 {
                     bool allocatedNewArray = EnsureCapacity(i);
                     if (allocatedNewArray)
+                    {
                         mustZero = false;
+                    }
                 }
                 if (mustZero)
+                {
                     Array.Clear(_buffer, _length, i - _length);
+                }
                 _length = i;
             }
             if ((count <= 8) && (buffer != _buffer))
             {
                 int byteCount = count;
                 while (--byteCount >= 0)
+                {
                     _buffer[_position + byteCount] = buffer[offset + byteCount];
+                }
             }
             else
-                Buffer.InternalBlockCopy(buffer, offset, _buffer, _position, count);
+            {
+                Buffer.BlockCopy(buffer, offset, _buffer, _position, count);
+            }
             _position = i;
         }
 
@@ -697,18 +692,13 @@ namespace System.IO
                 return;
             }
 
-            if (!_isOpen)
-            {
-                __Error.StreamIsClosed();
-            }
+            EnsureNotClosed();
             EnsureWriteable();
 
             // Check for overflow
             int i = _position + source.Length;
             if (i < 0)
-            {
                 throw new IOException(SR.IO_StreamTooLong);
-            }
 
             if (i > _length)
             {
@@ -795,7 +785,7 @@ namespace System.IO
 
         public override void WriteByte(byte value)
         {
-            if (!_isOpen) __Error.StreamIsClosed();
+            EnsureNotClosed();
             EnsureWriteable();
 
             if (_position >= _length)
@@ -806,10 +796,14 @@ namespace System.IO
                 {
                     bool allocatedNewArray = EnsureCapacity(newLength);
                     if (allocatedNewArray)
+                    {
                         mustZero = false;
+                    }
                 }
                 if (mustZero)
+                {
                     Array.Clear(_buffer, _length, _position - _length);
+                }
                 _length = newLength;
             }
             _buffer[_position++] = value;
@@ -821,7 +815,8 @@ namespace System.IO
             if (stream == null)
                 throw new ArgumentNullException(nameof(stream), SR.ArgumentNull_Stream);
 
-            if (!_isOpen) __Error.StreamIsClosed();
+            EnsureNotClosed();
+
             stream.Write(_buffer, _origin, _length - _origin);
         }
     }
index dc6f67b..9e1cfef 100644 (file)
@@ -231,12 +231,30 @@ namespace System.IO
             base.Dispose(disposing);
         }
 
+        private void EnsureNotClosed()
+        {
+            if (!_isOpen)
+                throw Error.GetStreamIsClosed();
+        }
+
+        private void EnsureReadable()
+        {
+            if (!CanRead)
+                throw Error.GetReadNotSupported();
+        }
+
+        private void EnsureWriteable()
+        {
+            if (!CanWrite)
+                throw Error.GetWriteNotSupported();
+        }
+
         /// <summary>
         /// Since it's a memory stream, this method does nothing.
         /// </summary>
         public override void Flush()
         {
-            if (!_isOpen) throw Error.GetStreamIsClosed();
+            EnsureNotClosed();
         }
 
         /// <summary>
@@ -267,7 +285,7 @@ namespace System.IO
         {
             get
             {
-                if (!_isOpen) throw Error.GetStreamIsClosed();
+                EnsureNotClosed();
                 return Interlocked.Read(ref _length);
             }
         }
@@ -279,7 +297,7 @@ namespace System.IO
         {
             get
             {
-                if (!_isOpen) throw Error.GetStreamIsClosed();
+                EnsureNotClosed();
                 return _capacity;
             }
         }
@@ -311,8 +329,10 @@ namespace System.IO
         {
             get
             {
-                if (_buffer != null) throw new NotSupportedException(SR.NotSupported_UmsSafeBuffer);
-                if (!_isOpen) throw Error.GetStreamIsClosed();
+                if (_buffer != null)
+                    throw new NotSupportedException(SR.NotSupported_UmsSafeBuffer);
+
+                EnsureNotClosed();
 
                 // Use a temp to avoid a race
                 long pos = Interlocked.Read(ref _position);
@@ -323,8 +343,10 @@ namespace System.IO
             }
             set
             {
-                if (_buffer != null) throw new NotSupportedException(SR.NotSupported_UmsSafeBuffer);
-                if (!_isOpen) throw Error.GetStreamIsClosed();
+                if (_buffer != null)
+                    throw new NotSupportedException(SR.NotSupported_UmsSafeBuffer);
+
+                EnsureNotClosed();
 
                 if (value < _mem)
                     throw new IOException(SR.IO_SeekBeforeBegin);
@@ -374,8 +396,8 @@ namespace System.IO
 
         internal int ReadCore(Span<byte> destination)
         {
-            if (!_isOpen) throw Error.GetStreamIsClosed();
-            if (!CanRead) throw Error.GetReadNotSupported();
+            EnsureNotClosed();
+            EnsureReadable();
 
             // Use a local variable to avoid a race where another thread 
             // changes our position after we decide we can read some bytes.
@@ -504,8 +526,8 @@ namespace System.IO
         /// <returns></returns>
         public override int ReadByte()
         {
-            if (!_isOpen) throw Error.GetStreamIsClosed();
-            if (!CanRead) throw Error.GetReadNotSupported();
+            EnsureNotClosed();
+            EnsureReadable();
 
             long pos = Interlocked.Read(ref _position);  // Use a local to avoid a race condition
             long len = Interlocked.Read(ref _length);
@@ -551,7 +573,8 @@ namespace System.IO
         /// <returns></returns>
         public override long Seek(long offset, SeekOrigin loc)
         {
-            if (!_isOpen) throw Error.GetStreamIsClosed();
+            EnsureNotClosed();
+
             switch (loc)
             {
                 case SeekOrigin.Begin:
@@ -593,8 +616,9 @@ namespace System.IO
                 throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_NeedNonNegNum);
             if (_buffer != null)
                 throw new NotSupportedException(SR.NotSupported_UmsSafeBuffer);
-            if (!_isOpen) throw Error.GetStreamIsClosed();
-            if (!CanWrite) throw Error.GetWriteNotSupported();
+
+            EnsureNotClosed();
+            EnsureWriteable();
 
             if (value > _capacity)
                 throw new IOException(SR.IO_FixedCapacity);
@@ -652,8 +676,8 @@ namespace System.IO
 
         internal unsafe void WriteCore(ReadOnlySpan<byte> source)
         {
-            if (!_isOpen) throw Error.GetStreamIsClosed();
-            if (!CanWrite) throw Error.GetWriteNotSupported();
+            EnsureNotClosed();
+            EnsureWriteable();
 
             long pos = Interlocked.Read(ref _position);  // Use a local to avoid a race condition
             long len = Interlocked.Read(ref _length);
@@ -792,8 +816,8 @@ namespace System.IO
         /// <param name="value"></param>
         public override void WriteByte(byte value)
         {
-            if (!_isOpen) throw Error.GetStreamIsClosed();
-            if (!CanWrite) throw Error.GetWriteNotSupported();
+            EnsureNotClosed();
+            EnsureWriteable();
 
             long pos = Interlocked.Read(ref _position);  // Use a local to avoid a race condition
             long len = Interlocked.Read(ref _length);
index a49f4a0..c3dc3a5 100644 (file)
@@ -15,11 +15,9 @@ namespace System
         private const int MaxUInt32HexDigits = 8;
         private const int MaxUInt32DecDigits = 10;
         private const int MaxUInt64DecDigits = 20;
-        private const int MinStringBufferSize = 105;
+        private const int CharStackBufferSize = 32;
         private const string PosNumberFormat = "#";
 
-        private static readonly char[] s_numberToStringScratch = new char[MinStringBufferSize];
-
         private static readonly string[] s_posCurrencyFormats =
         {
             "$#", "#$", "$ #", "# $"
@@ -74,7 +72,12 @@ namespace System
             {
                 NumberBuffer number = default;
                 Int32ToNumber(value, ref number);
-                var sb = new ValueStringBuilder(s_numberToStringScratch);
+                ValueStringBuilder sb;
+                unsafe
+                {
+                    char* stackPtr = stackalloc char[CharStackBufferSize];
+                    sb = new ValueStringBuilder(new Span<char>(stackPtr, CharStackBufferSize));
+                }
                 if (fmt != 0)
                 {
                     NumberToString(ref sb, ref number, fmt, digits, info, false);
@@ -109,7 +112,12 @@ namespace System
             {
                 NumberBuffer number = default;
                 Int32ToNumber(value, ref number);
-                var sb = new ValueStringBuilder(s_numberToStringScratch);
+                ValueStringBuilder sb;
+                unsafe
+                {
+                    char* stackPtr = stackalloc char[CharStackBufferSize];
+                    sb = new ValueStringBuilder(new Span<char>(stackPtr, CharStackBufferSize));
+                }
                 if (fmt != 0)
                 {
                     NumberToString(ref sb, ref number, fmt, digits, info, false);
@@ -142,7 +150,12 @@ namespace System
             {
                 NumberBuffer number = default;
                 UInt32ToNumber(value, ref number);
-                var sb = new ValueStringBuilder(s_numberToStringScratch);
+                ValueStringBuilder sb;
+                unsafe
+                {
+                    char* stackPtr = stackalloc char[CharStackBufferSize];
+                    sb = new ValueStringBuilder(new Span<char>(stackPtr, CharStackBufferSize));
+                }
                 if (fmt != 0)
                 {
                     NumberToString(ref sb, ref number, fmt, digits, info, false);
@@ -175,7 +188,12 @@ namespace System
             {
                 NumberBuffer number = default;
                 UInt32ToNumber(value, ref number);
-                var sb = new ValueStringBuilder(s_numberToStringScratch);
+                ValueStringBuilder sb;
+                unsafe
+                {
+                    char* stackPtr = stackalloc char[CharStackBufferSize];
+                    sb = new ValueStringBuilder(new Span<char>(stackPtr, CharStackBufferSize));
+                }
                 if (fmt != 0)
                 {
                     NumberToString(ref sb, ref number, fmt, digits, info, false);
@@ -211,7 +229,12 @@ namespace System
             {
                 NumberBuffer number = default;
                 Int64ToNumber(value, ref number);
-                var sb = new ValueStringBuilder(s_numberToStringScratch);
+                ValueStringBuilder sb;
+                unsafe
+                {
+                    char* stackPtr = stackalloc char[CharStackBufferSize];
+                    sb = new ValueStringBuilder(new Span<char>(stackPtr, CharStackBufferSize));
+                }
                 if (fmt != 0)
                 {
                     NumberToString(ref sb, ref number, fmt, digits, info, false);
@@ -247,7 +270,12 @@ namespace System
             {
                 NumberBuffer number = default;
                 Int64ToNumber(value, ref number);
-                var sb = new ValueStringBuilder(s_numberToStringScratch);
+                ValueStringBuilder sb;
+                unsafe
+                {
+                    char* stackPtr = stackalloc char[CharStackBufferSize];
+                    sb = new ValueStringBuilder(new Span<char>(stackPtr, CharStackBufferSize));
+                }
                 if (fmt != 0)
                 {
                     NumberToString(ref sb, ref number, fmt, digits, info, false);
@@ -281,7 +309,12 @@ namespace System
             {
                 NumberBuffer number = default;
                 UInt64ToNumber(value, ref number);
-                var sb = new ValueStringBuilder(s_numberToStringScratch);
+                ValueStringBuilder sb;
+                unsafe
+                {
+                    char* stackPtr = stackalloc char[CharStackBufferSize];
+                    sb = new ValueStringBuilder(new Span<char>(stackPtr, CharStackBufferSize));
+                }
                 if (fmt != 0)
                 {
                     NumberToString(ref sb, ref number, fmt, digits, info, false);
@@ -315,7 +348,12 @@ namespace System
             {
                 NumberBuffer number = default;
                 UInt64ToNumber(value, ref number);
-                var sb = new ValueStringBuilder(s_numberToStringScratch);
+                ValueStringBuilder sb;
+                unsafe
+                {
+                    char* stackPtr = stackalloc char[CharStackBufferSize];
+                    sb = new ValueStringBuilder(new Span<char>(stackPtr, CharStackBufferSize));
+                }
                 if (fmt != 0)
                 {
                     NumberToString(ref sb, ref number, fmt, digits, info, false);
index be80c6d..3daed13 100644 (file)
@@ -72,7 +72,7 @@ namespace System
         {
             get
             {
-                if ((_objectName == null)) // && !CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
+                if (_objectName == null)
                 {
                     return String.Empty;
                 }
index 0ee9c81..f9f6bb7 100644 (file)
@@ -167,7 +167,7 @@ namespace System.Text
             _chars = _arrayToReturnToPool = poolArray;
             if (toReturn != null)
             {
-                ArrayPool<char>.Shared.Return(_arrayToReturnToPool);
+                ArrayPool<char>.Shared.Return(toReturn);
             }
         }
     }
@@ -2,13 +2,10 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
-//
-//
-//
 // Helper methods for using Tasks to implement the APM pattern.
 //
 // Example usage, wrapping a Task<int>-returning FooAsync method with Begin/EndFoo methods:
+//
 //     public IAsyncResult BeginFoo(..., AsyncCallback callback, object state)
 //     {
 //         Task<int> t = FooAsync(...);
 //     {
 //         return TaskToApm.End<int>(asyncResult);
 //     }
-//
-// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
-using System.IO;
 using System.Diagnostics;
 
 namespace System.Threading.Tasks
@@ -48,19 +42,19 @@ namespace System.Threading.Tasks
             IAsyncResult asyncResult;
             if (task.IsCompleted)
             {
-                // Synchronous completion
+                // Synchronous completion.
                 asyncResult = new TaskWrapperAsyncResult(task, state, completedSynchronously: true);
-                if (callback != null)
-                    callback(asyncResult);
+                callback?.Invoke(asyncResult);
             }
-            // Otherwise, we need to schedule a callback.  Whether we can use the Task as the IAsyncResult
-            // depends on whether the Task's AsyncState has reference equality with the requested state.
             else
             {
-                // Asynchronous completion
+                // For asynchronous completion we need to schedule a callback.  Whether we can use the Task as the IAsyncResult
+                // depends on whether the Task's AsyncState has reference equality with the requested state.
                 asyncResult = task.AsyncState == state ? (IAsyncResult)task : new TaskWrapperAsyncResult(task, state, completedSynchronously: false);
                 if (callback != null)
+                {
                     InvokeCallbackWhenTaskCompletes(task, callback, asyncResult);
+                }
             }
             return asyncResult;
         }
@@ -78,15 +72,18 @@ namespace System.Threading.Tasks
                 task = twar.Task;
                 Debug.Assert(task != null, "TaskWrapperAsyncResult should never wrap a null Task.");
             }
-            // Otherwise, the IAsyncResult should be a Task.
             else
             {
+                // Otherwise, the IAsyncResult should be a Task.
                 task = asyncResult as Task;
             }
 
             // Make sure we actually got a task, then complete the operation by waiting on it.
             if (task == null)
-                __Error.WrongAsyncResult();
+            {
+                throw new ArgumentNullException();
+            }
+
             task.GetAwaiter().GetResult();
         }
 
@@ -103,15 +100,18 @@ namespace System.Threading.Tasks
                 task = twar.Task as Task<TResult>;
                 Debug.Assert(twar.Task != null, "TaskWrapperAsyncResult should never wrap a null Task.");
             }
-            // Otherwise, the IAsyncResult should be a Task<TResult>.
             else
             {
+                // Otherwise, the IAsyncResult should be a Task<TResult>.
                 task = asyncResult as Task<TResult>;
             }
 
             // Make sure we actually got a task, then complete the operation by waiting on it.
             if (task == null)
-                __Error.WrongAsyncResult();
+            {
+                throw new ArgumentNullException();
+            }
+
             return task.GetAwaiter().GetResult();
         }
 
@@ -158,9 +158,9 @@ namespace System.Threading.Tasks
             /// <summary>The wrapped Task.</summary>
             internal readonly Task Task;
             /// <summary>The new AsyncState value.</summary>
-            private readonly object m_state;
+            private readonly object _state;
             /// <summary>The new CompletedSynchronously value.</summary>
-            private readonly bool m_completedSynchronously;
+            private readonly bool _completedSynchronously;
 
             /// <summary>Initializes the IAsyncResult with the Task to wrap and the overriding AsyncState and CompletedSynchronously values.</summary>
             /// <param name="task">The Task to wrap.</param>
@@ -172,16 +172,16 @@ namespace System.Threading.Tasks
                 Debug.Assert(!completedSynchronously || task.IsCompleted, "If completedSynchronously is true, the task must be completed.");
 
                 this.Task = task;
-                m_state = state;
-                m_completedSynchronously = completedSynchronously;
+                _state = state;
+                _completedSynchronously = completedSynchronously;
             }
 
             // The IAsyncResult implementation.  
             // - IsCompleted and AsyncWaitHandle just pass through to the Task.
             // - AsyncState and CompletedSynchronously return the corresponding values stored in this object.
 
-            object IAsyncResult.AsyncState { get { return m_state; } }
-            bool IAsyncResult.CompletedSynchronously { get { return m_completedSynchronously; } }
+            object IAsyncResult.AsyncState { get { return _state; } }
+            bool IAsyncResult.CompletedSynchronously { get { return _completedSynchronously; } }
             bool IAsyncResult.IsCompleted { get { return this.Task.IsCompleted; } }
             WaitHandle IAsyncResult.AsyncWaitHandle { get { return ((IAsyncResult)this.Task).AsyncWaitHandle; } }
         }
index 302d623..813b2b5 100644 (file)
@@ -242,8 +242,6 @@ namespace System
             // case where the compat flags have been setup.
             Debug.Assert(!_compatFlagsInitialized);
             _compatFlagsInitialized = true;
-
-            CompatibilitySwitches.InitializeSwitches();
         }
 
         /// <summary>
index 4fef6f9..9d4d693 100644 (file)
@@ -35,14 +35,6 @@ namespace System
         public static extern void BlockCopy(Array src, int srcOffset,
             Array dst, int dstOffset, int count);
 
-        // A very simple and efficient memmove that assumes all of the
-        // parameter validation has already been done.  The count and offset
-        // parameters here are in bytes.  If you want to use traditional
-        // array element indices and counts, use Array.Copy.
-        [MethodImplAttribute(MethodImplOptions.InternalCall)]
-        internal static extern void InternalBlockCopy(Array src, int srcOffsetBytes,
-            Array dst, int dstOffsetBytes, int byteCount);
-
         // This is ported from the optimized CRT assembly in memchr.asm. The JIT generates 
         // pretty good code here and this ends up being within a couple % of the CRT asm.
         // It is however cross platform as the CRT hasn't ported their fast version to 64-bit
@@ -243,7 +235,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 (file)
index 58dd640..0000000
+++ /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/DebuggerAttributes.cs b/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs
deleted file mode 100644 (file)
index 035f809..0000000
+++ /dev/null
@@ -1,260 +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.
-
-/*============================================================
-**
-**
-**
-** Purpose: Attributes for debugger
-**
-**
-===========================================================*/
-
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace System.Diagnostics
-{
-    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
-    public sealed class DebuggerStepThroughAttribute : Attribute
-    {
-        public DebuggerStepThroughAttribute() { }
-    }
-
-    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor, Inherited = false)]
-    public sealed class DebuggerHiddenAttribute : Attribute
-    {
-        public DebuggerHiddenAttribute() { }
-    }
-
-    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor | AttributeTargets.Struct, Inherited = false)]
-    public sealed class DebuggerNonUserCodeAttribute : Attribute
-    {
-        public DebuggerNonUserCodeAttribute() { }
-    }
-
-    // Attribute class used by the compiler to mark modules.  
-    // If present, then debugging information for everything in the
-    // assembly was generated by the compiler, and will be preserved
-    // by the Runtime so that the debugger can provide full functionality
-    // in the case of JIT attach. If not present, then the compiler may
-    // or may not have included debugging information, and the Runtime
-    // won't preserve the debugging info, which will make debugging after
-    // a JIT attach difficult.
-    [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module, AllowMultiple = false)]
-    public sealed class DebuggableAttribute : Attribute
-    {
-        [Flags]
-        public enum DebuggingModes
-        {
-            None = 0x0,
-            Default = 0x1,
-            DisableOptimizations = 0x100,
-            IgnoreSymbolStoreSequencePoints = 0x2,
-            EnableEditAndContinue = 0x4
-        }
-
-        private DebuggingModes m_debuggingModes;
-
-        public DebuggableAttribute(bool isJITTrackingEnabled,
-                                   bool isJITOptimizerDisabled)
-        {
-            m_debuggingModes = 0;
-
-            if (isJITTrackingEnabled)
-            {
-                m_debuggingModes |= DebuggingModes.Default;
-            }
-
-            if (isJITOptimizerDisabled)
-            {
-                m_debuggingModes |= DebuggingModes.DisableOptimizations;
-            }
-        }
-
-        public DebuggableAttribute(DebuggingModes modes)
-        {
-            m_debuggingModes = modes;
-        }
-
-        public bool IsJITTrackingEnabled
-        {
-            get { return ((m_debuggingModes & DebuggingModes.Default) != 0); }
-        }
-
-        public bool IsJITOptimizerDisabled
-        {
-            get { return ((m_debuggingModes & DebuggingModes.DisableOptimizations) != 0); }
-        }
-
-        public DebuggingModes DebuggingFlags
-        {
-            get { return m_debuggingModes; }
-        }
-    }
-
-    //  DebuggerBrowsableState states are defined as follows:
-    //      Never       never show this element
-    //      Expanded    expansion of the class is done, so that all visible internal members are shown
-    //      Collapsed   expansion of the class is not performed. Internal visible members are hidden
-    //      RootHidden  The target element itself should not be shown, but should instead be 
-    //                  automatically expanded to have its members displayed.
-    //  Default value is collapsed
-
-    //  Please also change the code which validates DebuggerBrowsableState variable (in this file)
-    //  if you change this enum.
-    public enum DebuggerBrowsableState
-    {
-        Never = 0,
-        //Expanded is not supported in this release
-        //Expanded = 1, 
-        Collapsed = 2,
-        RootHidden = 3
-    }
-
-
-    // the one currently supported with the csee.dat 
-    // (mcee.dat, autoexp.dat) file. 
-    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
-    public sealed class DebuggerBrowsableAttribute : Attribute
-    {
-        private DebuggerBrowsableState state;
-        public DebuggerBrowsableAttribute(DebuggerBrowsableState state)
-        {
-            if (state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden)
-                throw new ArgumentOutOfRangeException(nameof(state));
-
-            this.state = state;
-        }
-        public DebuggerBrowsableState State
-        {
-            get { return state; }
-        }
-    }
-
-
-    // DebuggerTypeProxyAttribute
-    [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
-    public sealed class DebuggerTypeProxyAttribute : Attribute
-    {
-        private string typeName;
-        private string targetName;
-        private Type target;
-
-        public DebuggerTypeProxyAttribute(Type type)
-        {
-            if (type == null)
-            {
-                throw new ArgumentNullException(nameof(type));
-            }
-
-            typeName = type.AssemblyQualifiedName;
-        }
-
-        public DebuggerTypeProxyAttribute(string typeName)
-        {
-            this.typeName = typeName;
-        }
-        public string ProxyTypeName
-        {
-            get { return typeName; }
-        }
-
-        public Type Target
-        {
-            set
-            {
-                if (value == null)
-                {
-                    throw new ArgumentNullException(nameof(value));
-                }
-
-                targetName = value.AssemblyQualifiedName;
-                target = value;
-            }
-
-            get { return target; }
-        }
-
-        public string TargetTypeName
-        {
-            get { return targetName; }
-            set { targetName = value; }
-        }
-    }
-
-    // This attribute is used to control what is displayed for the given class or field 
-    // in the data windows in the debugger.  The single argument to this attribute is
-    // the string that will be displayed in the value column for instances of the type.  
-    // This string can include text between { and } which can be either a field, 
-    // property or method (as will be documented in mscorlib).  In the C# case, 
-    // a general expression will be allowed which only has implicit access to the this pointer 
-    // for the current instance of the target type. The expression will be limited, 
-    // however: there is no access to aliases, locals, or pointers. 
-    // In addition, attributes on properties referenced in the expression are not processed.
-    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Delegate | AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Assembly, AllowMultiple = true)]
-    public sealed class DebuggerDisplayAttribute : Attribute
-    {
-        private string name;
-        private string value;
-        private string type;
-        private string targetName;
-        private Type target;
-
-        public DebuggerDisplayAttribute(string value)
-        {
-            if (value == null)
-            {
-                this.value = "";
-            }
-            else
-            {
-                this.value = value;
-            }
-            name = "";
-            type = "";
-        }
-
-        public string Value
-        {
-            get { return value; }
-        }
-
-        public string Name
-        {
-            get { return name; }
-            set { name = value; }
-        }
-
-        public string Type
-        {
-            get { return type; }
-            set { type = value; }
-        }
-
-        public Type Target
-        {
-            set
-            {
-                if (value == null)
-                {
-                    throw new ArgumentNullException(nameof(value));
-                }
-
-                targetName = value.AssemblyQualifiedName;
-                target = value;
-            }
-            get { return target; }
-        }
-
-        public string TargetTypeName
-        {
-            get { return targetName; }
-            set { targetName = value; }
-        }
-    }
-}
-
-
index d746f58..1afe82d 100644 (file)
@@ -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
         }
 
         /// <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>
@@ -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;
index 3de41ca..625f006 100644 (file)
@@ -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;
index c5cd6cb..05de184 100644 (file)
@@ -117,7 +117,7 @@ namespace System.IO
 
         public virtual int PeekChar()
         {
-            if (_stream == null) __Error.FileNotOpen();
+            if (_stream == null) throw Error.GetFileNotOpen();
 
             if (!_stream.CanSeek)
                 return -1;
@@ -131,7 +131,7 @@ namespace System.IO
         {
             if (_stream == null)
             {
-                __Error.FileNotOpen();
+                throw Error.GetFileNotOpen();
             }
             return InternalReadOneChar();
         }
@@ -145,11 +145,11 @@ namespace System.IO
         public virtual byte ReadByte()
         {
             // Inlined to avoid some method call overhead with FillBuffer.
-            if (_stream == null) __Error.FileNotOpen();
+            if (_stream == null) throw Error.GetFileNotOpen();
 
             int b = _stream.ReadByte();
             if (b == -1)
-                __Error.EndOfFile();
+                throw Error.GetEndOfFile();
             return (byte)b;
         }
 
@@ -165,7 +165,7 @@ namespace System.IO
             int value = Read();
             if (value == -1)
             {
-                __Error.EndOfFile();
+                throw Error.GetEndOfFile();
             }
             return (char)value;
         }
@@ -187,7 +187,7 @@ namespace System.IO
         {
             if (_isMemoryStream)
             {
-                if (_stream == null) __Error.FileNotOpen();
+                if (_stream == null) throw Error.GetFileNotOpen();
                 // read directly from MemoryStream buffer
                 MemoryStream mStream = _stream as MemoryStream;
                 Debug.Assert(mStream != null, "_stream as MemoryStream != null");
@@ -265,7 +265,7 @@ namespace System.IO
         public virtual String ReadString()
         {
             if (_stream == null)
-                __Error.FileNotOpen();
+                throw Error.GetFileNotOpen();
 
             int currPos = 0;
             int n;
@@ -303,7 +303,7 @@ namespace System.IO
                 n = _stream.Read(_charBytes, 0, readLength);
                 if (n == 0)
                 {
-                    __Error.EndOfFile();
+                    throw Error.GetEndOfFile();
                 }
 
                 charsRead = _decoder.GetChars(_charBytes, 0, n, _charBuffer, 0);
@@ -340,7 +340,7 @@ namespace System.IO
             }
 
             if (_stream == null)
-                __Error.FileNotOpen();
+                throw Error.GetFileNotOpen();
 
             // SafeCritical: index and count have already been verified to be a valid range for the buffer
             return InternalReadChars(new Span<char>(buffer, index, count));
@@ -349,7 +349,7 @@ namespace System.IO
         public virtual int Read(Span<char> buffer)
         {
             if (_stream == null)
-                __Error.FileNotOpen();
+                throw Error.GetFileNotOpen();
 
             return InternalReadChars(buffer);
         }
@@ -524,7 +524,7 @@ namespace System.IO
             }
             if (_stream == null)
             {
-                __Error.FileNotOpen();
+                throw Error.GetFileNotOpen();
             }
 
             if (count == 0)
@@ -538,7 +538,7 @@ namespace System.IO
             if (n != count)
             {
                 char[] copy = new char[n];
-                Buffer.InternalBlockCopy(chars, 0, copy, 0, 2 * n); // sizeof(char)
+                Buffer.BlockCopy(chars, 0, copy, 0, 2 * n); // sizeof(char)
                 chars = copy;
             }
 
@@ -556,14 +556,14 @@ namespace System.IO
             if (buffer.Length - index < count)
                 throw new ArgumentException(SR.Argument_InvalidOffLen);
 
-            if (_stream == null) __Error.FileNotOpen();
+            if (_stream == null) throw Error.GetFileNotOpen();
             return _stream.Read(buffer, index, count);
         }
 
         public virtual int Read(Span<byte> buffer)
         {
             if (_stream == null)
-                __Error.FileNotOpen();
+                throw Error.GetFileNotOpen();
 
             return _stream.Read(buffer);
         }
@@ -571,7 +571,7 @@ namespace System.IO
         public virtual byte[] ReadBytes(int count)
         {
             if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
-            if (_stream == null) __Error.FileNotOpen();
+            if (_stream == null) throw Error.GetFileNotOpen();
 
             if (count == 0)
             {
@@ -594,7 +594,7 @@ namespace System.IO
             {
                 // Trim array.  This should happen on EOF & possibly net streams.
                 byte[] copy = new byte[numRead];
-                Buffer.InternalBlockCopy(result, 0, copy, 0, numRead);
+                Buffer.BlockCopy(result, 0, copy, 0, numRead);
                 result = copy;
             }
 
@@ -610,7 +610,7 @@ namespace System.IO
             int bytesRead = 0;
             int n = 0;
 
-            if (_stream == null) __Error.FileNotOpen();
+            if (_stream == null) throw Error.GetFileNotOpen();
 
             // Need to find a good threshold for calling ReadByte() repeatedly
             // vs. calling Read(byte[], int, int) for both buffered & unbuffered
@@ -619,7 +619,7 @@ namespace System.IO
             {
                 n = _stream.ReadByte();
                 if (n == -1)
-                    __Error.EndOfFile();
+                    throw Error.GetEndOfFile();
                 _buffer[0] = (byte)n;
                 return;
             }
@@ -629,7 +629,7 @@ namespace System.IO
                 n = _stream.Read(_buffer, bytesRead, numBytes - bytesRead);
                 if (n == 0)
                 {
-                    __Error.EndOfFile();
+                    throw Error.GetEndOfFile();
                 }
                 bytesRead += n;
             } while (bytesRead < numBytes);
index 6754baa..2b2506c 100644 (file)
@@ -99,7 +99,7 @@ namespace System.IO
                 {
                     int n = fs.Read(bytes, index, count);
                     if (n == 0)
-                        __Error.EndOfFile();
+                        throw Error.GetEndOfFile();
                     index += n;
                     count -= n;
                 }
index b8df5aa..477fe8b 100644 (file)
@@ -284,7 +284,7 @@ namespace System.IO
             byte[] buffer, int offset, int count, AsyncCallback callback, Object state,
             bool serializeAsynchronously, bool apm)
         {
-            if (!CanRead) __Error.ReadNotSupported();
+            if (!CanRead) throw Error.GetReadNotSupported();
 
             // To avoid a race with a stream's position pointer & generating race conditions 
             // with internal buffer indexes in our own streams that 
@@ -449,7 +449,7 @@ namespace System.IO
             byte[] buffer, int offset, int count, AsyncCallback callback, Object state,
             bool serializeAsynchronously, bool apm)
         {
-            if (!CanWrite) __Error.WriteNotSupported();
+            if (!CanWrite) throw Error.GetWriteNotSupported();
 
             // To avoid a race condition with a stream's position pointer & generating conditions 
             // with internal buffer indexes in our own streams that 
@@ -747,7 +747,7 @@ namespace System.IO
 
         public abstract void SetLength(long value);
 
-        public abstract int Read([In, Out] byte[] buffer, int offset, int count);
+        public abstract int Read(byte[] buffer, int offset, int count);
 
         public virtual int Read(Span<byte> destination)
         {
@@ -950,7 +950,7 @@ namespace System.IO
 
             public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, Object state)
             {
-                if (!CanRead) __Error.ReadNotSupported();
+                if (!CanRead) throw Error.GetReadNotSupported();
 
                 return BlockingBeginRead(buffer, offset, count, callback, state);
             }
@@ -965,7 +965,7 @@ namespace System.IO
 
             public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, Object state)
             {
-                if (!CanWrite) __Error.WriteNotSupported();
+                if (!CanWrite) throw Error.GetWriteNotSupported();
 
                 return BlockingBeginWrite(buffer, offset, count, callback, state);
             }
@@ -978,7 +978,7 @@ namespace System.IO
                 BlockingEndWrite(asyncResult);
             }
 
-            public override int Read([In, Out] byte[] buffer, int offset, int count)
+            public override int Read(byte[] buffer, int offset, int count)
             {
                 return 0;
             }
@@ -1105,10 +1105,10 @@ namespace System.IO
             {
                 SynchronousAsyncResult ar = asyncResult as SynchronousAsyncResult;
                 if (ar == null || ar._isWrite)
-                    __Error.WrongAsyncResult();
+                    throw new ArgumentException(SR.Arg_WrongAsyncResult);
 
                 if (ar._endXxxCalled)
-                    __Error.EndReadCalledTwice();
+                    throw new ArgumentException(SR.InvalidOperation_EndReadCalledMultiple);
 
                 ar._endXxxCalled = true;
 
@@ -1120,10 +1120,10 @@ namespace System.IO
             {
                 SynchronousAsyncResult ar = asyncResult as SynchronousAsyncResult;
                 if (ar == null || !ar._isWrite)
-                    __Error.WrongAsyncResult();
+                    throw new ArgumentException(SR.Arg_WrongAsyncResult);
 
                 if (ar._endXxxCalled)
-                    __Error.EndWriteCalledTwice();
+                    throw new ArgumentException(SR.InvalidOperation_EndWriteCalledMultiple);
 
                 ar._endXxxCalled = true;
 
@@ -1261,7 +1261,7 @@ namespace System.IO
                     _stream.Flush();
             }
 
-            public override int Read([In, Out]byte[] bytes, int offset, int count)
+            public override int Read(byte[] bytes, int offset, int count)
             {
                 lock (_stream)
                     return _stream.Read(bytes, offset, count);
index 092bf69..605a5f9 100644 (file)
@@ -287,7 +287,7 @@ namespace System.IO
         public bool EndOfStream {
             get {
                 if (stream == null)
-                    __Error.ReaderClosed();
+                    throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
 
                 CheckAsyncTaskInProgress();
 
@@ -302,7 +302,7 @@ namespace System.IO
 
         public override int Peek() {
             if (stream == null)
-                __Error.ReaderClosed();
+                throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
 
             CheckAsyncTaskInProgress();
 
@@ -315,7 +315,7 @@ namespace System.IO
         
         public override int Read() {
             if (stream == null)
-                __Error.ReaderClosed();
+                throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
 
             CheckAsyncTaskInProgress();
 
@@ -327,7 +327,7 @@ namespace System.IO
             return result;
         }
     
-        public override int Read([In, Out] char[] buffer, int index, int count)
+        public override int Read(char[] buffer, int index, int count)
         {
             if (buffer==null)
                 throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer);
@@ -337,7 +337,7 @@ namespace System.IO
                 throw new ArgumentException(SR.Argument_InvalidOffLen);
 
             if (stream == null)
-                __Error.ReaderClosed();
+                throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
 
             CheckAsyncTaskInProgress();
 
@@ -351,7 +351,7 @@ namespace System.IO
                 if (n == 0) break;  // We're at EOF
                 if (n > count) n = count;
                 if (!readToUserBuffer) {
-                    Buffer.InternalBlockCopy(charBuffer, charPos * 2, buffer, (index + charsRead) * 2, n*2);
+                    Buffer.BlockCopy(charBuffer, charPos * 2, buffer, (index + charsRead) * 2, n*2);
                     charPos += n;
                 }
                 charsRead += n;
@@ -369,7 +369,7 @@ namespace System.IO
         public override String ReadToEnd()
         {
             if (stream == null)
-                __Error.ReaderClosed();
+                throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
 
             CheckAsyncTaskInProgress();
 
@@ -384,7 +384,7 @@ namespace System.IO
             return GetStringAndReleaseSharedStringBuilder(sb);
         }
 
-        public override int ReadBlock([In, Out] char[] buffer, int index, int count)
+        public override int ReadBlock(char[] buffer, int index, int count)
         {
             if (buffer==null)
                 throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer);
@@ -394,7 +394,7 @@ namespace System.IO
                 throw new ArgumentException(SR.Argument_InvalidOffLen);
 
             if (stream == null)
-                __Error.ReaderClosed();
+                throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
 
             CheckAsyncTaskInProgress();
 
@@ -405,7 +405,7 @@ namespace System.IO
         private void CompressBuffer(int n)
         {
             Debug.Assert(byteLen >= n, "CompressBuffer was called with a number of bytes greater than the current buffer length.  Are two threads using this StreamReader at the same time?");
-            Buffer.InternalBlockCopy(byteBuffer, n, byteBuffer, 0, byteLen - n);
+            Buffer.BlockCopy(byteBuffer, n, byteBuffer, 0, byteLen - n);
             byteLen -= n;
         }
 
@@ -704,7 +704,7 @@ namespace System.IO
         public override String ReadLine()
         {
             if (stream == null)
-                __Error.ReaderClosed();
+                throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
 
             CheckAsyncTaskInProgress();
 
@@ -755,7 +755,7 @@ namespace System.IO
                 return base.ReadLineAsync();
 
             if (stream == null)
-                __Error.ReaderClosed();
+                throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
 
             CheckAsyncTaskInProgress();
 
@@ -834,7 +834,7 @@ namespace System.IO
                 return base.ReadToEndAsync();
 
             if (stream == null)
-                __Error.ReaderClosed();
+                throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
 
             CheckAsyncTaskInProgress();
 
@@ -876,7 +876,7 @@ namespace System.IO
                 return base.ReadAsync(buffer, index, count);
 
             if (stream == null)
-                __Error.ReaderClosed();
+                throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
 
             CheckAsyncTaskInProgress();
 
@@ -1027,7 +1027,7 @@ namespace System.IO
 
                 if (!readToUserBuffer)
                 {
-                    Buffer.InternalBlockCopy(charBuffer, charPos * 2, buffer, (index + charsRead) * 2, n * 2);
+                    Buffer.BlockCopy(charBuffer, charPos * 2, buffer, (index + charsRead) * 2, n * 2);
                     charPos += n;
                 }
 
@@ -1061,7 +1061,7 @@ namespace System.IO
                 return base.ReadBlockAsync(buffer, index, count);
 
             if (stream == null)
-                __Error.ReaderClosed();
+                throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
 
             CheckAsyncTaskInProgress();
 
index 9ef4f9f..868d08a 100644 (file)
@@ -84,7 +84,7 @@ namespace System.IO {
         // buffer character array starting at position
         // index. Returns the actual number of characters read.
         //
-        public virtual int Read([In, Out] char[] buffer, int index, int count) 
+        public virtual int Read(char[] buffer, int index, int count) 
         {
             if (buffer==null)
                 throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer);
@@ -121,7 +121,7 @@ namespace System.IO {
         // Blocking version of read.  Returns only when count
         // characters have been read or the end of the file was reached.
         // 
-        public virtual int ReadBlock([In, Out] char[] buffer, int index, int count) 
+        public virtual int ReadBlock(char[] buffer, int index, int count) 
         {
             int i, n = 0;
             do {
@@ -297,13 +297,13 @@ namespace System.IO {
             }
 
             [MethodImplAttribute(MethodImplOptions.Synchronized)]
-            public override int Read([In, Out] char[] buffer, int index, int count) 
+            public override int Read(char[] buffer, int index, int count) 
             {
                 return _in.Read(buffer, index, count);
             }
             
             [MethodImplAttribute(MethodImplOptions.Synchronized)]
-            public override int ReadBlock([In, Out] char[] buffer, int index, int count) 
+            public override int ReadBlock(char[] buffer, int index, int count) 
             {
                 return _in.ReadBlock(buffer, index, count);
             }
diff --git a/src/mscorlib/src/System/IO/__Error.cs b/src/mscorlib/src/System/IO/__Error.cs
deleted file mode 100644 (file)
index ea58db3..0000000
+++ /dev/null
@@ -1,81 +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.
-
-/*============================================================
-**
-** 
-** 
-**
-**
-** Purpose: Centralized error methods for the IO package.  
-** Mostly useful for translating Win32 HRESULTs into meaningful
-** error strings & exceptions.
-**
-**
-===========================================================*/
-
-using System;
-using System.Runtime.InteropServices;
-using Win32Native = Microsoft.Win32.Win32Native;
-using System.Text;
-using System.Globalization;
-using System.Security;
-
-namespace System.IO
-{
-    internal static class __Error
-    {
-        internal static void EndOfFile()
-        {
-            throw new EndOfStreamException(SR.IO_EOF_ReadBeyondEOF);
-        }
-
-        internal static void FileNotOpen()
-        {
-            throw new ObjectDisposedException(null, SR.ObjectDisposed_FileClosed);
-        }
-
-        internal static void StreamIsClosed()
-        {
-            throw new ObjectDisposedException(null, SR.ObjectDisposed_StreamClosed);
-        }
-
-        internal static void MemoryStreamNotExpandable()
-        {
-            throw new NotSupportedException(SR.NotSupported_MemStreamNotExpandable);
-        }
-
-        internal static void ReaderClosed()
-        {
-            throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed);
-        }
-
-        internal static void ReadNotSupported()
-        {
-            throw new NotSupportedException(SR.NotSupported_UnreadableStream);
-        }
-
-        internal static void WrongAsyncResult()
-        {
-            throw new ArgumentException(SR.Arg_WrongAsyncResult);
-        }
-
-        internal static void EndReadCalledTwice()
-        {
-            // Should ideally be InvalidOperationExc but we can't maitain parity with Stream and FileStream without some work
-            throw new ArgumentException(SR.InvalidOperation_EndReadCalledMultiple);
-        }
-
-        internal static void EndWriteCalledTwice()
-        {
-            // Should ideally be InvalidOperationExc but we can't maintain parity with Stream and FileStream without some work
-            throw new ArgumentException(SR.InvalidOperation_EndWriteCalledMultiple);
-        }
-
-        internal static void WriteNotSupported()
-        {
-            throw new NotSupportedException(SR.NotSupported_UnwritableStream);
-        }
-    }
-}
index 6104ebe..24dcc3d 100644 (file)
@@ -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)]
index 4462135..1f87dea 100644 (file)
@@ -286,7 +286,7 @@ namespace System.Reflection.Emit
                     if (signature[i] == null)
                         throw new ArgumentException(SR.Arg_InvalidTypeInSignature);
                     m_parameterTypes[i] = signature[i].UnderlyingSystemType as RuntimeType;
-                    if (m_parameterTypes[i] == null || !(m_parameterTypes[i] is RuntimeType) || m_parameterTypes[i] == (RuntimeType)typeof(void))
+                    if (m_parameterTypes[i] == null || m_parameterTypes[i] == (RuntimeType)typeof(void))
                         throw new ArgumentException(SR.Arg_InvalidTypeInSignature);
                 }
             }
@@ -297,7 +297,7 @@ namespace System.Reflection.Emit
 
             // check and store the return value
             m_returnType = (returnType == null) ? (RuntimeType)typeof(void) : returnType.UnderlyingSystemType as RuntimeType;
-            if ((m_returnType == null) || !(m_returnType is RuntimeType) || m_returnType.IsByRef)
+            if (m_returnType == null)
                 throw new NotSupportedException(SR.Arg_InvalidTypeInRetType);
 
             if (transparentMethod)
index 490a322..f730d86 100644 (file)
@@ -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;
index 85eb17c..0a61b68 100644 (file)
@@ -38,7 +38,7 @@ namespace System.Runtime.CompilerServices
         /// <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 };
         }
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/FriendAccessAllowedAttribute.cs b/src/mscorlib/src/System/Runtime/CompilerServices/FriendAccessAllowedAttribute.cs
deleted file mode 100644 (file)
index 9d380e1..0000000
+++ /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
-{
-    /// <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
-    {
-    }
-}
index e2e4374..3bf6e8c 100644 (file)
@@ -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);
index f89f201..1441593 100644 (file)
@@ -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
index d78aae2..d11b436 100644 (file)
@@ -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()
index 9747385..ccbb1f1 100644 (file)
@@ -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);
index 2ecd418..1a210a0 100644 (file)
@@ -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;
index 9de5e3f..ca19d94 100644 (file)
@@ -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 (file)
index f871d94..0000000
+++ /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
-{
-    /// <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
index 2d23c31..684a9c0 100644 (file)
@@ -1125,7 +1125,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
         /// 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
index 2c7bc04..888f25c 100644 (file)
@@ -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);
 
index f4ca1ae..07bcdb7 100644 (file)
@@ -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()
         {
index 2b14f37..322b4f8 100644 (file)
@@ -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)
         {
index 37ae347..5c9754f 100644 (file)
@@ -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;
         }
 
-        /// <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
@@ -6138,7 +6119,6 @@ namespace System.Threading.Tasks
         }
         #endregion
 
-        [FriendAccessAllowed]
         internal static Task<TResult> CreateUnwrapPromise<TResult>(Task outerTask, bool lookForOce)
         {
             Debug.Assert(outerTask != null);
index 8835eb5..42fc40e 100644 (file)
@@ -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
index ba50616..6158309 100644 (file)
@@ -461,7 +461,7 @@ namespace System
                         {
                             int n = stream.Read(buffer, index, count);
                             if (n == 0)
-                                __Error.EndOfFile();
+                                throw Error.GetEndOfFile();
 
                             int end = index + n;
                             for (; index < end; index++)
index 327f0f1..7040ffc 100644 (file)
@@ -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)
     {
index eab048d..f9f159a 100644 (file)
@@ -803,54 +803,6 @@ FCIMPL5(VOID, Buffer::BlockCopy, ArrayBase *src, int srcOffset, ArrayBase *dst,
 FCIMPLEND
 
 
-// InternalBlockCopy
-// This method from one primitive array to another based
-//  upon an offset into each an a byte count.
-FCIMPL5(VOID, Buffer::InternalBlockCopy, ArrayBase *src, int srcOffset, ArrayBase *dst, int dstOffset, int count)
-{
-    FCALL_CONTRACT;
-
-    // @TODO: We should consider writing this in managed code.  We probably
-    // cannot easily do this though - how do we get at the array's data?
-
-    // Unfortunately, we must do a check to make sure we're writing within
-    // the bounds of the array.  This will ensure that we don't overwrite
-    // memory elsewhere in the system nor do we write out junk.  This can
-    // happen if multiple threads interact with our IO classes simultaneously
-    // without being threadsafe.  Throw here.  
-    // Unfortunately this even applies to setting our internal buffers to
-    // null.  We don't want to debug races between Close and Read or Write.
-    if (src == NULL || dst == NULL)
-        FCThrowResVoid(kIndexOutOfRangeException, W("IndexOutOfRange_IORaceCondition"));
-
-    SIZE_T srcLen = src->GetNumComponents() * src->GetComponentSize();
-    SIZE_T dstLen = srcLen;
-    if (src != dst)
-        dstLen = dst->GetNumComponents() * dst->GetComponentSize();
-
-    if (srcOffset < 0 || dstOffset < 0 || count < 0)
-        FCThrowResVoid(kIndexOutOfRangeException, W("IndexOutOfRange_IORaceCondition"));
-
-    if (srcLen < (SIZE_T)srcOffset + (SIZE_T)count || dstLen < (SIZE_T)dstOffset + (SIZE_T)count)
-        FCThrowResVoid(kIndexOutOfRangeException, W("IndexOutOfRange_IORaceCondition"));
-
-    _ASSERTE(srcOffset >= 0);
-    _ASSERTE((src->GetNumComponents() * src->GetComponentSize()) - (unsigned) srcOffset >= (unsigned) count);
-    _ASSERTE((dst->GetNumComponents() * dst->GetComponentSize()) - (unsigned) dstOffset >= (unsigned) count);
-    _ASSERTE(dstOffset >= 0);
-    _ASSERTE(count >= 0);
-
-    // Copy the data.
-#if defined(_AMD64_) && !defined(PLATFORM_UNIX)
-    JIT_MemCpy(dst->GetDataPtr() + dstOffset, src->GetDataPtr() + srcOffset, count);
-#else
-    memmove(dst->GetDataPtr() + dstOffset, src->GetDataPtr() + srcOffset, count);
-#endif
-
-    FC_GC_POLL();
-}
-FCIMPLEND
-
 void QCALLTYPE MemoryNative::Clear(void *dst, size_t length)
 {
     QCALL_CONTRACT;
index 2ecaaa6..b1e47be 100644 (file)
@@ -89,7 +89,6 @@ public:
     // This method from one primitive array to another based
     //      upon an offset into each an a byte count.
     static FCDECL5(VOID, BlockCopy, ArrayBase *src, int srcOffset, ArrayBase *dst, int dstOffset, int count);
-    static FCDECL5(VOID, InternalBlockCopy, ArrayBase *src, int srcOffset, ArrayBase *dst, int dstOffset, int count);
     static FCDECL2(FC_UINT8_RET, GetByte, ArrayBase *arrayUNSAFE, INT32 index);
     static FCDECL3(VOID, SetByte, ArrayBase *arrayUNSAFE, INT32 index, UINT8 bData);
     static FCDECL1(FC_BOOL_RET, IsPrimitiveTypeArray, ArrayBase *arrayUNSAFE);
index b1f9b2b..4ee9826 100644 (file)
@@ -839,7 +839,6 @@ FCFuncEnd()
 
 FCFuncStart(gBufferFuncs)
     FCFuncElement("BlockCopy", Buffer::BlockCopy)
-    FCFuncElement("InternalBlockCopy", Buffer::InternalBlockCopy)
     FCFuncElement("_GetByte", Buffer::GetByte)
     FCFuncElement("_SetByte", Buffer::SetByte)
     FCFuncElement("IsPrimitiveTypeArray", Buffer::IsPrimitiveTypeArray)
@@ -1196,13 +1195,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 +1423,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)