feat: Add automated compilation validation for C# code examples#350
Open
currantw wants to merge 18 commits intovalkey-io:mainfrom
Open
feat: Add automated compilation validation for C# code examples#350currantw wants to merge 18 commits intovalkey-io:mainfrom
currantw wants to merge 18 commits intovalkey-io:mainfrom
Conversation
Signed-off-by: currantw <taylor.curran@improving.com>
…uses`. Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
currantw
commented
Apr 24, 2026
currantw
commented
Apr 24, 2026
currantw
commented
Apr 24, 2026
currantw
commented
Apr 24, 2026
There was a problem hiding this comment.
Pull request overview
Adds CI/local tooling to automatically extract C# XML-doc <example><code> snippets from sources/ and validate them by compiling against the built Valkey.Glide.dll, while updating existing doc examples to compile cleanly under the new validator.
Changes:
- Added
scripts/check_examples.pyto extract examples and compile-check them via a temporary .NET project. - Added
task check-examplesand a newcheck-examplesGitHub Actions workflow to run the validator in CI. - Updated numerous XML doc examples and a few small internal/formatting items to eliminate compilation failures.
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sources/Valkey.Glide/PubSubSubscriptionConfig.cs | Fixes an XML doc comment formatting issue that would break example extraction/parsing. |
| sources/Valkey.Glide/Internals/GuardClauses.cs | Removes a stream trim-mode guard helper (moved elsewhere). |
| sources/Valkey.Glide/Internals/FFI.structs.cs | Adds TODO notes on struct immutability/constructors (no functional change). |
| sources/Valkey.Glide/Commands/ITransactionClusterCommands.cs | Updates doc example variable names to align with cluster client usage. |
| sources/Valkey.Glide/Commands/ISortedSetBaseCommands.cs | Updates doc examples to use concrete keys/values so they compile. |
| sources/Valkey.Glide/Commands/ISetBaseCommands.cs | Updates doc examples to use concrete keys/values so they compile. |
| sources/Valkey.Glide/Commands/IListBaseCommands.cs | Updates doc examples (types/keys) to compile under validation harness. |
| sources/Valkey.Glide/Commands/IHashBaseCommands.cs | Updates hash command examples to compile (concrete values; fixes malformed tags). |
| sources/Valkey.Glide/Commands/IGenericCommands.cs | Updates batch/pipeline examples to match current async batch APIs/options. |
| sources/Valkey.Glide/Commands/IGenericClusterCommands.cs | Updates cluster batch/custom command examples to match current APIs and compile. |
| sources/Valkey.Glide/Client/IGlideClusterClient.cs | Adjusts cluster client examples to match ClusterValue API and null handling. |
| sources/Valkey.Glide/Client/IGlideClusterClient.ServerManagementCommands.cs | Updates Info/server-management examples for compilation and correct LINQ usage. |
| sources/Valkey.Glide/Client/IGlideClusterClient.ScriptingAndFunctionCommands.cs | Updates scripting/function examples (routes, payload variables) for compilation. |
| sources/Valkey.Glide/Client/IGlideClient.cs | Updates examples to define typed keys used by APIs. |
| sources/Valkey.Glide/Client/IGlideClient.ServerManagementCommands.cs | Updates example to avoid unsupported syntax and compile reliably. |
| sources/Valkey.Glide/Client/IBaseClient.SortedSetCommands.cs | Updates scan example to define a key variable for compilation. |
| sources/Valkey.Glide/Client/IBaseClient.SetCommands.cs | Updates scan example to define a key variable for compilation. |
| sources/Valkey.Glide/Client/IBaseClient.ServerManagementCommands.cs | Updates examples to declare locals/arrays explicitly for compilation. |
| sources/Valkey.Glide/Client/IBaseClient.ScriptingAndFunctionCommands.cs | Updates scripting/function examples to include required local variables. |
| sources/Valkey.Glide/Client/IBaseClient.PubSubCommands.cs | Updates pub/sub examples to use ValkeyKey[] where required. |
| sources/Valkey.Glide/Client/IBaseClient.ListCommands.cs | Updates list command examples with concrete keys/values and compilable literals. |
| sources/Valkey.Glide/Client/IBaseClient.GenericCommands.cs | Updates generic command examples to be compilable and more explicit in outputs. |
| sources/Valkey.Glide/Client/IBaseClient.BitmapCommands.cs | Updates bitmap/bitfield examples to match current option/type names and compile. |
| sources/Valkey.Glide/Client/GlideClusterClient.cs | Updates client-creation example to avoid removed using static pattern and compile. |
| sources/Valkey.Glide/Client/GlideClient.cs | Updates client-creation example to avoid removed using static pattern and compile. |
| sources/Valkey.Glide/Abstract/IServer.cs | Updates IServer examples to use correct receiver/return types and compile. |
| sources/Valkey.Glide/Abstract/IDatabaseAsync.ListCommands.cs | Splits/adjusts examples and updates inheritdoc references to compile and resolve correctly. |
| sources/Valkey.Glide/Abstract/Database.StreamCommands.cs | Moves trim-mode guard into Database and adds helper documentation. |
| scripts/check_examples.py | Adds extractor + compiler harness generator to validate examples via dotnet build. |
| Taskfile.yml | Adds check-examples task for local execution. |
| .gitignore | Ignores Python bytecode artifacts for the new script. |
| .github/workflows/check-examples.yml | Adds CI workflow to build GLIDE and run task check-examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: currantw <taylor.curran@improving.com>
currantw
commented
Apr 24, 2026
currantw
commented
Apr 24, 2026
currantw
commented
Apr 24, 2026
Signed-off-by: currantw <taylor.curran@improving.com>
currantw
commented
Apr 24, 2026
Signed-off-by: currantw <taylor.curran@improving.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add automated compilation validation for C# code examples in XML doc comments:
task check-examplescommand and GitHubcheck-examplesworkflow.NOTE: This pull request is only intended to add validation of examples. Add new examples and ensuring examples are consistent will be completed in #340.
Issue Link
Closes #347
Features and Behaviour Changes
scripts/check_examples.pyscript with two classes:ExampleExtractor: scans.csfiles undersources/and extracts code examples from XML doc comments using multi-line regex.ExampleChecker: generates a temporary .NET project referencing the builtValkey.Glide.dll, wraps each example in a compilable C# class, runsdotnet build, and reports compilation errors mapped back to source file and line number.task check-examplesTaskfile entry for local execution.check-examplesGitHub Actions workflow that runs on push/PR to validate examples in CI.--examplesflag to load examples from a JSON file instead of extracting from source.Implementation
usingdirectives for common Valkey GLIDE namespaces and types.Limitations
Valkey.Glideproject to be built first (dotnet build).Testing
task check-examples.Related Issues
Checklist
CHANGELOG.md,README.md,DEVELOPER.md, and other documentation files are updated.mainor releasemain, squash otherwise.