Last active
July 14, 2025 07:28
-
-
Save Hashbrown777/fdfd4853f2620be8fe9a11eb9c6a7b15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Gets the methods you need to override to create a subclass of the given type | |
Filter GetOverrides { Param($filter) | |
if (!$filter) { | |
$filter = [System.Reflection.MethodAttributes]::Virtual -bor [System.Reflection.MethodAttributes]::Abstract | |
} | |
$type = $_ | |
$type.GetMembers() ` | |
| ?{ $_.DeclaringType -eq $type -and $_.Attributes -band $filter } ` | |
| Sort-Object -Property 'Name' ` | |
| PrintMembers | |
} | |
#Gets the declared properties and methods of an object (&/or those declared by the given superclass) | |
Filter GetMembers { Param($type) | |
if (!$type) { | |
$type = @() | |
} | |
elseif ($type -isnot [array]) { | |
$type = @($type) | |
} | |
$type += @($_.GetType()) | |
$type[-1].GetMembers() ` | |
| ?{ $_.DeclaringType -in $type } ` | |
| Sort-Object -Property 'Name' ` | |
| PrintMembers | |
} | |
Filter PrintMembers { | |
'' | |
if (!$_.GetParameters) { | |
"[$($_.PropertyType.Name)] $($_.Name)" | |
return | |
} | |
$return = '' | |
if ($_.ReturnType -ne [void]) { | |
$return = "[$($_.ReturnType.Name)] " | |
} | |
$params = $_.GetParameters() | |
if (!$params.Count) { | |
"$return$($_.Name)()" | |
return | |
} | |
"$return$($_.Name)(" | |
$params ` | |
| &{ | |
Begin { | |
$last = $NULL | |
} | |
Process { | |
$next = "`t[$($_.ParameterType.Name)]`t$($_.Name)" | |
if ($last) { | |
"$last," | |
} | |
$last = $next | |
} | |
End { | |
if ($last) { | |
$last | |
} | |
} | |
} | |
')' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment