Repository navigation
Code Organization
Relevant source files
The following files were used as context for generating this wiki page:
This document describes the repository structure and file organization of the OfficeScrubC2R codebase. It explains where different types of files are located, how they are organized into directories, and the relationships between components.
For information about building the project from source, see Building from Source. For coding standards and conventions, see Development Guidelines.
The repository follows a flat structure at the root level for PowerShell modules, with subdirectories for documentation, testing, and CI/CD infrastructure.
graph TB
Root["/ (Repository Root)"]
Root --> PSM["OfficeScrubC2R.psm1<br/>Main PowerShell Module"]
Root --> PSD["OfficeScrubC2R.psd1<br/>Module Manifest"]
Root --> UTIL["OfficeScrubC2R-Utilities.psm1<br/>Nested Utilities Module"]
Root --> CS["OfficeScrubC2R-Native.cs<br/>C# Source Code"]
Root --> DLL["OfficeScrubNative.dll<br/>Pre-compiled Native Library"]
Root --> BUILD["build.ps1<br/>Build Script"]
Root --> Docs["docs/<br/>Documentation"]
Root --> GitHub[".github/<br/>CI/CD Infrastructure"]
Root --> Tests["tests/<br/>Test Suite"]
Root --> EnUS["en-US/<br/>Help Files"]
Root --> Release["release/<br/>Build Artifacts"]
Docs --> MemBank["memory-bank/<br/>Design Docs"]
Docs --> Source["source/<br/>Original VBS"]
GitHub --> Workflows["workflows/<br/>CI Pipelines"]
GitHub --> Scripts["scripts/<br/>Validation Scripts"]
Workflows --> CI["ci.yml"]
Scripts --> Validate["Validate-Module.ps1"]
Scripts --> Utils["utils.ps1"]
Tests --> TestScript["Test-OfficeScrubC2R.ps1"]
Tests --> Verify["Verify-NativeBuild.ps1"]
EnUS --> Help["about_OfficeScrubC2R.help.txt"]
style Root fill:#f9f9f9
style PSM fill:#e1f5ff
style CS fill:#ffe1e1
style DLL fill:#ffe1e1
Sources:
The root directory contains all PowerShell module files and the native C# library components. These files are organized to follow PowerShell Gallery module conventions.
| File | Purpose | Key Components |
|---|---|---|
OfficeScrubC2R.psd1 |
Module manifest with metadata, dependencies, and exports |
ModuleVersion, GUID, RootModule, NestedModules, FunctionsToExport
|
OfficeScrubC2R.psm1 |
Main module with exported functions |
Import-OfficeScrubNative, New-OfficeScrubOrchestrator, Test-OfficeC2RPath, Test-OfficeProductScope
|
OfficeScrubC2R-Utilities.psm1 |
Nested utilities module with helper functions |
Initialize-Environment, Initialize-Log, Write-Log, Get-InstalledProducts
|
| File | Purpose | Build Target |
|---|---|---|
OfficeScrubC2R-Native.cs |
C# source code (14,000+ lines) | Compilation input |
OfficeScrubNative.dll |
Pre-compiled native library | .NET Framework 4.5+ |
build.ps1 |
Build automation script | Compiles .cs to .dll
|
The native library contains these key classes: OfficeScrubOrchestrator, RegistryHelper, FileHelper, ProcessHelper, WindowsInstallerHelper, TypeLibHelper, LicenseHelper, ServiceHelper, ShellHelper, GuidHelper.
Sources:
Documentation is organized in the docs/ directory with two main subdirectories: memory-bank/ for design documentation and source/ for reference materials.
graph TB
DocsRoot["docs/"]
DocsRoot --> MB["memory-bank/<br/>Design Documentation"]
DocsRoot --> Src["source/<br/>Original Source"]
DocsRoot --> BuildDoc["BUILD.md"]
DocsRoot --> Changelog["CHANGELOG.md"]
DocsRoot --> Checklist["CHECKLIST.md"]
DocsRoot --> Contributing["CONTRIBUTING.md"]
DocsRoot --> RepoStruct["REPOSITORY_STRUCTURE.md"]
DocsRoot --> Setup["SETUP_COMPLETE.md"]
MB --> StructMD["structure.md<br/>Project Structure"]
MB --> TechMD["tech.md<br/>Technical Details"]
MB --> ProductMD["product.md<br/>Product Info"]
MB --> GuidelinesMD["guidelines.md<br/>Development Guidelines"]
Src --> VBS["OfficeScrubC2R.vbs<br/>Original Microsoft Script"]
Src --> SrcReadme["README<br/>Original Documentation"]
style DocsRoot fill:#f9f9f9
style MB fill:#e1f5ff
style Src fill:#ffe1e1
| Category | Files | Purpose |
|---|---|---|
| Design Docs | memory-bank/*.md |
Architecture, technical decisions, development patterns |
| Build Guides | BUILD.md |
Compilation instructions and requirements |
| Change History | CHANGELOG.md |
Version history following Keep a Changelog format |
| Contribution |
CONTRIBUTING.md, CHECKLIST.md
|
Developer guidelines and processes |
| Reference |
source/OfficeScrubC2R.vbs, source/README
|
Original Microsoft implementation |
Sources:
Build and continuous integration configuration is located in .github/ for GitHub Actions and the root-level build.ps1 script.
The build.ps1 script build.ps1:1-end orchestrates native library compilation:
- Locates
csc.exe(C# compiler) from .NET Framework installation - Compiles
OfficeScrubC2R-Native.cswith references to:-
System.Management.dll(WMI operations) -
Microsoft.CSharp.dll(dynamic operations)
-
- Outputs
OfficeScrubNative.dllto the module root directory
graph LR
GHRoot[".github/"]
GHRoot --> WF["workflows/"]
GHRoot --> SCR["scripts/"]
WF --> CI["ci.yml<br/>GitHub Actions Pipeline"]
SCR --> Val["Validate-Module.ps1<br/>Gallery Compatibility Checks"]
SCR --> Util["utils.ps1<br/>Build Helper Functions"]
CI --> TestJob["Test Job:<br/>Build + Import + Test"]
CI --> ValJob["Validate Job:<br/>Gallery Compatibility"]
TestJob --> BuildStep["Build Native DLL"]
TestJob --> ImportStep["Import Module"]
TestJob --> TestStep["Run Tests"]
ValJob --> ManifestCheck["Check Manifest"]
ValJob --> FilesCheck["Check Required Files"]
ValJob --> ZoneCheck["Check Zone Identifiers"]
style CI fill:#e1f5ff
style TestJob fill:#fff4e1
style ValJob fill:#ffe1e1
The CI pipeline .github/workflows/ci.yml:1-end runs two parallel jobs on pull requests and pushes to main branch:
- Test Job: Validates build process and module import on Windows Server 2022
- Validate Job: Ensures PowerShell Gallery publication requirements are met
Sources:
Test files are organized in the tests/ directory, with additional verification scripts in .github/scripts/.
| File | Purpose | Type |
|---|---|---|
tests/Test-OfficeScrubC2R.ps1 |
Main test suite | Functional tests |
tests/Verify-NativeBuild.ps1 |
Build verification | Build validation |
.github/scripts/Validate-Module.ps1 |
PowerShell Gallery checks | Compliance validation |
The test structure supports both manual testing via Pester and automated CI/CD validation.
Sources:
Repository-level configuration files control version control behavior, code analysis, and build exclusions.
| File | Purpose | Key Configuration |
|---|---|---|
.gitignore |
Git exclusion rules | Excludes *.dll (except OfficeScrubNative.dll), *.log, *.pdb, release/, artifacts/
|
.gitattributes |
Git file handling | Line ending normalization |
PSScriptAnalyzerSettings.psd1 |
PowerShell linting | Code quality rules and exclusions |
LICENSE |
MIT license | Distribution terms |
The .gitignore file .gitignore:1-59 explicitly includes the pre-compiled OfficeScrubNative.dll using the exception rule !OfficeScrubNative.dll .gitignore:54.
Sources:
The following diagram illustrates how source files depend on each other and the load order during module initialization.
graph TB
subgraph "Module Entry Point"
PSD1["OfficeScrubC2R.psd1<br/>Module Manifest"]
end
subgraph "PowerShell Layer"
PSM1["OfficeScrubC2R.psm1<br/>Main Module"]
UTIL["OfficeScrubC2R-Utilities.psm1<br/>Nested Module"]
end
subgraph "Native Layer"
DLL["OfficeScrubNative.dll<br/>Pre-compiled Binary"]
CS["OfficeScrubC2R-Native.cs<br/>Source Code"]
BuildScript["build.ps1<br/>Compilation"]
end
subgraph "Native Library Classes"
ORCH["OfficeScrubOrchestrator"]
REG["RegistryHelper"]
FILE["FileHelper"]
PROC["ProcessHelper"]
MSI["WindowsInstallerHelper"]
TLB["TypeLibHelper"]
LIC["LicenseHelper"]
SVC["ServiceHelper"]
SHELL["ShellHelper"]
GUID["GuidHelper"]
end
PSD1 -->|"RootModule ="| PSM1
PSD1 -->|"NestedModules ="| UTIL
PSM1 -->|"Import-Module"| UTIL
PSM1 -->|"Import-OfficeScrubNative()"| DLL
PSM1 -->|"Fallback Compile"| BuildScript
BuildScript -->|"Compiles"| CS
CS -->|"Produces"| DLL
DLL --> ORCH
DLL --> REG
DLL --> FILE
DLL --> PROC
DLL --> MSI
DLL --> TLB
DLL --> LIC
DLL --> SVC
DLL --> SHELL
DLL --> GUID
ORCH -->|"Uses"| REG
ORCH -->|"Uses"| FILE
ORCH -->|"Uses"| PROC
ORCH -->|"Uses"| MSI
ORCH -->|"Uses"| TLB
ORCH -->|"Uses"| LIC
ORCH -->|"Uses"| SVC
ORCH -->|"Uses"| SHELL
ORCH -->|"Uses"| GUID
style PSD1 fill:#e1f5ff
style PSM1 fill:#e1f5ff
style UTIL fill:#e1f5ff
style DLL fill:#ffe1e1
style ORCH fill:#fff4e1
-
Module Import: PowerShell reads
OfficeScrubC2R.psd1manifest -
Root Module Load: Loads
OfficeScrubC2R.psm1asRootModule -
Nested Module Import: Imports
OfficeScrubC2R-Utilities.psm1defined inNestedModules -
Native DLL Load:
Import-OfficeScrubNativefunction attempts to loadOfficeScrubNative.dll -
Fallback Compilation: If DLL load fails, executes
build.ps1to compile fromOfficeScrubC2R-Native.cs -
Orchestrator Creation:
New-OfficeScrubOrchestratorinstantiates the orchestrator with all helper classes
Sources:
The module has specific dependency requirements for different components.
The manifest OfficeScrubC2R.psd1 declares:
-
PowerShellVersion: Minimum
5.1 -
DotNetFrameworkVersion: Minimum
4.5 -
NestedModules:
@('OfficeScrubC2R-Utilities.psm1') -
RequiredAssemblies:
@('OfficeScrubNative.dll')
The C# source OfficeScrubC2R-Native.cs requires compilation references:
-
System.dll- Base .NET types -
System.Management.dll- WMI operations for services and licensing -
Microsoft.CSharp.dll- Dynamic operations and runtime binding
The build.ps1 script requires:
-
C# Compiler:
csc.exefrom .NET Framework 4.5+ installation -
Alternative:
dotnet buildfor .NET Core 7+ compilation -
Environment Variables:
ProgramFiles(x86)orProgramFilesfor locating compiler
Sources:
Build outputs and artifacts are organized into excluded directories to keep the repository clean.
| Directory | Purpose | Tracking |
|---|---|---|
release/ |
Release artifacts and packages |
.gitignore excluded |
artifacts/ |
CI/CD verification artifacts |
.gitignore excluded |
temp/, tmp/
|
Temporary build files |
.gitignore excluded |
TestResults/ |
Test execution results |
.gitignore excluded |
| File | Tracking | Reason |
|---|---|---|
OfficeScrubNative.dll |
Committed to repository | Pre-compiled for immediate use without build requirements |
The pre-compiled DLL OfficeScrubNative.dll is explicitly tracked .gitignore:54 to allow users to import the module without requiring the .NET Framework compiler or build tools.
Sources:
PowerShell help files are organized using standard PowerShell localization directory conventions.
en-US/
└── about_OfficeScrubC2R.help.txt # PowerShell help documentation
The en-US/ directory follows PowerShell's culture-specific help file structure, allowing for potential future localization into other languages using additional culture directories (e.g., de-DE/, fr-FR/).
Sources: