-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Console.Write on iOS #56713
Fix Console.Write on iOS #56713
Conversation
Tagging subscribers to this area: @dotnet/area-system-console Issue DetailsFixes #36440. This is iOS-part of Egor's fix from #37078. For this code snippet:
the output will be:
|
Can we enable runtime/src/libraries/System.Console/tests/ConsoleEncoding.cs Lines 25 to 26 in 79c4144
or any other test for this on iOS? (from the skip reason message of this test, it's not clear which API is not supported) |
Added |
It's quite close to a working state, the only problem is that I cannot find the right moment to write the data remaining in the cache to the stream before closing the app. |
src/libraries/System.Private.CoreLib/src/System/IO/StreamWriter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/StreamWriter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/StreamWriter.cs
Outdated
Show resolved
Hide resolved
…pnin/runtime into fix_console_write_on_ios # Conflicts: # src/libraries/System.Console/src/System/ConsolePal.iOS.cs
The PR looks pretty green now. @stephentoub Would you like to take another look? |
} | ||
|
||
// no newlines found, add the entire buffer to the cache | ||
cache.Append(charBuffer); |
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.
General question about this change... it seems like this change means that if I have code that does:
while (true)
{
Console.Write(".");
await Task.Delay(1000);
}
to print out a period to the console once a second, for example as you might find with a progress indicator in a console app, that the data will never be emitted to the console, because newlines are never found. Am I understanding correctly? Is that not an issue, e.g. because Console is only used for diagnostic messages in an iOS app?
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.
Yes, this is a thing I wasn't able to beat. I mentioned it a bit earlier #56713 (comment). The current Xamarin implementation has the same drawback so it won't surprise the existing customers.
/backport to release/6.0 |
Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1194460075 |
@MaximLipnin backporting to release/6.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Fix Console.Write on iOS
Applying: Move the helper method to iOS-specific location
Applying: Add a test
Applying: Remove unused using
Applying: Apply Ralf's suggestion
Applying: Move Interop.Sys.Log to a local function
Applying: Move the caching logic over to StreamWriter
Applying: feedback
Applying: Remove unused usings
Applying: Derive from StreamWriter
Applying: Feedback
Applying: Try a solution not changing public API surface and using NSLogStream with a decoder
Applying: Some feedback
Applying: Use ArrayPool
Applying: Not rely on the length of the rented array
Applying: Address the feedback
Applying: not use _ prefix for local variable
Applying: Address the feedback
Using index info to reconstruct a base tree...
M src/libraries/System.Console/src/System/ConsolePal.iOS.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.Console/src/System/ConsolePal.iOS.cs
CONFLICT (content): Merge conflict in src/libraries/System.Console/src/System/ConsolePal.iOS.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0018 Address the feedback
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
A small cleanup after #56713.
Expands on dotnet#56713 by moving the caching implementation to a separate internal class leaving only the interop calls in ConsolePal.iOS and ConsolePal.Android Fixes dotnet#57304
Fixes #36440.
This is iOS-part of Egor's fix (with Ralf's suggestion) from #37078.
For this code snippet:
the output will be: