Prelude is a PowerShell "standard" library providing utilities, helpers, functions, type accelerators, and aliases inspired by functional programming language preludes. It supports linear algebra, graph theory, data analysis, and system automation.
Prelude/- PowerShell module sourcePrelude.psd1- Module manifestPrelude.psm1- Module entry pointsrc/- Source files organized by functionalitycore.ps1- Core functionsapplication.ps1- Application utilitiesdata.ps1- Data manipulationgraph.ps1- Graph theory implementationsmatrix.ps1- Linear algebra/matrix operationsproductivity.ps1- Productivity helpersweb.ps1- Web utilities
Plus/- Extended functionalitytypes/- Custom type definitionsformats/- PowerShell formatting files
csharp/- C# implementations for performanceTests/- .NET unit testsGraph/,Matrix/, etc. - Domain-specific implementations
tests/- PowerShell Pester tests*.Tests.ps1- Test files corresponding tosrc/modules
docs/,examples/- Documentation and examplesstyles/- Code quality/linting rules (alex, proselint, etc.)
Prelude.psd1- PowerShell module manifest (defines exports)PSScriptAnalyzerSettings.psd1- PSScriptAnalyzer configurationstryker-config.json- Mutation testing configurationappveyor.yml- CI/CD configurationcodecov.yml- Code coverage configuration
- Located in
Prelude/src/organized by feature area - Functions follow verb-noun naming:
Get-Something,Set-Something,New-Something - Must be exported in
Prelude.psd1underFunctionsToExport - Should have Comment-Based Help (CBH) with
.SYNOPSIS,.DESCRIPTION,.PARAMETER,.EXAMPLE
- Located in
csharp/with corresponding project files (.csproj) - Performance-critical code is implemented in C#
- Tests in
csharp/Tests/Tests.csprojusing standard .NET testing - Classes follow PascalCase naming
- PowerShell tests:
tests/*.Tests.ps1using Pester framework - .NET tests:
csharp/Tests/*.Tests.cs - Test files should mirror source file names
- Run tests with build tasks (see below)
- PowerShell scripts analyzed with PSScriptAnalyzer
- Configuration:
PSScriptAnalyzerSettings.psd1 - Custom rules:
PSScriptAnalyzerCustomRules.psm1 - StyleCop used for C# (config:
stylecop.json)
Available VS Code tasks (run with Ctrl+Shift+B or via task runner):
- build - Compile .NET projects:
dotnet build csharp/Tests/Tests.csproj - watch - Watch mode:
dotnet watch run csharp/Tests/Tests.csproj - publish - Publish:
dotnet publish csharp/Tests/Tests.csproj
The main task execution script is ./Invoke-Task.ps1. Run any task using switch parameters:
Setup Scripts:
./Invoke-Setup.ps1- Install/configure development dependencies./Invoke-FixPesterSetup.ps1- Fix Pester installation issues
Lint - Analyze and format code
./Invoke-Task.ps1 -Lint # Lint PowerShell and C# code with auto-fix
./Invoke-Task.ps1 -Lint -Skip dotnet # Lint only PowerShell code
./Invoke-Task.ps1 -Lint -Skip powershell # Lint only C# code
./Invoke-Task.ps1 -Lint -DryRun # Analyze without making changes
./Invoke-Task.ps1 -Lint -CI # Run in CI modeRuns PSScriptAnalyzer on PowerShell (Prelude/src/ and Prelude/Plus/) and dotnet-format on C# code. Configuration: PSScriptAnalyzerSettings.psd1, PSScriptAnalyzerCustomRules.psm1.
Test - Run unit tests
./Invoke-Task.ps1 -Test # Run all tests
./Invoke-Task.ps1 -Test -Skip powershell # Run only C# tests
./Invoke-Task.ps1 -Test -Skip dotnet # Run only PowerShell Pester tests
./Invoke-Task.ps1 -Test -WithCoverage # Run tests with code coverage
./Invoke-Task.ps1 -Test -WithCoverage -GenerateCoverageReport # Generate coverage report
./Invoke-Task.ps1 -Test -Tags Remote # Run only tests tagged 'Remote'
./Invoke-Task.ps1 -Test -Exclude WindowsOnly # Exclude tests tagged 'WindowsOnly'
./Invoke-Task.ps1 -Test -Filter '*Readability*' # Run tests matching filter pattern
./Invoke-Task.ps1 -Test -Platform linux # Run tests for LinuxRuns Pester tests (tests/*.Tests.ps1) and .NET tests (csharp/Tests/Tests.csproj). Coverage reports can be viewed at .\coverage\index.htm.
Build - Compile C# and create link libraries
./Invoke-Task.ps1 -Build # Format, test, and build link libraries
./Invoke-Task.ps1 -Build -BuildOnly # Skip formatting and testing
./Invoke-Task.ps1 -Build -Version 2019 # Use Visual Studio 2019
./Invoke-Task.ps1 -Build -Architecture x86 # Build for 32-bit architectureFormats C# code, runs tests, builds link libraries saved to Prelude/bin/. Requires Visual Studio and compiler (csc.exe). Supports 2019 and 2022 editions.
Publish - Publish module to PowerShell Gallery
./Invoke-Task.ps1 -Publish # Bump build version and publish
./Invoke-Task.ps1 -Publish -Minor # Bump minor version (e.g., 1.1.1 -> 1.2.0)
./Invoke-Task.ps1 -Publish -Major # Bump major version (e.g., 1.1.1 -> 2.0.0)
./Invoke-Task.ps1 -Publish -DryRun # Simulate publishing without making changesUpdates module version in Prelude.psd1 and publishes to PowerShell Gallery. Requires valid $Env:NUGET_API_KEY. Version bump defaults to build increment if no flag specified.
Check - Verify development environment
./Invoke-Task.ps1 -Check # Check environment against VS 2022 Community
./Invoke-Task.ps1 -Check -Version 2019 # Check against VS 2019Validates that the environment has necessary tools and dependencies for Prelude development.
Mutate - Run Stryker mutation tests
./Invoke-Task.ps1 -Mutate -Project Matrix # Run mutation tests on Matrix project
./Invoke-Task.ps1 -Mutate -Project Graph # Run mutation tests on Graph project
./Invoke-Task.ps1 -Mutate -Project Geodetic # Run mutation tests on Geodetic projectExecutes mutation testing using Stryker (configured in stryker-config.json). Supported projects: Matrix, Graph, Geodetic. Opens report in browser after completion.
Benchmark - Run C# performance benchmarks
./Invoke-Task.ps1 -Benchmark # Run all benchmarksExecutes BenchmarkDotNet benchmarks from csharp/Performance/Performance.csproj in Release mode.
The Prelude.psd1 file defines module exports:
CmdletsToExport = @(...) # Exported cmdlets
FunctionsToExport = @(...) # Exported functions
AliasesToExport = @(...) # Exported aliases
VariablesToExport = @(...) # Exported variablesImportant: When adding new functions, add them to the appropriate export list in Prelude.psd1.
- Create or add function to appropriate file in
Prelude/src/ - Add to
FunctionsToExportinPrelude.psd1 - Create corresponding test in
tests/ - Add Comment-Based Help to function
- Remove function definition from
Prelude/src/ - Remove from export lists in
Prelude.psd1 - Remove or update corresponding tests
- Edit in
csharp/<component>/folder - Compile with build task
- Update tests if behavior changes
| File | Purpose |
|---|---|
| Prelude/Prelude.psd1 | Module manifest - defines all exports |
| Prelude/Prelude.psm1 | Module initialization and setup |
| Prelude/src/core.ps1 | Core utilities and foundational functions |
| tests/_setup.ps1 | Pester test setup and imports |
| PSScriptAnalyzerSettings.psd1 | Code style rules |
- Module exports: Always synchronize function definitions with
Prelude.psd1exports - Test coverage: Maintain tests alongside function implementations
- Documentation: Use Comment-Based Help for all public functions
- Naming conventions: Follow PowerShell verb-noun standards
- Performance: Consider C# implementations for computationally intensive operations