|
1 | 1 | # CLAUDE.md |
2 | 2 |
|
3 | | -This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 3 | +## What this is |
4 | 4 |
|
5 | | -## Development Commands |
| 5 | +ReflectorNet is a .NET reflection toolkit for AI-driven scenarios: fuzzy method discovery, type-preserving serialization, and dynamic invocation. It ships as the NuGet package `com.IvanMurzak.ReflectorNet` and is the most foundational library in the workspace dependency chain. |
| 6 | + |
| 7 | +## Build / run |
6 | 8 |
|
7 | 9 | ```bash |
8 | | -# Build the solution |
| 10 | +# Build |
9 | 11 | dotnet build --configuration Release |
10 | 12 |
|
11 | | -# Run all tests (multi-TFM: net8.0 and net9.0) |
| 13 | +# Test (multi-TFM: net8.0 and net9.0) |
12 | 14 | dotnet test --configuration Release --verbosity normal |
13 | 15 |
|
14 | | -# Run a single test by fully qualified name |
| 16 | +# Single test by FQN |
15 | 17 | dotnet test --configuration Release --filter "FullyQualifiedName~com.IvanMurzak.ReflectorNet.Tests.ClassName.MethodName" |
16 | 18 |
|
17 | | -# Run tests matching a pattern |
18 | | -dotnet test --configuration Release --filter "FullyQualifiedName~SchemaTests" |
19 | | - |
20 | 19 | # Pack for NuGet |
21 | 20 | dotnet pack ReflectorNet/ReflectorNet.csproj --configuration Release --output ./packages |
22 | 21 | ``` |
23 | 22 |
|
24 | | -## Project Layout |
25 | | - |
26 | | -- **ReflectorNet/** - Main library (NuGet: `com.IvanMurzak.ReflectorNet`) |
27 | | -- **ReflectorNet.Tests/** - xUnit test suite |
28 | | -- **ReflectorNet.Tests.OuterAssembly/** - Separate assembly used by tests for cross-assembly reflection scenarios |
29 | | -- **ConsoleApp/** - Console app for manual testing |
30 | | - |
31 | | -## Target Frameworks & Language |
32 | | - |
33 | | -- **Library**: `netstandard2.1`, `net8.0`, `net9.0` — LangVersion `10.0` |
34 | | -- **Tests**: `net8.0`, `net9.0` — LangVersion `11.0` |
35 | | -- Nullable enabled, ImplicitUsings disabled throughout |
36 | | -- Root namespace: `com.IvanMurzak.ReflectorNet` |
37 | | - |
38 | | -## Architecture |
39 | | - |
40 | | -ReflectorNet is a reflection toolkit for AI-driven .NET scenarios — fuzzy method discovery, type-preserving serialization, and dynamic invocation. |
41 | | - |
42 | | -### Reflector (partial class, split across 10 files) |
43 | | - |
44 | | -`Reflector` is the main entry point in `src/Reflector/`. Each concern is a separate partial file: |
45 | | - |
46 | | -| File | Responsibility | |
47 | | -|------|---------------| |
48 | | -| `Reflector.cs` | Constructor, reference resolution | |
49 | | -| `Reflector.Serialize.cs` | Object → `SerializedMember` | |
50 | | -| `Reflector.Deserialize.cs` | `SerializedMember` → object | |
51 | | -| `Reflector.Modify.cs` | In-place object updates | |
52 | | -| `Reflector.FindMethod.cs` | Fuzzy method discovery (match levels 1-6) | |
53 | | -| `Reflector.CallMethod.cs` | Dynamic method invocation | |
54 | | -| `Reflector.Json.cs` | JSON serialization integration | |
55 | | -| `Reflector.Registry.cs` | Converter registry (nested `Registry` class) | |
56 | | -| `Reflector.DefaultValue.cs` | Default value resolution | |
57 | | -| `Reflector.Equals.cs` | Deep equality comparison | |
58 | | -| `Reflector.Error.cs` | Hierarchical error formatting | |
59 | | - |
60 | | -### Converter System (Chain of Responsibility) |
61 | | - |
62 | | -Located in `src/Converter/`. The `Registry` selects the best converter by querying each for `SerializationPriority(Type)` — highest score wins. |
63 | | - |
64 | | -**Reflection converters** (`src/Converter/Reflection/`): |
65 | | -- `BaseReflectionConverter<T>` — abstract base (partial: `.Serialize`, `.Deserialize`, `.Modify`, `.DefaultValue`) |
66 | | -- `PrimitiveReflectionConverter` — built-in types (int, string, DateTime, etc.) |
67 | | -- `GenericReflectionConverter<T>` — custom classes/structs (fallback) |
68 | | -- `ArrayReflectionConverter` — arrays and collections (partial: `.Deserialize`) |
69 | | -- `TypeReflectionConverter`, `AssemblyReflectionConverter` — System.Type, Assembly |
70 | | -- `LazyGenericReflectionConverter` — runtime type resolution for optional dependencies |
71 | | -- `IgnoreFieldsAndPropertiesReflectionConverter` — selective member exclusion |
72 | | - |
73 | | -**JSON converters** (`src/Converter/Json/`): System.Text.Json converters for many .NET types. `IJsonSchemaConverter` interface enables custom JSON Schema generation. |
74 | | - |
75 | | -### Key Models (`src/Model/`) |
76 | | - |
77 | | -- `SerializedMember` — type-preserving intermediate representation (partial: `.Static`) |
78 | | -- `MethodRef` — method reference for fuzzy discovery |
79 | | -- `MethodData` — method metadata and parameters |
80 | | -- `SerializationContext` / `DeserializationContext` — state during (de)serialization |
81 | | - |
82 | | -### Thread Safety |
83 | | - |
84 | | -Registry uses `ConcurrentBag`/`ConcurrentDictionary` with a cache-replacement invalidation pattern (replace entire dictionary reference rather than clearing) for thread-safe converter and blacklist cache management. |
85 | | - |
86 | | -## CI/CD |
87 | | - |
88 | | -- **PR workflow** (`pull_request.yml`): build + test on ubuntu with .NET 8.0 + 9.0, publishes trx test results |
89 | | -- **Release workflow** (`release.yml`): triggered on push to main — reads version from `ReflectorNet.csproj` `<Version>`, creates GitHub release tag, publishes NuGet package. Version bump = new release. |
90 | | - |
91 | | -## Versioning |
| 23 | +## Find detail in |
92 | 24 |
|
93 | | -Version is defined in `ReflectorNet/ReflectorNet.csproj` `<Version>` element. Bumping it and merging to main triggers a NuGet publish. |
| 25 | +- `docs/claude/architecture.md` — Reflector partial-class structure, converter chain, project layout, target frameworks |
| 26 | +- `docs/claude/models.md` — `SerializedMember`, `MethodRef`, context objects |
| 27 | +- `docs/claude/threading.md` — Registry thread safety pattern |
| 28 | +- `docs/claude/release.md` — CI/CD workflows and versioning |
0 commit comments