PowerShell is wonderful but it is unofrtunate there not only seems to be no concept of outputting to a sequential medium like a stream or a file but most strings sent to WriteLine are padded with blanks to match the BufferSize!!! I feel this is a serious bug that causes performance problems, resource issues and even crashes! My application implements PSHost and PSHostRawUserInterface and I have struggled with various techniques to try to eliminate line wrapping efficiently but this seems not possible. I am capturing output to put into a stream and basically do not have the concept of a "screen" and do not feel one should be necessary when hosting PowerShell in your own application. Here is what I have found: 1. Seems only Buffersize matters as I do not even get called for WindowSize, MaxWindowSize or MaxPhysicalWindowSize. This is probably wrong in general but is true in my application and the CmdLets and PS scripts that I have run so far. 2. BufferSize is called for each line of output and sometimes twice. Seems quite inefficient. Does it really need to be THAT dynamic??? I don't know of too many users that change their screensize in between cmdlets. 3. I can set BufferSize width and control the wrapping but most output [esp. that seems to come from external sources like get-process and dir] is padded with blanks!!! This is terrible and is a bug imo and in the worst case scenario, if you set the width to int32.maxvalue it will throw out of memory and even set to 1024 or something "reasonable" to eliminate most line wrapping, this is terribly inefficient and wasteful of resources! It is a bug because only some output does this not all of it!!! So why should any of it? 4. Height does not seem to matter whether I set it to 0 or 1 or whatever. 5. If I set BufferSize to int32.maxvalue I run out of memory on many commands but not the ones that properly output a line without trailing blanks such as write-output and the other write-xxx commands. Microsoft, I absolutely love PowerShell but please allow the concept of outputting to a stream by perhaps adding a simple option saying I have no concept of a screen but still support write-host etc. or let me set BufferSize width to 0 or -1 to indicate I do NOT want line wrapping at all, and have no concept of a line length. Also, if I do set a BufferSize width, please do not pad the string with blanks to meet that width. Some commands already work like this and unfortunately many do not! Think outputting to a stream or file...not a screen! Sorry for the rant, hopefully I'm off base and am doing something wrong here. Thanks, Dave |