chore: update project structure, naming, and add reporting infrastructure
- Update all 7 phase docs with source/target location references (golang/ for Go source, dotnet/ for .NET version) - Rename NATS.Server to ZB.MOM.NatsNet.Server in phase 4-7 docs - Update solution layout to dotnet/src/ and dotnet/tests/ structure - Create CLAUDE.md with project summary and phase links - Update .gitignore: track porting.db, add standard .NET patterns - Add golang/nats-server as git submodule - Add reports/generate-report.sh and pre-commit hook - Add documentation_rules.md to version control
This commit is contained in:
@@ -11,31 +11,38 @@ Every module, feature, and test in the porting database must have either a .NET
|
||||
- Phases 1-3 complete: all Go items in the DB, all libraries mapped
|
||||
- Verify with: `dotnet run --project tools/NatsNet.PortTracker -- report summary --db porting.db`
|
||||
|
||||
## Source and Target Locations
|
||||
|
||||
- **Go source code** is located in the `golang/` folder (specifically `golang/nats-server/`)
|
||||
- **.NET ported version** is located in the `dotnet/` folder
|
||||
|
||||
## Solution Structure
|
||||
|
||||
Define the .NET solution layout following standard conventions:
|
||||
|
||||
```
|
||||
src/
|
||||
NATS.Server/ # Main server library (all core logic)
|
||||
Protocol/ # Wire protocol parsing, commands
|
||||
Subscriptions/ # SubList trie, subject matching
|
||||
JetStream/ # Stream management, consumers
|
||||
Cluster/ # Routes, gateways, leaf nodes
|
||||
Auth/ # Authentication, accounts, JWT
|
||||
...
|
||||
NATS.Server.Host/ # Host/entry point (Program.cs, DI, config)
|
||||
dotnet/
|
||||
ZB.MOM.NatsNet.sln
|
||||
src/
|
||||
ZB.MOM.NatsNet.Server/ # Main server library (all core logic)
|
||||
Protocol/ # Wire protocol parsing, commands
|
||||
Subscriptions/ # SubList trie, subject matching
|
||||
JetStream/ # Stream management, consumers
|
||||
Cluster/ # Routes, gateways, leaf nodes
|
||||
Auth/ # Authentication, accounts, JWT
|
||||
...
|
||||
ZB.MOM.NatsNet.Server.Host/ # Host/entry point (Program.cs, DI, config)
|
||||
|
||||
tests/
|
||||
NATS.Server.Tests/ # Unit tests for NATS.Server
|
||||
Protocol/
|
||||
Subscriptions/
|
||||
JetStream/
|
||||
...
|
||||
NATS.Server.IntegrationTests/ # Cross-module and end-to-end tests
|
||||
tests/
|
||||
ZB.MOM.NatsNet.Server.Tests/ # Unit tests for ZB.MOM.NatsNet.Server
|
||||
Protocol/
|
||||
Subscriptions/
|
||||
JetStream/
|
||||
...
|
||||
ZB.MOM.NatsNet.Server.IntegrationTests/ # Cross-module and end-to-end tests
|
||||
```
|
||||
|
||||
The `NATS.Server` project holds all portable logic. `NATS.Server.Host` is the thin entry point that wires up dependency injection, configuration, and hosting. Tests mirror the source structure.
|
||||
The `ZB.MOM.NatsNet.Server` project holds all portable logic. `ZB.MOM.NatsNet.Server.Host` is the thin entry point that wires up dependency injection, configuration, and hosting. Tests mirror the source structure.
|
||||
|
||||
## Naming Conventions
|
||||
|
||||
@@ -45,11 +52,11 @@ Follow these rules consistently when mapping Go items to .NET:
|
||||
|--------|-----------|---------|
|
||||
| Classes | PascalCase | `NatsParser`, `SubList`, `JetStreamController` |
|
||||
| Methods | PascalCase | `TryParse`, `Match`, `ProcessMessage` |
|
||||
| Namespaces | `NATS.Server.[Module]` | `NATS.Server.Protocol`, `NATS.Server.Subscriptions` |
|
||||
| Namespaces | `ZB.MOM.NatsNet.Server.[Module]` | `ZB.MOM.NatsNet.Server.Protocol`, `ZB.MOM.NatsNet.Server.Subscriptions` |
|
||||
| Test classes | `[ClassName]Tests` | `NatsParserTests`, `SubListTests` |
|
||||
| Test methods | `[Method]_[Scenario]_[Expected]` | `TryParse_ValidInput_ReturnsTrue` |
|
||||
| Interfaces | `I[Name]` | `IMessageRouter`, `ISubListAccess` |
|
||||
| Projects | `NATS.Server[.Suffix]` | `NATS.Server`, `NATS.Server.Host` |
|
||||
| Projects | `ZB.MOM.NatsNet.Server[.Suffix]` | `ZB.MOM.NatsNet.Server`, `ZB.MOM.NatsNet.Server.Host` |
|
||||
|
||||
Avoid abbreviations unless they are universally understood (e.g., `TCP`, `TLS`, `JWT`). Prefer descriptive names over short ones.
|
||||
|
||||
@@ -65,8 +72,8 @@ dotnet run --project tools/NatsNet.PortTracker -- module list --db porting.db
|
||||
|
||||
# Map a module to its .NET target
|
||||
dotnet run --project tools/NatsNet.PortTracker -- module map <id> \
|
||||
--project "NATS.Server" \
|
||||
--namespace "NATS.Server.Protocol" \
|
||||
--project "ZB.MOM.NatsNet.Server" \
|
||||
--namespace "ZB.MOM.NatsNet.Server.Protocol" \
|
||||
--class "NatsParser" \
|
||||
--db porting.db
|
||||
```
|
||||
@@ -75,11 +82,11 @@ Work through all modules systematically. Group related Go files into the same na
|
||||
|
||||
| Go package/file pattern | .NET namespace |
|
||||
|------------------------|----------------|
|
||||
| `server/parser.go` | `NATS.Server.Protocol` |
|
||||
| `server/sublist.go` | `NATS.Server.Subscriptions` |
|
||||
| `server/jetstream*.go` | `NATS.Server.JetStream` |
|
||||
| `server/route.go`, `server/gateway.go` | `NATS.Server.Cluster` |
|
||||
| `server/auth.go`, `server/accounts.go` | `NATS.Server.Auth` |
|
||||
| `server/parser.go` | `ZB.MOM.NatsNet.Server.Protocol` |
|
||||
| `server/sublist.go` | `ZB.MOM.NatsNet.Server.Subscriptions` |
|
||||
| `server/jetstream*.go` | `ZB.MOM.NatsNet.Server.JetStream` |
|
||||
| `server/route.go`, `server/gateway.go` | `ZB.MOM.NatsNet.Server.Cluster` |
|
||||
| `server/auth.go`, `server/accounts.go` | `ZB.MOM.NatsNet.Server.Auth` |
|
||||
| `server/pse/` | Likely N/A (Go-specific platform code) |
|
||||
|
||||
### Step 2: Map features
|
||||
@@ -92,7 +99,7 @@ dotnet run --project tools/NatsNet.PortTracker -- feature list --module <module_
|
||||
|
||||
# Map a feature
|
||||
dotnet run --project tools/NatsNet.PortTracker -- feature map <id> \
|
||||
--project "NATS.Server" \
|
||||
--project "ZB.MOM.NatsNet.Server" \
|
||||
--class "NatsParser" \
|
||||
--method "TryParse" \
|
||||
--db porting.db
|
||||
@@ -115,7 +122,7 @@ dotnet run --project tools/NatsNet.PortTracker -- test list --module <module_id>
|
||||
|
||||
# Map a test
|
||||
dotnet run --project tools/NatsNet.PortTracker -- test map <id> \
|
||||
--project "NATS.Server.Tests" \
|
||||
--project "ZB.MOM.NatsNet.Server.Tests" \
|
||||
--class "NatsParserTests" \
|
||||
--method "TryParse_ValidInput_ReturnsTrue" \
|
||||
--db porting.db
|
||||
@@ -147,7 +154,7 @@ Items that typically do not need a .NET port:
|
||||
|---------|--------|
|
||||
| `pse_darwin.go`, `pse_linux.go`, `pse_windows.go` | Go-specific platform syscall wrappers; use .NET `System.Diagnostics.Process` instead |
|
||||
| `disk_avail_windows.go`, `disk_avail_linux.go` | Go-specific disk APIs; use .NET `System.IO.DriveInfo` instead |
|
||||
| Custom logger (`logger.go`, `log.go`) | Replaced by Serilog via `NATS.Server.Host` |
|
||||
| Custom logger (`logger.go`, `log.go`) | Replaced by Serilog via `ZB.MOM.NatsNet.Server.Host` |
|
||||
| Signal handling (`signal.go`) | Replaced by .NET Generic Host `IHostLifetime` |
|
||||
| Go `sync.Pool`, `sync.Map` wrappers | .NET has `ObjectPool<T>`, `ConcurrentDictionary<K,V>` built-in |
|
||||
| Build tags / `_test.go` helpers specific to Go test infra | Replaced by xUnit attributes and test fixtures |
|
||||
|
||||
Reference in New Issue
Block a user