|
| 1 | +# SoundSwitch GitHub Copilot Instructions |
| 2 | + |
| 3 | +## Project Architecture |
| 4 | + |
| 5 | +SoundSwitch is a Windows application for switching audio playback and recording devices using hotkeys. It's built with .NET on the Windows platform. |
| 6 | + |
| 7 | +### Core Components |
| 8 | + |
| 9 | +- **SoundSwitch (Main Project)**: The core application handling UI, notifications, and user interaction |
| 10 | +- **SoundSwitch.Audio.Manager**: Manages audio device switching using NAudio and Windows APIs |
| 11 | +- **SoundSwitch.Common**: Shared utilities and framework components |
| 12 | +- **SoundSwitch.CLI**: Command-line interface for controlling SoundSwitch |
| 13 | +- **SoundSwitch.IPC**: Inter-process communication for integration with other applications |
| 14 | +- **SoundSwitch.UI.Menu**: UI menu components for the system tray and application |
| 15 | +- **SoundSwitch.Bluetooth**: Bluetooth device management |
| 16 | +- **SoundSwitch.UI.UserControls**: Reusable UI controls |
| 17 | + |
| 18 | +### Architectural Patterns |
| 19 | + |
| 20 | +- **Model-View-Controller**: The application follows MVC pattern with separation of concerns |
| 21 | +- **Event-driven architecture**: Heavy use of event handling for device changes and hotkey detection |
| 22 | +- **Dependency Injection**: Used to manage component dependencies |
| 23 | +- **Job Scheduling**: Used for background tasks and recurring operations |
| 24 | + |
| 25 | +## Development Guidelines |
| 26 | + |
| 27 | +### Coding Standards |
| 28 | + |
| 29 | +1. Classes should use proper XML documentation |
| 30 | +2. Follow C# naming conventions (PascalCase for public members, camelCase for private) |
| 31 | +3. Extract interfaces for testable components |
| 32 | +4. Include copyright notices at the top of source files |
| 33 | + |
| 34 | +### Error Handling |
| 35 | + |
| 36 | +- Use structured exception handling with appropriate logging |
| 37 | +- Prefer using the `Result<T>` pattern from RailSharp for indicating success/failure |
| 38 | +- Log errors with Serilog |
| 39 | + |
| 40 | +### Localization |
| 41 | + |
| 42 | +- All user-facing strings should be localized |
| 43 | +- Use resource files (.resx) for localization |
| 44 | +- Support for right-to-left languages |
| 45 | + |
| 46 | +### Audio Device Management |
| 47 | + |
| 48 | +- Use NAudio for audio device enumeration and control |
| 49 | +- Handle device addition/removal events |
| 50 | +- Support both playback and recording devices |
| 51 | + |
| 52 | +### Settings Management |
| 53 | + |
| 54 | +- Use AppConfigs.Configuration for persistent settings |
| 55 | +- Settings should be automatically saved when changed |
| 56 | + |
| 57 | +### Hotkey Registration |
| 58 | + |
| 59 | +- Use the WindowsAPIAdapter for hotkey registration |
| 60 | +- Handle conflicts with other applications |
| 61 | +- Support customizable hotkeys |
| 62 | + |
| 63 | +## Project Structure |
| 64 | + |
| 65 | +- Use separate assembly projects for distinct functionality |
| 66 | +- Tests should be in corresponding test projects |
| 67 | +- UI components should be separated from business logic |
| 68 | + |
| 69 | +## Important Interfaces |
| 70 | + |
| 71 | +- `IAudioDeviceLister`: For enumerating audio devices |
| 72 | +- `IAppModel`: Main model interface for application state |
| 73 | +- `INotificationManager`: Handles user notifications |
| 74 | +- `IProfileManager`: Manages device switching profiles |
| 75 | + |
| 76 | +## Testing |
| 77 | + |
| 78 | +- Use unit tests for core functionality |
| 79 | +- Mock external dependencies |
| 80 | +- Test all device operations |
| 81 | + |
| 82 | +## Deployment |
| 83 | + |
| 84 | +- Support multiple release channels (Stable, Beta, Nightly) |
| 85 | +- Use GitHub Actions for CI/CD |
| 86 | +- Sign executables with certificate |
| 87 | + |
| 88 | +## When Contributing |
| 89 | + |
| 90 | +1. Target the latest .NET version supported by the project |
| 91 | +2. Test changes thoroughly across different Windows versions |
| 92 | +3. Use GitHub flow for contributions (feature branches and PRs) |
| 93 | +4. Update documentation and CHANGELOG.md with significant changes |
| 94 | + |
| 95 | +## DeviceFullInfo |
| 96 | + |
| 97 | +Never use the Name property. Always use the NameClean property instead. Ensure that any handling of device names is done using NameClean to avoid potential issues with formatting or invalid characters. |
0 commit comments