5
Would like to see a code analyzer rule that warns developers when in code a text-array is passed as an argument, but the array length or max. length of the text-entries do not match the formal parameter.
(1) Example 1:
Given the following variable declarations:
var
FormatAddr: Codeunit "Format Address";
CustAddr: array[8] of Text[50];
And the following statement:
FormatAddr.SalesHeaderBillTo(CustAddr, SalesHdr);
Knowing that this procedure has the following signature: SalesHeaderBillTo(VAR AddrArray : ARRAY [8] OF Text[100];VAR SalesHeader : Record "Sales Header")
We should get a warning on a possible overflow (i.e., array[8] of Text[50] given, but array[8] of Text[100] expected).
(2) Example 2:
Given the following variable declarations:
var
FormatAddr: Codeunit "Format Address";
CustAddr: array[7] of Text[100];
And the following statement:
FormatAddr.SalesHeaderBillTo(CustAddr, SalesHdr);
Knowing that this procedure has the following signature: SalesHeaderBillTo(VAR AddrArray : ARRAY [8] OF Text[100];VAR SalesHeader : Record "Sales Header")
We should get a warning on the length of the arrays not matching (i.e., array of length 7 given, but array of length 8 expected).
(1) Example 1:
Given the following variable declarations:
var
FormatAddr: Codeunit "Format Address";
CustAddr: array[8] of Text[50];
And the following statement:
FormatAddr.SalesHeaderBillTo(CustAddr, SalesHdr);
Knowing that this procedure has the following signature: SalesHeaderBillTo(VAR AddrArray : ARRAY [8] OF Text[100];VAR SalesHeader : Record "Sales Header")
We should get a warning on a possible overflow (i.e., array[8] of Text[50] given, but array[8] of Text[100] expected).
(2) Example 2:
Given the following variable declarations:
var
FormatAddr: Codeunit "Format Address";
CustAddr: array[7] of Text[100];
And the following statement:
FormatAddr.SalesHeaderBillTo(CustAddr, SalesHdr);
Knowing that this procedure has the following signature: SalesHeaderBillTo(VAR AddrArray : ARRAY [8] OF Text[100];VAR SalesHeader : Record "Sales Header")
We should get a warning on the length of the arrays not matching (i.e., array of length 7 given, but array of length 8 expected).
STATUS DETAILS
New
Business Central Team (administrator)
Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future.
Best regards,
Business Central Team