Hi All,
I hope you'll are doing well.
Business Central 17 has come up with a lot of improvements and functionalities, and one of them is Mandatory Affixes which is very important for developers w.r.t Code Standardization and managing their objects.
AppSourceCop Rule AS0011: An affix is required
Now, what does that mean! Let's look into it in detail.
In order to avoid name clashes for objects added by your extension and objects added by other extensions, an affix must be prepended or appended to the name of all new application objects, extension objects, and fields. That is a suffix or a prefix is required.
This can be done by using the property mandatoryAffixes in AppSourceCop.json.
Change: The mandatory prefix and mandatory suffix properties are now both defining an affix that can be used either as prefix or as suffix.
The mandatoryAffixes property expects to receive an array of string as follows
{
"mandatoryAffixes": [ "Test", "Case", "New" ]
}
Example:
If the existing codeunit doesn't contain an affix, it should be modified as follows:
Note: Applicable to all objects
Existing Codeunit:
codeunit 50100 ExistingCodeunit
{
procedure MyProcedure()
begin
// Business logic.
end;
}
Modified Extension Codeunit:
codeunit 50100 MyCodeunit
{
ObsoleteState = Pending;
ObsoleteReason = 'Use Test_MyCodeunit instead.';
procedure MyProcedure()
var
c: Codeunit Test_MyCodeunit;
begin
// Re-direct calls to not break the runtime behaviour of dependent extensions.
c.MyProcedure();
end;
}
//using one of the affixes mentioned in the mndatoryAffixes array
codeunit 50120 Test_MyCodeunit
{
procedure MyProcedure()
begin
// Business logic.
end;
}
Check more rules here: AppSourceCop Analyzer Rules
This comment has been removed by the author.
ReplyDelete