Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naming of Dotnet variables Business Central AL Language Source Control #6457

Closed
PortHH opened this issue Feb 9, 2021 · 8 comments
Closed
Labels
bug Product bug CodeCop This is a specific static-code-analysis group (AA) static-code-analysis

Comments

@PortHH
Copy link

PortHH commented Feb 9, 2021

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).

@dzzzb
Copy link

dzzzb commented Feb 9, 2021

This might explain what #6422 was trying to determine, i.e. what the AA0072 CodeCop currently considers a "valid" name for .Net objects.

@GuillemPM
Copy link

GuillemPM commented Feb 9, 2021

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

@dzzzb
Copy link

dzzzb commented Feb 9, 2021

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.

@qutreson qutreson added bug Product bug CodeCop This is a specific static-code-analysis group (AA) static-code-analysis labels Feb 10, 2021
@JSebastianN
Copy link

Agreed. This sucks
image

Naming should follow the regular rules and not be special for DotNet

@dzzzb
Copy link

dzzzb commented Jan 11, 2022

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 ;-)

@S-Keim
Copy link

S-Keim commented Mar 28, 2022

Hello dnpb,

can you please write a code sample, how to use #pragma to suppress the warning in a special region?

Thanks
S-Keim

@dzzzb
Copy link

dzzzb commented Mar 28, 2022

#pragma warning disable AA0072
// code for which you don't want / care about warnings here
#pragma warning restore AA0072

@mazhelez
Copy link
Collaborator

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.

@mazhelez mazhelez closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Product bug CodeCop This is a specific static-code-analysis group (AA) static-code-analysis
Projects
None yet
Development

No branches or pull requests

7 participants