Open SeeminglyScience opened 6 years ago
I need better detection interfaces in method resolution. As a workaround you can cast it as an IEnumerable<>.
IEnumerable<>
using namespace System.Collections.Generic using namespace System.IO using namespace System.Reflection.PortableExecutable using namespace System.Reflection.Metadata $getNamespaceDelegate = [psdelegate]{ $fileStream = [FileStream]::new( [psobject].Assembly.Location, [FileMode]::Open, [FileAccess]::Read, [FileShare]::ReadWrite) with ($fileStream) { with ($peReader = [PEReader]::new($fileStream)) { $mdReader = $peReader.GetMetadataReader() # Here's the example $foundHandle = ([IEnumerable[TypeDefinitionHandle]]$mdReader.TypeDefinitions).First{ $handle => ($mdReader.GetString($mdReader.GetTypeDefinition($handle).Name) -eq 'PowerShell') } return $mdReader.GetString($mdReader.GetTypeDefinition($foundHandle).Namespace) } } } $getNamespaceDelegate.Invoke()
I need better detection interfaces in method resolution. As a workaround you can cast it as an
IEnumerable<>
.