Vital Core Extraction – Implementation Plan
Goal Description
Extract a portable .NET Standard 2.1 core from EITWEP.Model to enable:
- Modern API Development: New .NET 10 services can reference the same entities
- Headless Execution: Background jobs and CLI tools without HttpContext
- Reduced Coupling: Clear separation between data, abstractions, and domain logic
[!IMPORTANT] This is a documentation and prototyping session. No production code changes will be committed until prototype validation passes.
User Review Required
[!CAUTION] Decision Point 1: Should the new
Wep.Core.*libraries be:
- (A) Project References – Simpler, but requires all projects in same solution
- (B) NuGet Packages – More overhead, but better versioning and independence
[!WARNING] Decision Point 2: LLBLGen Pro 4.2 compatibility with .NET Standard 2.1 is untested. Phase B may need LLBLGen configuration changes.
Proposed Changes
Phase A: Abstractions Shim
[NEW] Wep.Core.Abstractions.csproj
New .NET Standard 2.1 class library containing portable interfaces.
Contents:
IWepActivityable.cs– Activity logging contractIEITLogItemable.cs– Log item contractICommunicable.cs– Communication contractIEITNotifiable.cs– Notification contract
Key Constraint: Zero dependencies on System.Web, System.Drawing, or legacy assemblies.
[MODIFY] EITWEP.Model.csproj
Add reference to new Abstractions project.
+ <ProjectReference Include="..\Wep.Core.Abstractions\Wep.Core.Abstractions.csproj" />
Phase B: Entity Extraction (Prototype Only)
[NEW] Wep.Core.Data.csproj
New .NET Standard 2.1 class library for entities.
Initial Scope (Prototype):
- 1 entity only:
OrderOMGT.cs(generated part) CommonEntityBase.cs(if extractable)
[MODIFY] EITWEP.Model/TypeForwarders.cs
Add type forwarding for extracted entities.
// TypeForwarders.cs (new file)
[assembly: TypeForwardedTo(typeof(Wep.Core.Data.EntityClasses.OrderOMGT))]
Phase C: Logic Separation (Future – Not in This Session)
Domain logic extraction deferred until Phase A and B are validated.
Verification Plan
Prototype Validation (Manual)
| Step | Action | Expected Result |
|---|---|---|
| 1 | Create Wep.Core.sln in separate folder | Solution created |
| 2 | Add Wep.Core.Abstractions project | Project builds |
| 3 | Copy IWepActivityable interface (pure version) | No compile errors |
| 4 | Reference from EITWEP.Model | Model builds |
| 5 | Build full WepNG_MVC.sln | All 10+ projects build |
Build Verification Command
# From WepNG_MVC folder
msbuild WepNG_MVC.sln /t:Build /p:Configuration=Debug
Automated Testing Strategy
Current State
[!NOTE] There are no existing unit tests for
EITWEP.Model. The codebase has ~0% test coverage on the data layer.
Recommended Approach
| Phase | Test Type | Scope | Complexity | Value |
|---|---|---|---|---|
| A | Compilation Tests | Verify all projects still compile | 🟢 Low | Safety net |
| B | Integration Tests | Verify Type Forwarding resolution | 🟡 Medium | Critical for migration |
| C | Characterization Tests | Capture current behavior before refactoring | 🔴 High | Future-proofing |
Phase A: Compilation Tests (Recommended)
Simple verification that the extraction doesn't break the build:
[Fact]
public void AllProjectsCompile_AfterAbstractionExtraction()
{
// Run msbuild and assert exit code 0
var result = Process.Start("msbuild", "WepNG_MVC.sln /t:Build");
Assert.Equal(0, result.ExitCode);
}
Phase B: Type Forwarding Tests (Recommended)
Verify that types are correctly resolved at runtime:
[Fact]
public void OrderOMGT_ResolvedViaTypeForwarding()
{
// This should resolve via forwarding, not fail
var type = typeof(OrderOMGT);
Assert.Equal("Wep.Core.Data", type.Assembly.GetName().Name);
}
Phase C: Characterization Tests (Future)
What are they? Tests that capture existing behavior without knowing if it's "correct". Useful for refactoring legacy code.
Why useful? Before extracting business logic, we capture what the code currently does. If extraction changes behavior, tests fail.
Extraction difficulty: 🔴 HIGH
The main challenges are:
- No seams for mocking – Business logic is intertwined with persistence
- HttpContext dependency – Many methods require a web context
- Database dependency – Most logic requires a live database
- Circular dependencies – Hard to instantiate classes in isolation
Recommended strategy: Use ApprovalTests or Scientist.NET patterns to capture current behavior before refactoring.
[!TIP] Start small: Write characterization tests only for the specific methods being extracted in Phase C. Don't try to cover the entire 1,985 business files.
Risk Mitigation Checklist
- Before Any Change: Create git branch
feature/vital-core-extraction-prototype - After Phase A: Verify all projects reference
Wep.Core.Abstractionscorrectly - After Phase B Prototype: Verify
OrderOMGTtype resolves via Type Forwarding - Rollback Ready: All changes can be reverted with
git checkout main
Deliverables
| Deliverable | Status | Notes |
|---|---|---|
session1_analysis.md | ✅ Complete | Detailed findings |
implementation_plan.md | ✅ This document | Awaiting approval |
Wep.Core.Abstractions skeleton | 🔜 After approval | Prototype only |
| Type Forwarding PoC | 🔜 After approval | Minimal scope |
| Compilation Tests | 🔜 After Phase A | Safety net |
Next Steps After Approval
- Create
feature/vital-core-extraction-prototypebranch - Create
Wep.Core.Abstractionsproject skeleton - Extract
IWepActivityableas proof of concept - Write compilation verification tests
- Verify build chain
- Report findings