ExtendedModuleInfo.ps1
|
# Copyright (c) Matthias Wolf, Mawosoft. using namespace System using namespace System.Collections.Generic using namespace System.Reflection using namespace System.Management.Automation <# Provides extended infos about script modules. #> class ExtendedModuleInfo { # The primary module this info applies to. [psmoduleinfo]$Module # All modules that have been merged into this info or null if not merged. [List[ExtendedModuleInfo]]$MergedModules # The implementing assemblies (typedefs). [HashSet[Assembly]]$Assemblies # Module scope functions [Dictionary[string, FunctionInfo]]$Functions # Module scope variables [Dictionary[string, psvariable]]$Variables # Explicit 'script:myvar' variables detected during parsing. # These can be used to filter Variables to exlude implicit definitions. [HashSet[string]]$ScriptVariables # Module scope types [Dictionary[string, type]]$Types # Script files collected from module path, functions, and type assemblies. # Dot-sourced files that contain neither will not appear here. [HashSet[string]]$ScriptFiles hidden static [StringComparer]$s_pathComparer static ExtendedModuleInfo() { [ExtendedModuleInfo]::s_pathComparer = [StringComparer]::OrdinalIgnoreCase try { if ($global:PSVersionTable.PSVersion.Major -ge 6 -and $global:IsLinux) { [ExtendedModuleInfo]::s_pathComparer = [StringComparer]::Ordinal } } catch { } } ExtendedModuleInfo() { # Init properties here for better readability. $this.Assemblies = [HashSet[Assembly]]::new() $this.Functions = [Dictionary[string, FunctionInfo]]::new([StringComparer]::OrdinalIgnoreCase) $this.Variables = [Dictionary[string, psvariable]]::new([StringComparer]::OrdinalIgnoreCase) $this.ScriptVariables = [HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase) $this.Types = [Dictionary[string, type]]::new([StringComparer]::OrdinalIgnoreCase) $this.ScriptFiles = [HashSet[string]]::new([ExtendedModuleInfo]::s_pathComparer) } } |