-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Languageparser, language semanticsparser, language semantics
Description
Steps to reproduce
using namespace System.Management.Automation
class Y{
[int] $Id
}
class X{
static [void] OpenUri([psobject] $obj) {
$id = $obj.Id
start-process "http://baseuri/$id"
}
static [void] UpdateTypeData(){
$td = [Runspaces.Typedata]::new([Y])
$td.Members.Add("OpenUri",
[Runspaces.CodeMethodData]::new("OpenUri", [X]::GetMethodInfo([X], "OpenUri")));
Update-TypeData -TypeData $td -Force
}
hidden static [Reflection.MethodInfo] GetMethodInfo([Type] $type, [string] $method) {
return $type.GetMethod($method, [Reflection.BindingFlags]::Static -bor [Reflection.BindingFlags]::Public -bor [Reflection.BindingFlags]::IgnoreCase);
}
}
[X]::UpdateTypeData()
$y = [Y]::new()
#works
$y | % OpenUri
#fails with No coercion operator is defined between types 'System.Void' and 'System.Object'.
$y.OpenUri()
Expected behavior
Same behavior invoking method with dot syntax as when invoked via Foreach-Object -MemberName
Actual behavior
fails with
No coercion operator is defined between types 'System.Void' and 'System.Object'.
At line:1 char:1
+ $y.OpenUri()
PS C:\Program Files\PowerShell\6.0.0-beta.6> $y | gm
TypeName: Y
Name MemberType Definition
---- ---------- ----------
OpenUri CodeMethod static void OpenUri(psobject obj)
Environment data
All versions (beta 6 and win 5.1)
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Languageparser, language semanticsparser, language semantics