Monad Beta3の謎

なぜかBeta3で動作しない

文字列をIEに出力する(out-ie) - PowerShell Memoで紹介した「out-ie」は、文字列をIEに出力するScriptです。このScriptは、Beta2では問題なく動作していたのですが、Beta3ではエラーが出て正しく動作しません。


なぜ?

out-ie
param()

#パイプでオブジェクトが渡されたかチェック
$test = $input.clone()
if($test.MoveNext() -eq $False){return}

#パイプで渡されたのが「文字列」かどうかチェック
$html = @($input)
if(($html[0] -is [System.String]) -eq $False){}

$ie = new-object -com internetexplorer.application
$ie.visible = $true
[void]$ie.navigate2("about:blank")

while($ie.ReadyState -ne 4){}

for($i=0; $i -lt $html.length; $i++)
{
    [void]$ie.document.writeln([String]$html[$i])
}
[void]$ie.refresh()
return $ie
Sample(Beta3)

MSH C:\> get-date | convert-HTML | out-ie
Exception calling "writeln" with "1" argument(s): "種類が一致しません。
"
At D:\Doc\MSH\custom_cmdlet\out-ie.msh:19 char:31

  1. [void]$ie.document.writeln( <<<< [String]$html[$i])

あれ、「writeln」メソッドでエラーが出ているようです。
「writeln」メソッドの仕様or解釈の仕方が変更されたのでしょうか?
比較のため、Beta2、Beta3それぞれで、「writeln」メソッドの定義を調べてみましょう。

Writeln test on Beta2
MSH C:\> $ie = new-object -com internetexplorer.application
MSH C:\> $ie.visible = $true
MSH C:\> [void]$ie.navigate2("about:blank")
MSH C:\>  $ie.document.writeln


MemberType          : Method
OverloadDefinitions : {void writeln (SAFEARRAY(Variant))}
TypeOfValue         : System.Management.Automation.MshMethod
Value               : void writeln (SAFEARRAY(Variant))
Name                : writeln
IsInstance          : True
Writeln test on Beta3
MSH C:\> $ie = new-object -com internetexplorer.application
MSH C:\> $ie.visible = $true
MSH C:\> [void]$ie.navigate2("about:blank")
MSH C:\> $ie.document.writeln


MemberType          : Method
OverloadDefinitions : {System.Void writeln(Params Object[] psarray)}
TypeOfValue         : System.Management.Automation.MshMethod
Value               : System.Void writeln(Params Object[] psarray)
Name                : writeln
IsInstance          : True

なんと、引数の定義が変わっていますね。

  • Beta2
    • {void writeln (SAFEARRAY(Variant))}
  • Beta3
    • {System.Void writeln(Params Object[] psarray)}


むむむ・・・?