Skip to content
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

Using Console.SetOut doesn't affect IsOutputRedirected #17959

Closed
BrennanConroy opened this issue Jul 29, 2016 · 8 comments
Closed

Using Console.SetOut doesn't affect IsOutputRedirected #17959

BrennanConroy opened this issue Jul 29, 2016 · 8 comments
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.Console help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@BrennanConroy
Copy link
Member

... similarly for Input and Error.

See : https://github.com/dotnet/corefx/blob/5e36ca02d2594f715da829aafaf7af2b554dfcdf/src/System.Console/src/System/ConsolePal.Unix.cs#L461-L467

The summary describes the behavior I expect which is checking Console.Out but the actual behavior is checking STDOUT

@stephentoub @ianhays

@ianhays
Copy link
Contributor

ianhays commented Jul 29, 2016

IsOutputRedirected looks at the output/input/error handles themselves. SetOut doesn't affect those, so Is*Redirected is unaffected by SetOut/SetIn/SetError. SetOut only modifies the TextWriter that the Console operations call e.g. if you do a manual interop write to the stdout handle it will function the same regardless of what SetOut is set to.

The Unix behavior was made to mimic the Windows behavior in this regard.

@BrennanConroy
Copy link
Member Author

Yeah I can see that. I'm saying its not great behavior, you are operating on the "Console" object when calling SetOut and IsOutputRedirected should reflect the "Console" objects internal state.

It would be great to have a way of seeing if Console.Out (and friends) is actually redirected from STDOUT without having to manually Pinvoke

@muratg
Copy link

muratg commented Aug 2, 2016

👀

@ianhays ianhays removed their assignment Oct 25, 2016
@karelz
Copy link
Member

karelz commented Nov 3, 2016

We need formal API proposal.

@ianhays
Copy link
Contributor

ianhays commented Dec 19, 2016

Does anyone want to take this and submit a formal API proposal with samples and use cases? If not, I'm going to close the issue as there hasn't been any movement in a while.

@muratg
Copy link

muratg commented Dec 19, 2016

@BrennanConroy could you update the impact of this? (and what workaround did we use?)

@ianhays please do not close just yet. IIRC, an ASP.NET scenario was impacted with this...

@BrennanConroy
Copy link
Member Author

We wanted a way to check if Console.Out was being redirected for logging to possibly remove ANSI Color Codes. I'm not sure if we still want to be able to do that @glennc

@glennc
Copy link

glennc commented Jan 6, 2017

I think we are good to close this. At this point we have enough other mitigations to the root problems in place that it isn't important enough for us to try and make a change at this level of the stack.

@ianhays ianhays closed this as completed Jan 9, 2017
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.0.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.Console help wanted [up-for-grabs] Good issue for external contributors
Projects
None yet
Development

No branches or pull requests

6 participants