Class PowershellHelper
- Namespace
- SunamoPS
- Assembly
- SunamoPS.dll
Helper class providing PowerShell utility methods for process listing, language detection, and script parsing.
public class PowershellHelper
- Inheritance
-
PowershellHelper
- Inherited Members
- Extension Methods
Properties
Instance
Singleton instance of PowershellHelper.
public static PowershellHelper Instance { get; }
Property Value
Methods
CmdC(string, Func<bool, TextBuilderPS>)
Executes a command via cmd /c in a PowerShell session.
public Task CmdC(string command, Func<bool, TextBuilderPS> textBuilderFactory)
Parameters
commandstringCommand to execute.
textBuilderFactoryFunc<bool, TextBuilderPS>Factory function for creating a TextBuilderPS.
Returns
DetectLanguageForFileGithubLinguist(string)
Detects the programming language of a file using GitHub Linguist via WSL.
public Task<string?> DetectLanguageForFileGithubLinguist(string windowsPath)
Parameters
windowsPathstringWindows file path to analyze.
Returns
FindDuplicatedMethodsInPs1File(List<PowershellMethod>)
Finds duplicated method names in a parsed PowerShell script.
public static string FindDuplicatedMethodsInPs1File(List<PowershellMethod> methods)
Parameters
methodsList<PowershellMethod>List of parsed PowerShell methods.
Returns
- string
Formatted string listing method names and their line numbers.
ParseMethods(string)
Parses PowerShell code into a list of method definitions with their names, bodies, and line numbers.
public static List<PowershellMethod> ParseMethods(string powerShellCode)
Parameters
powerShellCodestringPowerShell source code to parse.
Returns
- List<PowershellMethod>
List of parsed PowerShell methods.
ProcessNames()
Gets the names of all currently running processes.
public List<string> ProcessNames()