Closed meinsiedler closed 3 years ago
I really appreciate your effort in making the changes. Had a quick look over it and only some minor details.
I really appreciate your effort in making the changes. Had a quick look over it and only some minor details.
I also really appreciate your quick responses and your effort you make by providing useful information and your feedback. 😊
I'll update the PR with the requested changes maybe tomorrow or next week at latest.
Hi,
I enabled ReadAsync
and WriteAsync
for .NET 4.5 too. Also, I added a unit test for .NET 4.5 only and fixed some code formatting issues (braces, #region
indentation).
Integrated with release v2.3.0 (bc94184904364411ef0f5406c918b4873e0b70a2) and published on NuGet.
Hi!
This PR resolves the issue described in #114. As discussed there, .NET standard doesn't support the
Begin|EndRead
andBegin|EndWrite
methods and the current implementation of SerialPortStream didn't implement theReadAsync
andWriteAsync
methods from theStream
base class.With this PR, the two methods are now implemented. The two new methods simply delegate to the existing
BeginRead
andBeginWrite
methods using theTask.FromAsync
method. SinceAsyncResult
isn't available any more too, we can use aTask
instead as described here (Task
implementsIAsyncResult
).With the approach of re-using the existing
Begin|EndRead
andBegin|EndWrite
methods we can leverage the well tested and established code without introducing much more code to maintain.Unfortunately, the Asynchronous Programming Model (APM) (using
Begin|EndRead
andBegin|EndWrite
methods) didn't consider cancellation, so we cannot support theCancallationToken
with the newReadAsync
andWriteAsync
methods easily. The passsedcancellationToken
will simply be ignored. We hope that's OK for now. Otherwise we would need to rewrite the entire read/write process using "real" asynchronicity and with "real" cancellation behavior. Since this would mean a lot more effort and more further code to maintain in future for little use, we think it's better to ignore the cancellation behavior in that case.Regarding testing: We haven't added any more unit tests to your solution, since we saw that no .NET standard 1.5 tests were present. For testing our changes locally, we added my unit test from my test project directly, but didn't commit it to your repo. The tests now succeed with .NET Core 3.1 too.
We'd be very happy if our PR for fixing the issues with .NET Core lands in a new NuGet version of your project.
Best regards.