|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +Porticle.Grpc.TypeMapper is a Roslyn-based post-processor shipped as a NuGet development dependency. It hooks into the build pipeline after `Protobuf_Compile` and rewrites protoc-generated C# classes to add support for Guids, nullable strings, and nullable enums — features not natively supported by Protocol Buffers. |
| 6 | + |
| 7 | +Proto field comments (`[GrpcGuid]`, `[NullableString]`, `[NullableEnum]`) or global project properties control which transformations are applied. |
| 8 | + |
| 9 | +## Solution Structure |
| 10 | + |
| 11 | +``` |
| 12 | +Source/ |
| 13 | + Porticle.Grpc.sln |
| 14 | + Porticle.Grpc.TypeMapper/ # Main library (NuGet package, net8.0 + net9.0) |
| 15 | + Porticle.Grpc.UnitTests/ # MSTest unit tests (net9.0) |
| 16 | + Porticle.Grpc.Test/ # Integration test with proto files |
| 17 | + Porticle.Grpc.TestWithoutProto/ # Package consumption test without proto compilation |
| 18 | +``` |
| 19 | + |
| 20 | +## Key Source Files |
| 21 | + |
| 22 | +| File | Role | |
| 23 | +|------|------| |
| 24 | +| `ProtoPostProcessor.cs` | MSBuild Task entry point — finds generated files, runs visitors, writes output | |
| 25 | +| `ClassVisitor.cs` | CSharpSyntaxRewriter — orchestrates property and method transformations per class | |
| 26 | +| `PropertyVisitor.cs` | Rewrites property types/getters/setters (Guid, nullable string, nullable enum) | |
| 27 | +| `MethodVisitor.cs` | Updates Equals/GetHashCode/WriteTo/MergeFrom etc. to use backing fields | |
| 28 | +| `PropertyToFieldRewriter.cs` | Replaces property identifiers with field names inside method bodies | |
| 29 | +| `ListWrappers.cs` | Source code strings for `RepeatedFieldGuidWrapper` and `IListWithRangeAdd<T>` | |
| 30 | +| `SyntaxHelper.cs` | Static helpers to parse C# source strings into Roslyn syntax nodes | |
| 31 | +| `StringUtils.cs` | Snake_case to CamelCase conversion matching protoc/gRPC naming conventions | |
| 32 | +| `Extensions.cs` | Small helper extensions (CheckNotNull, GetGetter, GetSetter) | |
| 33 | +| `Porticle.Grpc.TypeMapper.targets` | MSBuild targets file shipped in the NuGet package | |
| 34 | + |
| 35 | +## Build & Test |
| 36 | + |
| 37 | +```bash |
| 38 | +dotnet build Source/Porticle.Grpc.sln |
| 39 | +dotnet test Source/Porticle.Grpc.UnitTests |
| 40 | +``` |
| 41 | + |
| 42 | +## Coding Conventions |
| 43 | + |
| 44 | +- All code comments (including XML doc comments) must be written in **English**. |
| 45 | +- Target frameworks: net8.0 and net9.0. |
| 46 | +- Nullable reference types are enabled (`<Nullable>enable</Nullable>`). |
| 47 | +- Implicit usings are enabled. |
| 48 | +- Debug builds treat warnings as errors. |
0 commit comments