Closed PortHH closed 2 years ago
This might explain what https://github.com/microsoft/AL/issues/6422 was trying to determine, i.e. what the AA0072 CodeCop currently considers a "valid" name for .Net objects.
The only way to bypass the warning at the moment is by using the name of the assembly, it seems that the code analyzers don't use the alias as the expected name.
There is an extended example:
dotnet
{
assembly(mscorlib)
{
type(System.DateTime; MyDateTime){}
}
}
codeunit XXX MyCodeunit
{
trigger OnRun()
var
MyDateTime: DotNet MyDateTime; //This is showing the AL(AA0072) Warning
"System.DateTime": DotNet MyDateTime; //This is not showing any warning
begin
end;
}
I understand this is a bug, it is not critical but it should be corrected
Thanks for that info. I'd propose that #6422 be closed as a dupe of this, since this thread got the answer on what the current preferred naming rule is and what it should be instead.
Agreed. This sucks
Naming should follow the regular rules and not be special for DotNet
In that case I would just #pragma
out the warning for sections of code using .Net variables, rather than follow the (accidental?) convention with protest ;-)
Hello dnpb,
can you please write a code sample, how to use #pragma to suppress the warning in a special region?
Thanks S-Keim
#pragma warning disable AA0072
// code for which you don't want / care about warnings here
#pragma warning restore AA0072
Thanks for reporting this issue. Sorry we haven’t completed it yet, but we’ve had to prioritize elsewhere. We’re planning to give the CodeCop engine and its rules an overhaul in a future major release. Thanks for your patience.
For this case consider using Pragma Warning Directive.
The naming of DotNet Variables on prem is very strange
example:
MyDateTime: DotNet MyDateTime; //AL(AA0072) Warning "System.DateTime": DotNet MyDateTime; //Not warning
As it seems wrong to me to declare the variable in this way ("System.DateTime"), I would give it the same name as the alias (MyDateTime).