Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Add TextReader/Writer Memory-based virtuals #24434

Merged
merged 3 commits into from
Oct 5, 2017

Conversation

stephentoub
Copy link
Member

@@ -117,6 +118,35 @@ public override int Read(char[] buffer, int index, int count)
return n;
}

public override int Read(Span<char> destination)
{
if (GetType() != typeof(StringReader))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add the comment on why we do the check for derived classes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll add comments.

Copy link
Member

@JeremyKuhne JeremyKuhne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@@ -1435,8 +1435,12 @@ public partial class StringReader : System.IO.TextReader
public override int Peek() { throw null; }
public override int Read() { throw null; }
public override int Read(char[] buffer, int index, int count) { throw null; }
public override int Read(System.Span<char> destination) { throw null; }
Copy link
Member

@ahsonkhan ahsonkhan Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Is specifying System required in the type name? If not, remove (here and elsewhere) to be consistent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the full type name is consistent with how the ref generator tool generates the code.

@@ -1523,6 +1533,7 @@ public abstract partial class TextWriter : System.MarshalByRefObject, System.IDi
public virtual System.Threading.Tasks.Task WriteAsync(char value) { throw null; }
public System.Threading.Tasks.Task WriteAsync(char[] buffer) { throw null; }
public virtual System.Threading.Tasks.Task WriteAsync(char[] buffer, int index, int count) { throw null; }
public virtual System.Threading.Tasks.Task WriteAsync(ReadOnlyMemory<char> source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the full type name is consistent with how the ref generator tool generates the code.

There are some places where the full type name is not being used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix those.

@stephentoub
Copy link
Member Author

@dotnet/dnceng, I'm seeing an error I've not seen before. The given tests completed successfully, and then there was some kind of connection failure in the infrastructure:
https://ci3.dot.net/job/dotnet_corefx/job/master/job/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/4068/

2017-10-05 00:04:57,039: INFO: proc(54): run_and_log_output: Output: === TEST EXECUTION SUMMARY ===
2017-10-05 00:04:57,052: INFO: proc(54): run_and_log_output: Output:    System.Net.Ping.Functional.Tests  Total: 31, Errors: 0, Failed: 0, Skipped: 0, Time: 1.090s
2017-10-05 00:04:57,124: INFO: proc(54): run_and_log_output: Output: ~/dotnetbuild/work/ec79333e-ad45-408e-a8ba-47605cb8ec35/Work/9ac4a109-a12f-4ca5-880d-24562d2b0f2f/Unzip
2017-10-05 00:04:57,125: INFO: proc(54): run_and_log_output: Output: Finished running tests. End time=00:04:57. Return value was 0
2017-10-05 00:04:57,127: INFO: proc(58): run_and_log_output: Exit Code: 0
2017-10-05 00:04:57,127: INFO: scriptrunner(62): _main: Uploading results from /home/helixbot/dotnetbuild/work/ec79333e-ad45-408e-a8ba-47605cb8ec35/Work/9ac4a109-a12f-4ca5-880d-24562d2b0f2f/Unzip/testResults.xml
2017-10-05 00:04:57,128: INFO: azure_storage(205): _upload: Uploading single blob: 'testResults.xml'
2017-10-05 00:07:04,479: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 00:09:11,711: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 00:09:11,715: INFO: saferequests(64): request_with_retry: Waiting 1.44397734 seconds for retry 2
2017-10-05 00:11:20,479: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 00:11:20,479: INFO: saferequests(64): request_with_retry: Waiting 1.53217030351 seconds for retry 3
2017-10-05 00:13:29,247: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 00:13:29,247: INFO: saferequests(64): request_with_retry: Waiting 1.71480464429 seconds for retry 4
2017-10-05 00:15:38,271: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 00:15:38,272: ERROR: saferequests(104): request_with_retry: Retry count 5 exceeded, re-raising last error
Traceback (most recent call last):
  File "/home/helixbot/dotnetbuild/work/ec79333e-ad45-408e-a8ba-47605cb8ec35/Payload/RunnerScripts/scriptrunner/scriptrunner.py", line 96, in <module>
    sys.exit(main())
  File "/home/helixbot/dotnetbuild/work/ec79333e-ad45-408e-a8ba-47605cb8ec35/Payload/RunnerScripts/scriptrunner/scriptrunner.py", line 92, in main
    return command_main(_main, ['script=', 'args='], args)
  File "/home/helixbot/dotnetbuild/scripts/helix/cmdline.py", line 47, in command_main
    return main_method(settings, optlist, args)
  File "/home/helixbot/dotnetbuild/work/ec79333e-ad45-408e-a8ba-47605cb8ec35/Payload/RunnerScripts/scriptrunner/scriptrunner.py", line 74, in _main
    result_url = test_executor.upload_file_to_storage(results_location, settings)
  File "/home/helixbot/dotnetbuild/scripts/helix_test_execution.py", line 37, in upload_file_to_storage
    url = fc.upload(file_path, os.path.basename(file_path))
  File "/home/helixbot/dotnetbuild/scripts/helix/azure_storage.py", line 77, in upload
    self._upload(f, name)
  File "/home/helixbot/dotnetbuild/scripts/helix/azure_storage.py", line 208, in _upload
    retry_status_ranges=helix.saferequests.RETRY_RANGE_ALL_ERROR
  File "/home/helixbot/dotnetbuild/scripts/helix/saferequests.py", line 105, in request_with_retry
    raise last_error
requests.exceptions.ConnectionError: ('Connection aborted.', error(110, 'Connection timed out'))
2017-10-05 00:15:38,272: ERROR: logs(87): _log_uncaught_exception: Unhandled error: ('Connection aborted.', error(110, 'Connection timed out'))
['  File "/home/helixbot/dotnetbuild/work/ec79333e-ad45-408e-a8ba-47605cb8ec35/Payload/RunnerScripts/scriptrunner/scriptrunner.py", line 96, in <module>\n    sys.exit(main())\n', '  File "/home/helixbot/dotnetbuild/work/ec79333e-ad45-408e-a8ba-47605cb8ec35/Payload/RunnerScripts/scriptrunner/scriptrunner.py", line 92, in main\n    return command_main(_main, [\'script=\', \'args=\'], args)\n', '  File "/home/helixbot/dotnetbuild/scripts/helix/cmdline.py", line 47, in command_main\n    return main_method(settings, optlist, args)\n', '  File "/home/helixbot/dotnetbuild/work/ec79333e-ad45-408e-a8ba-47605cb8ec35/Payload/RunnerScripts/scriptrunner/scriptrunner.py", line 74, in _main\n    result_url = test_executor.upload_file_to_storage(results_location, settings)\n', '  File "/home/helixbot/dotnetbuild/scripts/helix_test_execution.py", line 37, in upload_file_to_storage\n    url = fc.upload(file_path, os.path.basename(file_path))\n', '  File "/home/helixbot/dotnetbuild/scripts/helix/azure_storage.py", line 77, in upload\n    self._upload(f, name)\n', '  File "/home/helixbot/dotnetbuild/scripts/helix/azure_storage.py", line 208, in _upload\n    retry_status_ranges=helix.saferequests.RETRY_RANGE_ALL_ERROR\n', '  File "/home/helixbot/dotnetbuild/scripts/helix/saferequests.py", line 105, in request_with_retry\n    raise last_error\n']
2017-10-05 00:15:38,273: INFO: azure_storage(205): _upload: Uploading single blob: 'ccbbb7786fad47939326786eba934e24.log'
2017-10-05 00:17:45,503: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 00:19:52,735: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 00:19:52,735: INFO: saferequests(64): request_with_retry: Waiting 0.799028305568 seconds for retry 2
2017-10-05 00:22:00,735: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 00:22:00,735: INFO: saferequests(64): request_with_retry: Waiting 1.75648261411 seconds for retry 3
2017-10-05 00:24:09,759: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 00:24:09,759: INFO: saferequests(64): request_with_retry: Waiting 4.02889609425 seconds for retry 4

Copy link
Contributor

@pjanotti pjanotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@stephentoub
Copy link
Member Author

@dotnet/dnceng, another example of the tests finishing successfully and then the leg failing:
https://ci3.dot.net/job/dotnet_corefx/job/master/job/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/4077/

2017-10-05 03:43:56,433: INFO: proc(54): run_and_log_output: Output:    System.Data.Common.Tests  Total: 1719, Errors: 0, Failed: 0, Skipped: 0, Time: 6.395s
2017-10-05 03:43:56,474: INFO: proc(54): run_and_log_output: Output: ~/dotnetbuild/work/715edee8-780f-448e-8ba2-282cdca0dab5/Work/b4f890eb-dd55-453a-bb12-08d8c4b170fe/Unzip
2017-10-05 03:43:56,475: INFO: proc(54): run_and_log_output: Output: Finished running tests. End time=03:43:56. Return value was 0
2017-10-05 03:43:56,476: INFO: proc(58): run_and_log_output: Exit Code: 0
2017-10-05 03:43:56,477: INFO: scriptrunner(62): _main: Uploading results from /home/helixbot/dotnetbuild/work/715edee8-780f-448e-8ba2-282cdca0dab5/Work/b4f890eb-dd55-453a-bb12-08d8c4b170fe/Unzip/testResults.xml
2017-10-05 03:43:56,477: INFO: azure_storage(205): _upload: Uploading single blob: 'testResults.xml'
2017-10-05 03:46:03,750: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 03:48:10,981: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 03:48:10,981: INFO: saferequests(64): request_with_retry: Waiting 0.512995863254 seconds for retry 2
2017-10-05 03:50:18,725: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 03:50:18,725: INFO: saferequests(64): request_with_retry: Waiting 2.4484734257 seconds for retry 3
2017-10-05 03:52:28,389: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 03:52:28,389: INFO: saferequests(64): request_with_retry: Waiting 3.00865067789 seconds for retry 4
2017-10-05 03:54:38,693: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 03:54:38,693: ERROR: saferequests(104): request_with_retry: Retry count 5 exceeded, re-raising last error
Traceback (most recent call last):
  File "/home/helixbot/dotnetbuild/work/715edee8-780f-448e-8ba2-282cdca0dab5/Payload/RunnerScripts/scriptrunner/scriptrunner.py", line 96, in <module>
    sys.exit(main())
  File "/home/helixbot/dotnetbuild/work/715edee8-780f-448e-8ba2-282cdca0dab5/Payload/RunnerScripts/scriptrunner/scriptrunner.py", line 92, in main
    return command_main(_main, ['script=', 'args='], args)
  File "/home/helixbot/dotnetbuild/scripts/helix/cmdline.py", line 47, in command_main
    return main_method(settings, optlist, args)
  File "/home/helixbot/dotnetbuild/work/715edee8-780f-448e-8ba2-282cdca0dab5/Payload/RunnerScripts/scriptrunner/scriptrunner.py", line 74, in _main
    result_url = test_executor.upload_file_to_storage(results_location, settings)
  File "/home/helixbot/dotnetbuild/scripts/helix_test_execution.py", line 37, in upload_file_to_storage
    url = fc.upload(file_path, os.path.basename(file_path))
  File "/home/helixbot/dotnetbuild/scripts/helix/azure_storage.py", line 77, in upload
    self._upload(f, name)
  File "/home/helixbot/dotnetbuild/scripts/helix/azure_storage.py", line 208, in _upload
    retry_status_ranges=helix.saferequests.RETRY_RANGE_ALL_ERROR
  File "/home/helixbot/dotnetbuild/scripts/helix/saferequests.py", line 105, in request_with_retry
    raise last_error
requests.exceptions.ConnectionError: ('Connection aborted.', error(110, 'Connection timed out'))
2017-10-05 03:54:38,694: ERROR: logs(87): _log_uncaught_exception: Unhandled error: ('Connection aborted.', error(110, 'Connection timed out'))
['  File "/home/helixbot/dotnetbuild/work/715edee8-780f-448e-8ba2-282cdca0dab5/Payload/RunnerScripts/scriptrunner/scriptrunner.py", line 96, in <module>\n    sys.exit(main())\n', '  File "/home/helixbot/dotnetbuild/work/715edee8-780f-448e-8ba2-282cdca0dab5/Payload/RunnerScripts/scriptrunner/scriptrunner.py", line 92, in main\n    return command_main(_main, [\'script=\', \'args=\'], args)\n', '  File "/home/helixbot/dotnetbuild/scripts/helix/cmdline.py", line 47, in command_main\n    return main_method(settings, optlist, args)\n', '  File "/home/helixbot/dotnetbuild/work/715edee8-780f-448e-8ba2-282cdca0dab5/Payload/RunnerScripts/scriptrunner/scriptrunner.py", line 74, in _main\n    result_url = test_executor.upload_file_to_storage(results_location, settings)\n', '  File "/home/helixbot/dotnetbuild/scripts/helix_test_execution.py", line 37, in upload_file_to_storage\n    url = fc.upload(file_path, os.path.basename(file_path))\n', '  File "/home/helixbot/dotnetbuild/scripts/helix/azure_storage.py", line 77, in upload\n    self._upload(f, name)\n', '  File "/home/helixbot/dotnetbuild/scripts/helix/azure_storage.py", line 208, in _upload\n    retry_status_ranges=helix.saferequests.RETRY_RANGE_ALL_ERROR\n', '  File "/home/helixbot/dotnetbuild/scripts/helix/saferequests.py", line 105, in request_with_retry\n    raise last_error\n']
2017-10-05 03:54:38,694: INFO: azure_storage(205): _upload: Uploading single blob: 'c1218b833e6d4e748a57fed8dcc96f47.log'
2017-10-05 03:56:45,925: WARNING: saferequests(70): request_with_retry: Request failed with exception: ConnectionError(ProtocolError('Connection aborted.', error(110, 'Connection timed out')),)
2017-10-05 03:57:01,252: INFO: saferequests(90): request_with_retry: Response complete with status code '201'
2017-10-05 03:57:01,253: INFO: event(43): send: Sending event type Logs
2017-10-05 03:57:01,280: INFO: saferequests(90): request_with_retry: Response complete with status code '201'
'module' object has no attribute '__file__'

@stephentoub
Copy link
Member Author

stephentoub commented Oct 5, 2017

@dotnet/dnceng, and an "Execution may have been compromised" error?

Details from Job 0185a04b-2766-411a-aebe-a0f0cc28fd21

ExitCode: -3 
Ran on Machine: dnbopsup4000FWJ 
Errors

DownloadError: Unable to download https://dotnetbuilddrops.blob.core.windows.net/build-88ab1f2999a7453da8b724423e07a790/SupplementalPayload.zip?sv=2015-04-05&sr=c&sig=5p6o%2FBGro8F5Das0zsds0soANZ3nPytE4mfiB66%2Bhm8%3D&st=2017-10-05T03%3A32%3A18.8400702Z&se=2017-11-04T03%3A32%3A18.8400826Z&sp=r after retrying. Execution may be compromised.

@stephentoub stephentoub merged commit 03d7056 into dotnet:master Oct 5, 2017
@stephentoub stephentoub deleted the textreaderwriter_memory branch October 5, 2017 04:36
@mmitche
Copy link
Member

mmitche commented Oct 5, 2017

@karelz karelz added this to the 2.1.0 milestone Oct 11, 2017
pjanotti pushed a commit to pjanotti/corefx that referenced this pull request Oct 31, 2017
* Add Memory-based Read/WriteAsync virtuals to TextReader/Writer

* Override Span/Memory-based APIs on StringReader/Writer

* Address PR feedback
@PRIMETSS
Copy link
Contributor

Just hit a Needing/Wanting Cancellation token support for StreamReader.ReadLineAsync() just now, Was it added in 2.1.0 >> only, or still open-not in yet?
Thankyou!

@stephentoub
Copy link
Member Author

These overloads were added in 2.1.

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Add Memory-based Read/WriteAsync virtuals to TextReader/Writer

* Override Span/Memory-based APIs on StringReader/Writer

* Address PR feedback


Commit migrated from dotnet/corefx@03d7056
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants