Table of Contents

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

PowershellHelper

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

command string

Command to execute.

textBuilderFactory Func<bool, TextBuilderPS>

Factory function for creating a TextBuilderPS.

Returns

Task

DetectLanguageForFileGithubLinguist(string)

Detects the programming language of a file using GitHub Linguist via WSL.

public Task<string?> DetectLanguageForFileGithubLinguist(string windowsPath)

Parameters

windowsPath string

Windows file path to analyze.

Returns

Task<string>

Detected language name, or null if not found.

FindDuplicatedMethodsInPs1File(List<PowershellMethod>)

Finds duplicated method names in a parsed PowerShell script.

public static string FindDuplicatedMethodsInPs1File(List<PowershellMethod> methods)

Parameters

methods List<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

powerShellCode string

PowerShell 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()

Returns

List<string>

List of process names.