﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management.Automation;
using Extensions.String;

namespace Microsoft.PowerShell.Commands.Utility
{
    [Cmdlet("Write", "Host")]
    public sealed class WriteHostCommand : ConsoleColorCmdlet
    {
        [Parameter(Position = 0, ValueFromRemainingArguments = true, ValueFromPipeline = true)]
        public PSObject Object { get; set; }

        [Parameter]
        public SwitchParameter NoNewline { get; set; }

        [Parameter]
        public Object Separator { get; set; }

        protected override void ProcessRecord()
        {
            Action<ConsoleColor, ConsoleColor, string> writeAction;

            if (NoNewline) writeAction = Host.UI.Write;
            else writeAction = Host.UI.WriteLine;

            if (Object == null)
            {
                writeAction(ForegroundColor, BackgroundColor, "");
            }
            else if (Object.BaseObject is Enumerable)
            {
                throw new NotImplementedException();
            }
            else
            {
                writeAction(ForegroundColor, BackgroundColor, Object.ToString());
            }
        }
    }
}

﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management.Automation;
using Extensions.String;
using System.Collections;

namespace Microsoft.PowerShell.Commands.Utility
{
    [Cmdlet("Write", "Host")]
    public sealed class WriteHostCommand : ConsoleColorCmdlet
    {
        [Parameter(Position = 0, ValueFromRemainingArguments = true, ValueFromPipeline = true)]
        public PSObject Object { get; set; }

        [Parameter]
        public SwitchParameter NoNewline { get; set; }

        [Parameter]
        public Object Separator { get; set; }

        protected override void ProcessRecord()
        {
            Action<ConsoleColor, ConsoleColor, string> writeAction;

            if (NoNewline) writeAction = Host.UI.Write;
            else writeAction = Host.UI.WriteLine;

            if (Object == null)
            {
                writeAction(ForegroundColor, BackgroundColor, "");
            }
            else
            {
                writeAction(ForegroundColor, BackgroundColor, Object.ToString());
            }
        }
    }
}

Remove never-run code in WriteHost.
Remove never-run code in WriteHost.

This code triggers a compile warning (which is treated as an error) when using MonoDevelop.

The condition is bogus - an object can never satisfy `is Enumerable` because `Enumerable` is a `static class`. So it will always be false. I probably intended to write `is IEnumerable` here, but that causes tests to fail. So, yanking this broken code.

I am also opening Issue #20 to make sure we come back and think about this carefully at some point.
