Last active
September 21, 2024 16:24
-
-
Save eugrus/a4a0cd8967a309a13f77cb516ef2b955 to your computer and use it in GitHub Desktop.
Gives a look into objects inside a .NET assembly
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
param ([string]$dllname) | |
Add-Type -Path "$dllname" | |
$classes = [System.Reflection.Assembly]::LoadFile("$dllname").GetTypes() | Where-Object {$_.IsClass} | |
foreach ($class in $classes) { | |
Write-Host "- Class: $($class.FullName)" | |
$fields = $class.GetFields() | |
if ($fields.Count -gt 0) { | |
Write-Host "-- Fields:" | |
foreach ($field in $fields) { | |
Write-Host "--- Field: $($field.Name) ($($field.FieldType.Name))" | |
} | |
} else { | |
Write-Host "-- No fields" | |
} | |
$methods = $class.GetMethods() | |
foreach ($method in $methods) { | |
$parameters = $method.GetParameters() | ForEach-Object { "$($_.ParameterType.Name) $($_.Name)" } | |
$paramString = if ($parameters) { [string]::Join(", ", $parameters) } else { "No parameters" } | |
Write-Host "-- Method: $($method.Name) ($paramString)" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment