AA0181 rule warning for Codeunit.Find method
There is a codeunit with Find(var RecordVariable: Record SomeRecord): Boolean method defined in my code.
When I use it like
if CodeunitVariable.Find(RecordVariable) then;
or
CodeunitVariable.Find(RecordVariable)
I am getting warning AA0181: The FindSet() or Find() method on the record 'SomeRecord' must be used only in connection with the Next() method.
Note: If the call is repeated on multiple lines, the warning appears only on the last line of code.
Maybe there is a relation to #7459.
Versions:
- AL Language: v13.0.971907
- Visual Studio Code: 1.88.1
Internal work item: AB#534244
I think the issue is lacking come context for what is the issue. According to the public documentation about this analyzer rule, the scenario sounds like it is by design. Can you provide further details on
- What behaviour your were not expecting
- What you were expecting,
- A code snippet with proper context
@EmilDamsbo
I was mistaken on first read as well, but: The rule should warn for Record.Find only. But it also gives false positives on Codeunit.Find, whereas Find in the latter case is a custom procedure, not the AL method.
@EmilDamsbo Do you still need any other details? Please read the description again; I think there is all you need.
Thanks both, I misread the original issue. Seems this has been correctly tagged now
It does seem like we're incorrectly emitting AA0181 on signatures that resemble the .Find method on records.
Here's a repro:
codeunit 50109 MyCodeunitA
{
procedure Find(rec: Record Customer): Boolean
begin
exit(true);
end;
}
codeunit 50110 MyCodeunitB
{
procedure Test(cu: Codeunit MyCodeunitA; r: Record Customer)
begin
if cu.Find(r) then
Message('Found');
end;
}
AA0181 is emitted on cu.Find(r). Approving the bug. Thank you for reporting it!
The fix for this issue has been checked in to the master branch. It will be available in the bcinsider.azurecr.io/bcsandbox-master Docker image starting from platform build number 25.0.20197.0 and VS Code Extension Version 14.0.1032641.
If you don’t have access to these images you need to become part of the Ready2Go program: aka.ms/readytogo
For more details on code branches and docker images please read: https://blogs.msdn.microsoft.com/nav/2018/05/03/al-developer-previews-multiple-releases-and-github/ https://freddysblog.com/2020/06/25/working-with-artifacts/