This document introduces the module development specification of the EasyAbp organization. Follow these rules and designs if you want to join and contribute.
Please read through the ABP official document: Module Development.
We have some standards based on the official document: Module Development Best Practices & Conventions.
Try to design an abstract module and provide more implementations.
- Good practice:
EasyAbp.Abp.Sms,EasyAbp.Abp.Sms.Aws,EasyAbp.Abp.Sms.Azure. - Bad practice:
EasyAbp.Abp.AzureSms.
Example of module solution name:
- Application module:
EasyAbp.TodoManagement. - Framework module:
EasyAbp.Abp.Todo(including the prefixAbp.).
For framework modules, the better name of
XxxxxxModuleclass for framework module isAbpXxxxxxModule.
- Add a
[UnitOfWork]attribute to the method that uses repositories. - Don't use any write-operation method of repositories. That also means you will never add a
[UnitOfWork(IsTransactional = true)]attribute.
Todo.
Read the document Getting Start to Develop Modules and follow it to adjust your module solution from the startup template.
According to abpframework/abp#3166
- Make all public/protected methods virtual (including entities, domain services, application services, page models, view components...) to make them easily overridable.
- Make all private methods of domain & application services "protected virtual" to also be able to override them.
Generally, please virtualize the above methods, but you should also think about maintainability and consider protecting some methods if necessary.
- Let your entities implement
IMultiTenantif your module can be designed to support multi-tenancy. - Make sure permissions are host-side only if they should be hidden from tenant users and vice versa.
Refer to the MenuContributor demo.
- The name of menu item should have a
CompanyName+ModuleNameprefix, for example:EasyAbpGiftCardManagementGiftCardis theGiftCardusing theEasyAbpGiftCardManagementprefix. - Create a
CompanyName+ModuleNamemenu item as the root of the module and put other menu items into it, hide it if there is nosub menu item inside.
Always retain a protected or public parameterless constructor, since serializers need it.
public class Book
{
protected Book() { }
}There are two ways to get user data (such as UserName and PhoneNumber):
-
Get from ABP's identity module.
- Use
IExternalUserLookupServiceProviderinstead ofIIdentityUserRepositoryorIIdentityUserAppServicein all your code to get user's data.
- Use
-
Create an local extra user entity (like
BlogUser) and synchronize data from IdentityUser.- See ABP document: Creating a New Entity with Its Own Database Table/Collection.
- Use
IDistributedEventHandlerinstead ofILocalEventHandlerto synchronize user data.
Classes with IHasExtraProperties should inherit ExtensibleObject.
Otherwise, you should make sure:
- The class has
[Serializable]attribute. - The ExtraProperties property has
[JsonInclude]attribute. - The ExtraProperties property has a protected setter.
Use IClock.Now instead of DateTime.Now or DateTime.UtcNow in all your code to get current date time.
Refer to the common.props and the FodyWeavers.xml demos.
- Add
FodyandConfigureAwait.Fodyreferences to module projects. - Set
<ConfigureAwait ContinueOnCapturedContext="false" />.
The ABP auto API controllers is not friendly to tiered solutions, so please use the AbpHelper to generate controllers manually.
- Open
MyModuleNamePermissions.csand change GroupName toEasyAbp.MyModuleName. - Open
MyModuleNameSettings.csand change GroupName toEasyAbp.MyModuleName. - Open
MyModuleNameRemoteServiceConsts.csand change RemoteServiceName toEasyAbpMyModuleName. - Open
MyModuleNameRemoteServiceConsts.csand change ModuleName toeasyAbpMyModuleName. - Open
MyModuleNameResource.csand replace[LocalizationResourceName("MyModuleName")]with[LocalizationResourceName("EasyAbpMyModuleName")]. - Open
MyModuleNameController.csand add [Area(MyModuleNameServiceConsts.ModuleName)] attribute.
Todo.
Todo.
Follow the steps below:
- Copy the common.props demo to your module.
- Edit
Version,Description,PackageTagsandPackageLicenseExpression. (Don't follow the ABP framework's version.)
Refer to the README.md demo. You can customize the structure, but in fact similar formats are more readable.
Refer to the GitHub Action demo, configure your project publication jobs. The NuGet packages will be automatic built and published after you commit code to the master branch with a new module version.
- EasyAbp modules always follow the latest version of ABP framework, so when a new version ABP released, you should upgrade your modules as soon as possible.
- Write down the roadmap in README.md with reference to this demo and implement them when you have time and inspiration.
- Create a new GitHub release and announce all the breaking changes before publish new version pacakges to NuGet.
Welcome to contribute to EasyAbp organization, you can publish new modules or improve existing modules for us.
If you want to contribute a new module to EasyAbp, please create an issue here to introduce your design and provide the link to your module Github repository. We will evaluate your design and review your code, if the module is well-designed and needed, we will add it to EasyAbp org.
If you want to improve an existing module, please create a PR in the module Github repository, which we will review and merge if it is needed.