|
| 1 | +--- |
| 2 | +name: csharp-sync |
| 3 | +description: Migrates RavenDB C# client features to the Python client. Use when porting C# diffs, patches, or test files to Python, batching sync work, or writing migration tests. |
| 4 | +--- |
| 5 | + |
| 6 | +# C# β Python Client Sync |
| 7 | + |
| 8 | +Migrate features from the RavenDB C# client into this Python client codebase. |
| 9 | +Input is a raw `.patch` / `.diff` from the C# repo. Output is working Python code with tests. |
| 10 | + |
| 11 | +## Pipeline |
| 12 | + |
| 13 | +1. **Triage** β read the diff, list every changed file, group into batches |
| 14 | +2. **Implement** β port each batch following [CONVENTIONS.md](CONVENTIONS.md) |
| 15 | +3. **Test** β migrate or write tests following [TESTING.md](TESTING.md) |
| 16 | + |
| 17 | +## Reference sources |
| 18 | + |
| 19 | +When triaging or implementing, cross-reference with the upstream C# source and RavenDB docs. |
| 20 | + |
| 21 | +### C# source (GitHub raw) |
| 22 | + |
| 23 | +Base URL for the `v7.2` branch: |
| 24 | +``` |
| 25 | +https://raw.githubusercontent.com/ravendb/ravendb/refs/heads/v7.2/src/Raven.Client/ |
| 26 | +``` |
| 27 | + |
| 28 | +To read a C# file, build the URL from its namespace path: |
| 29 | +- `Documents/Operations/Attachments/PutAttachmentOperation.cs` |
| 30 | +- `Documents/Commands/Batches/PutAttachmentCommandData.cs` |
| 31 | +- `Documents/Indexes/IndexDefinition.cs` |
| 32 | +- `Exceptions/Documents/DocumentDoesNotExistException.cs` |
| 33 | + |
| 34 | +To discover what's inside a directory, fetch the GitHub API: |
| 35 | +``` |
| 36 | +https://api.github.com/repos/ravendb/ravendb/contents/src/Raven.Client/Documents/Operations?ref=v7.2 |
| 37 | +``` |
| 38 | +This returns a JSON array of `{name, path, type}` entries β use it to list files before fetching specific ones. |
| 39 | + |
| 40 | +For **tests**, the base path is: |
| 41 | +``` |
| 42 | +https://raw.githubusercontent.com/ravendb/ravendb/refs/heads/v7.2/test/SlowTests/ |
| 43 | +``` |
| 44 | +With the API equivalent: |
| 45 | +``` |
| 46 | +https://api.github.com/repos/ravendb/ravendb/contents/test/SlowTests?ref=v7.2 |
| 47 | +``` |
| 48 | + |
| 49 | +### RavenDB documentation |
| 50 | + |
| 51 | +Base URL: `https://docs.ravendb.net/7.2` |
| 52 | + |
| 53 | +Key sections to check during triage: |
| 54 | +- `document-extensions/attachments/` β attachment operations |
| 55 | +- `documents/schema-validation/` β JSON schema validation |
| 56 | +- `indexes/` β index definitions, schema in indexes |
| 57 | +- `ai-integration/` β AI / embeddings features |
| 58 | + |
| 59 | +Use docs to determine whether a C# change is: |
| 60 | +1. **A documented feature** β must be ported |
| 61 | +2. **C#-specific plumbing** (e.g. `IDisposable`, `Span<T>`) β skip |
| 62 | +3. **Related to a feature not yet synced** β defer to a later batch |
| 63 | + |
| 64 | +## Step 1 β Triage the diff |
| 65 | + |
| 66 | +1. Read the full diff. For each changed C# file write a one-line summary. |
| 67 | +2. For unfamiliar changes, **fetch the full C# source** from GitHub to understand context. |
| 68 | +3. **Check RavenDB docs** to confirm the feature is documented and understand its scope. |
| 69 | +4. **Filter out** changes that are C#-specific or relate to features not yet in the Python client. |
| 70 | +5. Group remaining changes into **batches** by feature area. Good boundaries: |
| 71 | + - New operation class (e.g. `ConfigureRemoteAttachmentsOperation`) |
| 72 | + - New model / DTO cluster (e.g. settings + configuration classes) |
| 73 | + - New exception type + dispatcher wiring |
| 74 | + - Test migration for an already-implemented feature |
| 75 | +6. Create a **checklist** β one `- [ ]` per batch, ordered by dependency (models β operations β tests). |
| 76 | + |
| 77 | +### Batch sizing |
| 78 | + |
| 79 | +- Target **β€ 300 lines of Python** per batch. |
| 80 | +- If a single C# file maps to > 300 lines, split by class or logical section. |
| 81 | +- Tests are their own batch, listed after the implementation batch they cover. |
| 82 | + |
| 83 | +## Step 2 β Implement each batch |
| 84 | + |
| 85 | +Follow the naming rules and patterns in [CONVENTIONS.md](CONVENTIONS.md). |
| 86 | + |
| 87 | +When porting a C# class, **always fetch the full source from GitHub** β diffs alone often lack constructor signatures, base classes, or `ToJson`/`FromJson` methods needed for a correct port. |
| 88 | + |
| 89 | +For every edit: |
| 90 | +1. Use `codebase-retrieval` to find ALL downstream callers, implementations, and tests. |
| 91 | +2. Update every affected file β missing a downstream change is a critical failure. |
| 92 | +3. After editing, verify imports resolve and no existing tests are broken. |
| 93 | +4. If unsure about a field or method, check the **RavenDB docs** for the canonical behavior. |
| 94 | + |
| 95 | +### Key files to touch per feature |
| 96 | + |
| 97 | +| What | Where | |
| 98 | +|---|---| |
| 99 | +| New operation / model | `ravendb/documents/operations/<feature>/__init__.py` | |
| 100 | +| New exception | `ravendb/exceptions/raven_exceptions.py` or subpackage | |
| 101 | +| Exception dispatcher map | `ravendb/exceptions/exception_dispatcher.py` | |
| 102 | +| DatabaseRecord fields | `ravendb/serverwide/database_record.py` | |
| 103 | +| IndexDefinition fields | `ravendb/documents/indexes/definitions.py` | |
| 104 | +| Statistics fields | `ravendb/documents/operations/statistics.py` | |
| 105 | +| Session-level changes | `ravendb/documents/session/` submodules | |
| 106 | +| Bulk insert changes | `ravendb/documents/bulk_insert_operation.py` | |
| 107 | +| Module exports | `ravendb/__init__.py` | |
| 108 | + |
| 109 | +## Step 3 β Write tests |
| 110 | + |
| 111 | +Follow the infrastructure and patterns in [TESTING.md](TESTING.md). |
| 112 | + |
| 113 | + |
0 commit comments