diff options
author | Jan Kotas <jkotas@microsoft.com> | 2016-01-19 00:04:33 -0800 |
---|---|---|
committer | stephentoub <stoub@microsoft.com> | 2016-01-19 08:16:16 -0500 |
commit | 04294485c8cfd1b8d2fe974ace49c5dd33008626 (patch) | |
tree | 9a654de18c38163953e09f8fa4e5a480117fdc0c /src/mscorlib | |
parent | 2b53215be49e81bd8e0aee85b539bc07a6c43e2e (diff) | |
download | coreclr-04294485c8cfd1b8d2fe974ace49c5dd33008626.tar.gz coreclr-04294485c8cfd1b8d2fe974ace49c5dd33008626.tar.bz2 coreclr-04294485c8cfd1b8d2fe974ace49c5dd33008626.zip |
Add generic detection of Stream.{Begin|End}{Read|Write} overrides
Diffstat (limited to 'src/mscorlib')
-rw-r--r-- | src/mscorlib/src/System/IO/FileStream.cs | 3 | ||||
-rw-r--r-- | src/mscorlib/src/System/IO/Stream.cs | 27 |
2 files changed, 12 insertions, 18 deletions
diff --git a/src/mscorlib/src/System/IO/FileStream.cs b/src/mscorlib/src/System/IO/FileStream.cs index 0952300dfb..3258940b53 100644 --- a/src/mscorlib/src/System/IO/FileStream.cs +++ b/src/mscorlib/src/System/IO/FileStream.cs @@ -1778,9 +1778,6 @@ namespace System.IO { return; } -#if FEATURE_CORECLR - internal override bool OverridesBeginEnd { get { return true; } } -#endif [System.Security.SecuritySafeCritical] // auto-generated [HostProtection(ExternalThreading = true)] diff --git a/src/mscorlib/src/System/IO/Stream.cs b/src/mscorlib/src/System/IO/Stream.cs index d62bcbd855..4a90945d22 100644 --- a/src/mscorlib/src/System/IO/Stream.cs +++ b/src/mscorlib/src/System/IO/Stream.cs @@ -285,19 +285,7 @@ namespace System.IO { return new ManualResetEvent(false); } - internal virtual bool OverridesBeginEnd - { - get - { -#if FEATURE_CORECLR - return false; // methods aren't exposed outside of mscorlib -#else - return true; // have to assume they are overridden as they're exposed -#endif - } - } - - [HostProtection(ExternalThreading=true)] + [HostProtection(ExternalThreading=true)] public virtual IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) { Contract.Ensures(Contract.Result<IAsyncResult>() != null); @@ -438,9 +426,13 @@ namespace System.IO { : BeginEndReadAsync(buffer, offset, count); } + [System.Security.SecuritySafeCritical] + [MethodImplAttribute(MethodImplOptions.InternalCall)] + private extern bool HasOverridenBeginEndRead(); + private Task<Int32> BeginEndReadAsync(Byte[] buffer, Int32 offset, Int32 count) { - if (!OverridesBeginEnd) + if (!HasOverridenBeginEndRead()) { return (Task<Int32>)BeginReadInternal(buffer, offset, count, null, null, serializeAsynchronously: true, apm: false); } @@ -751,6 +743,8 @@ namespace System.IO { return WriteAsync(buffer, offset, count, CancellationToken.None); } + + [HostProtection(ExternalThreading = true)] [ComVisible(false)] public virtual Task WriteAsync(Byte[] buffer, int offset, int count, CancellationToken cancellationToken) @@ -762,10 +756,13 @@ namespace System.IO { : BeginEndWriteAsync(buffer, offset, count); } + [System.Security.SecuritySafeCritical] + [MethodImplAttribute(MethodImplOptions.InternalCall)] + private extern bool HasOverridenBeginEndWrite(); private Task BeginEndWriteAsync(Byte[] buffer, Int32 offset, Int32 count) { - if (!OverridesBeginEnd) + if (!HasOverridenBeginEndWrite()) { return (Task)BeginWriteInternal(buffer, offset, count, null, null, serializeAsynchronously: true, apm: false); } |