|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +MelonAccessibilityLib is a C# library that adds screen reader accessibility to Unity games via MelonLoader mods. It provides speech management, text cleaning utilities, and P/Invoke wrappers for UniversalSpeech with SAPI fallback. |
| 8 | + |
| 9 | +## Build Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +# Build all target frameworks (net6.0, net472, net35) |
| 13 | +dotnet build |
| 14 | + |
| 15 | +# Build specific framework |
| 16 | +dotnet build -f net6.0 |
| 17 | +dotnet build -f net472 |
| 18 | +dotnet build -f net35 |
| 19 | + |
| 20 | +# Release build |
| 21 | +dotnet build -c Release |
| 22 | + |
| 23 | +# Create NuGet package |
| 24 | +dotnet pack -c Release |
| 25 | +``` |
| 26 | + |
| 27 | +Build outputs are located at `bin/{Debug|Release}/{net6.0|net472|net35}/MelonAccessibilityLib.dll`. |
| 28 | + |
| 29 | +## Testing |
| 30 | + |
| 31 | +No test framework is currently configured. If adding tests, use standard `dotnet test` commands. |
| 32 | + |
| 33 | +## Architecture |
| 34 | + |
| 35 | +### Component Overview |
| 36 | + |
| 37 | +- **SpeechManager** (`SpeechManager.cs`): High-level static API for speech output with duplicate prevention, repeat functionality, and text formatting |
| 38 | +- **UniversalSpeechWrapper** (`UniversalSpeechWrapper.cs`): Low-level P/Invoke wrapper for UniversalSpeech.dll with SAPI fallback |
| 39 | +- **TextCleaner** (`TextCleaner.cs`): Removes Unity rich text tags and normalizes text for screen reader output |
| 40 | +- **AccessibilityLog/IAccessibilityLogger** (`IAccessibilityLogger.cs`): Logging facade with pluggable logger interface |
| 41 | +- **Net35Extensions** (`Net35Extensions.cs`): Polyfills for .NET 3.5 compatibility (e.g., `IsNullOrWhiteSpace`) |
| 42 | + |
| 43 | +### Data Flow |
| 44 | + |
| 45 | +``` |
| 46 | +Consumer (MelonMod) |
| 47 | + │ |
| 48 | + ├─ Sets AccessibilityLog.Logger |
| 49 | + ├─ Calls SpeechManager.Initialize() |
| 50 | + └─ Calls SpeechManager.Output() |
| 51 | + │ |
| 52 | + ├─ Duplicate suppression (time-based) |
| 53 | + ├─ TextCleaner.Clean() (strips rich text) |
| 54 | + └─ UniversalSpeechWrapper.Speak() (P/Invoke) |
| 55 | +``` |
| 56 | + |
| 57 | +### Extensibility Points |
| 58 | + |
| 59 | +- **Custom Logger**: Implement `IAccessibilityLogger` interface |
| 60 | +- **Text Formatting**: Set `SpeechManager.FormatTextOverride` delegate |
| 61 | +- **Repeat Logic**: Set `SpeechManager.ShouldStoreForRepeatPredicate` delegate |
| 62 | +- **Custom Text Types**: Use constants starting from `TextType.CustomBase` (100) |
| 63 | + |
| 64 | +## Key Conventions |
| 65 | + |
| 66 | +- All public classes are static (no instance creation) |
| 67 | +- Private fields use `_camelCase` prefix |
| 68 | +- P/Invoke constants use `ALL_CAPS` |
| 69 | +- Single namespace: `MelonAccessibilityLib` |
| 70 | +- Comprehensive XML documentation on all public members |
| 71 | +- Multi-target build: net35 is limited to C# 7.3 features |
| 72 | + |
| 73 | +## Platform Requirements |
| 74 | + |
| 75 | +- Windows only (P/Invoke and SAPI are Windows-specific) |
| 76 | +- UniversalSpeech.dll must be deployed alongside consuming mod |
| 77 | +- Supports screen readers: NVDA, JAWS, Window-Eyes, System Access, Supernova, ZoomText |
0 commit comments