Skip to main content

Vital Core Extraction – Implementation Plan

Goal Description

Extract a portable .NET Standard 2.1 core from EITWEP.Model to enable:

  1. Modern API Development: New .NET 10 services can reference the same entities
  2. Headless Execution: Background jobs and CLI tools without HttpContext
  3. 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 contract
  • IEITLogItemable.cs – Log item contract
  • ICommunicable.cs – Communication contract
  • IEITNotifiable.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)

StepActionExpected Result
1Create Wep.Core.sln in separate folderSolution created
2Add Wep.Core.Abstractions projectProject builds
3Copy IWepActivityable interface (pure version)No compile errors
4Reference from EITWEP.ModelModel builds
5Build full WepNG_MVC.slnAll 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.

PhaseTest TypeScopeComplexityValue
ACompilation TestsVerify all projects still compile🟢 LowSafety net
BIntegration TestsVerify Type Forwarding resolution🟡 MediumCritical for migration
CCharacterization TestsCapture current behavior before refactoring🔴 HighFuture-proofing

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);
}

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:

  1. No seams for mocking – Business logic is intertwined with persistence
  2. HttpContext dependency – Many methods require a web context
  3. Database dependency – Most logic requires a live database
  4. 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.Abstractions correctly
  • After Phase B Prototype: Verify OrderOMGT type resolves via Type Forwarding
  • Rollback Ready: All changes can be reverted with git checkout main

Deliverables

DeliverableStatusNotes
session1_analysis.md✅ CompleteDetailed findings
implementation_plan.md✅ This documentAwaiting approval
Wep.Core.Abstractions skeleton🔜 After approvalPrototype only
Type Forwarding PoC🔜 After approvalMinimal scope
Compilation Tests🔜 After Phase ASafety net

Next Steps After Approval

  1. Create feature/vital-core-extraction-prototype branch
  2. Create Wep.Core.Abstractions project skeleton
  3. Extract IWepActivityable as proof of concept
  4. Write compilation verification tests
  5. Verify build chain
  6. Report findings