3.2 KiB
3.2 KiB
Mango.Nop Libraries — Domain Rules
This is the single source of truth for Mango.Nop library rules. Do not duplicate these elsewhere. For detailed docs see:
README.md→docs/For core framework rules see:../../../../../../Aycode/Source/AyCode.Core/.github/copilot-instructions.md
nopCommerce Compatibility
- All three libraries target net9.0 — required by nopCommerce 4.80.9. Do NOT change TFM.
- NopDependencies folder in
Mango.Nop.Corecontains mirror copies of nopCommerce entity classes (BaseEntity,Customer,Order,Product,GenericAttribute, etc.) so thatMango.Nop.Corecan be referenced without the full nopCommerce dependency chain. - Do NOT modify files in
NopDependencies/unless the nopCommerce version changes.
Entity & DTO Patterns
BaseEntity(NopDependencies) = root entity base withint Id. All nopCommerce entities inherit from this.MgEntityBase= custom entity base that inheritsBaseEntityand implementsIEntityInt(from AyCode.Interfaces). Used for domain-specific entities.ModelDtoBase<TMainEntity>= DTO base with two-way mapping:CopyEntityValuesToDto()andCreateMainEntity(). All DTOs inherit from this.GenericAttribute= polymorphic key-value store.KeyGroup= owner type name,EntityId= owner ID. Extension methods inGenericAttributeExtensionsprovide typed access.
Data Access Patterns
MgDbTableBase<TEntity>= repository base wrapping nopCommerceEntityRepository<TEntity>. AddsGetAll(), timestamp handling, and event publishing.MgDtoDbTableBase= DTO-aware repository — handles DTO ↔ entity mapping on top ofMgDbTableBase.MgDbContextBase= EF Core context base for custom tables.
Conventions
Mgprefix for all custom types:MgEntityBase,MgOrderDto,MgDbTableBase, etc.- No redundant code — before writing new logic, search for existing methods. Reuse or extract shared logic.
- Keep all .md files in sync — when you modify code, update any affected .md file in the same area. If you already read an .md file during your work and notice it contradicts the current code, fix the discrepancy — but do NOT proactively scan or open .md files just to check for issues.
- All AyCode references are via DLL (not ProjectReference) — this is intentional. When a type is referenced but not defined in this library (e.g.
IEntityInt,IId<T>,AcConst,ToonDescription), look it up in../../../../../../Aycode/Source/AyCode.Core/source and docs. - Documentation layering — write
.mddocumentation at the defining layer (where the code lives). Higher-layer.mdfiles reference the base docs (e.g.see AyCode.Core/docs/SIGNALR.md) and document only project-specific overrides or extensions. Never duplicate base-layer descriptions in consumer-level docs.
Reference Modes
- Full stack (ProjectReference, all 3 libraries) — for nopCommerce plugins needing entity access, data layer, and services.
- Types only (DLL reference,
Mango.Nop.Coreonly) — for projects that only need DTOs, entities, and interfaces without the nopCommerce runtime dependency.