-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Conversation
By looking at the diff between Stream class in coreclr and corert I see that: (1)
and
throw (2)
is (3)
in corert has the extra if block check below:
Possible action: You could add #ifdef !CORECLR to keep the existing behavior for corert and remain to throw the exceptions. (4)
Is only used in coreclr. |
(5) More methods that would need to move to non-shared file (Stream.CoreCLR.cs):
non public APIs that could be moved to
|
(6) The implementations are different between coreclr and corert for below APIs:
|
@marek-safar @jkotas overall I'm not confident in this change. I see more in the diff between the two files than I pointed out to above, yet maybe some but not all the diffs in corert is a bit out of date. I think there is still value in just conservatively reducing the visible diff rather than completely moving the file to shared. @marek-safar let me know what you think. |
(1) I would add these under
(2) Changing this to
(3) @stephentoub Is it a good idea to have explicit check for IsCancellationRequested in (4) (5) (6) @stephentoub Is the CoreRT implementation of old async based on |
corert's extra check is not necessary. The Task.Factory.StartNew call is being passed the cancellation token: coreclr/src/System.Private.CoreLib/src/System/IO/Stream.cs Lines 255 to 259 in e1bbc70
and that StartNew call will itself check the token.
As currently implemented, corert's implementation is less efficient, incurring more allocation than the implementation in coreclr. We could say we don't really care about the perf of these Begin/EndRead/Write methods, but I'd be hesitant without doing more analysis. |
Let's use the coreclr implementation for the shared copy then. |
(1) I would add these under #if CORERT I am not sure this is necessary. The platform-specific checks are now in (2) Done (3, 4) Unchanged |
|
ok, ifdef-ed the SyncStream uses with PNSE |
@maryamariyan Do the change look good to you now? |
@@ -1270,6 +1237,9 @@ public override int ReadByte() | |||
|
|||
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) | |||
{ | |||
#if CORERT | |||
throw new PlatformNotSupportedException(); // TODO: https://github.com/dotnet/corert/issues/3251 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In corert we have NotImplementedException
(refer to this).
Do we want to switch behavior to PlatformNotImplementedException
?
@@ -1327,6 +1298,9 @@ public override void WriteByte(byte b) | |||
|
|||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) | |||
{ | |||
#if CORERT | |||
throw new PlatformNotSupportedException(); // TODO: https://github.com/dotnet/corert/issues/3251 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In corert we have NotImplementedException
(refer to this).
Do we want to switch behavior to PlatformNotImplementedException
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to continue to throw the same exception.
@jkotas some of the APIs (shown in the list below) are only async in corert and not as such in coreclr.
|
|
Other than the exception type comment above the rest looking LGTM. Note 1: As of this PR we knowingly decided to pick implementation of coreclr for the below APIs:
For example in corert, below shows how two APIs will be overwritten by coreclr:
To be overwritten with
Note 2: The only other diff is that in corert we had the below 4 Debug.Assert statements in
|
@jkotas for some public APIs the argument names will be changed for corert. That should be fine, right? |
Right, assuming they are being changed to match the reference assemblies in corefx. The API compat checks should catch mismatched argument names. I am not sure why it is not happening. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
* Moves Stream to shared location * Review tweaks * Add NotImplementedException for SyncStream due to #3251 Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* Moves Stream to shared location * Review tweaks * Add NotImplementedException for SyncStream due to dotnet/corert#3251 Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
* Moves Stream to shared location * Review tweaks * Add NotImplementedException for SyncStream due to dotnet/corert#3251 Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
* Moves Stream to shared location * Review tweaks * Add NotImplementedException for SyncStream due to #3251 Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* Moves Stream to shared location * Review tweaks * Add NotImplementedException for SyncStream due to dotnet/corert#3251 Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
No description provided.