-
-
Notifications
You must be signed in to change notification settings - Fork 0
Developer Guide
- Visual Studio 2022 (Community Edition works fine) or VS Code or JetBrains Rider.
- .NET Framework 4.8 Developer Pack.
- Streamer.bot (latest version recommended, minimum v0.2.3).
/
├── GiveawayBot.cs # Main script file (The Bot)
├── _tests/ # Unit and integration tests
├── .github/ # CI/CD and templates
├── docs/ # Documentation
├── examples/ # Configuration examples
└── StreamerBot.csproj # Project file for IntelliSense
The project references Streamer.bot DLLs (StreamerBot.Plugin.Interface.dll, StreamerBot.Common.dll).
These are not included in the repo. You must adhere to the Setup instructions
in [CONTRIBUTING.md](.. CONTRIBUTING.md) to point the project to your local
Streamer.bot installation.
Streamer.bot compiles C# code using Roslyn with a language version target of 7.3. This is a hard constraint tied to Streamer.bot's runtime environment. If Streamer.bot upgrades to a newer .NET runtime, this project will adopt modern C# features accordingly.
This project enforces C# 7.3 compatibility at multiple layers:
-
Build Time:
StreamerBot.csprojsets<LangVersion>7.3</LangVersion>to prevent compilation of C# 8.0+ code -
IDE:
.editorconfigsuppresses suggestions for C# 8.0+ features -
Pre-Commit: Git hook (
.git/hooks/pre-commit) scans staged files for C# 8.0+ features before allowing commits
- Async/await
- LINQ (Standard)
- Tuples (ValueTuple)
- Local functions
-
??=(Null-coalescing assignment) → Useif (x == null) x = value; -
new()(Target-typed new) -> Usenew ClassName() -
recordtypes -> Useclassorstruct -
using var-> Useusing (...) { } -
switchexpressions -> Useswitchstatements - Nullable reference types (
string?) -> Just usestring(and assume it can be null) - File-scoped namespace -> Use block-scoped namespace
-
#nullablepragma -> Not supported
The .editorconfig file is heavily tuned to hide suggestions for these modern features.
We use a custom test runner in _tests/ because standard testing frameworks
(NUnit/xUnit) are hard to integrate with the
single-file script format and Streamer.bot's environment.
Open the _tests folder in a terminal:
dotnet run- Open
_tests/TestRunner.cs. - Add a new method
async Task YourTestName(MockCPH cph). - Register it in the
_testsarray inMain.
Since the bot runs inside Streamer.bot, traditional debugging is difficult.
-
Logging: Use
CPH.LogInfo()/CPH.LogDebug(). These appear in the Streamer.bot Log tab. -
File Logging: The bot uses
FileLoggerto write toGiveaway Helper/logs/. Check these files for detailed persistence and logic traces. -
Unit Tests: The
MockCPHallows you to step through code in your IDE (VS Code/Visual Studio) without running Streamer.bot. This is the best way to debug logic.
To debug the code running in Streamer.bot:
- Compile the code in Streamer.bot (click "Compile").
- In VS/Rider, "Attach to Process".
- Select
Streamer.bot.exe. - Note: usage of breakpoints might fail if the compiled assembly doesn't match source exactly.
We use a fully automated PR-based release workflow.
Run the auto-release script from your local machine:
# Syntax: .\tools\auto-release.ps1 -Version <NEW_VERSION>
.\tools\auto-release.ps1 -Version 1.6.0This script will:
- Update all version files (
VERSION,.csproj,.cs) - Update
CHANGELOG.md - Create a temporary branch and open a Pull Request
- Review the created Pull Request on GitHub.
- Merge the PR into
main. - The automated workflow will detect the merge, tag the commit, and publish the release to GitHub Releases.
The tools/ directory contains several scripts to assist with development:
-
auto-release.ps1: Orchestrates the entire release process. -
update-version.ps1: Manually bumps version numbers across all files. -
install-hooks.ps1: Installs git hooks to prevent committing version mismatches. -
GenerateWiki.exe: Generates documentation from source code comments.