microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
744 stars 245 forks source link

Rule137DoNotDeclareVariablesThatAreUnused Index out of range error #4293

Closed GreatScott000 closed 5 years ago

GreatScott000 commented 5 years ago

After I have installed the AL Language 2.0.56865 extension I am seeing this warning in the Problems list in VS Code (1.29.1)

Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Design.Rule137DoNotDeclareVariablesThatAreUnused' threw an exception of type 'System.IndexOutOfRangeException' with message 'Index was outside the bounds of the array.'

This is the full message information:

{ "resource": "../app.json", "owner": "_generated_diagnostic_collectionname#0", "code": "AD0001", "severity": 4, "message": "Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Design.Rule137DoNotDeclareVariablesThatAreUnused' threw an exception of type 'System.IndexOutOfRangeException' with message 'Index was outside the bounds of the array.'", "source": "AL", "startLineNumber": 1, "startColumn": 1, "endLineNumber": 1, "endColumn": 1 }

GreatScott000 commented 5 years ago

Not surprisingly that removing the ${CodeCop} analyzer makes the warning go away. However, I prefer to leave this on.

JohanStenberg100 commented 5 years ago

Hi @GreatScott000, can you provide a small AL sample which reproduces this issue? Thanks!

GreatScott000 commented 5 years ago

@JohanStenberg100 I can do that for you but it will not be until 2018/12/04

salgiza commented 5 years ago

Hi, @GreatScott000 , @JohanStenberg100

I've also been getting this warning from quite a while, but up until today I didn't have the time to try to pinpoint what was causing it (we got the warning in two big projects). After doing some tests, I've managed to reproduce the error by following these steps:

  1. Create a new AL project.
  2. Configure the launch.json file and download symbols.
  3. Add the following codeunit:
codeunit 50100 "Test"
{
    TableNo = "Job Queue Entry";

    trigger OnRun()
    begin
    end;
}

Tested using VS Code 1.29.1 + AL extension 2.0.56865 + Docker with version 13.1.25940.26323 (ES)

salgiza commented 5 years ago

Ooops: and obviously, between steps 1 and 3, enable the code analyzers! (I have both AppSourceCop and CodeCop enabled)

JohanStenberg100 commented 5 years ago

@salgiza thank you, this exception does not reproduce on our master branch but I can reproduce it on the 2.0.56865 version. Make sure to update when a new AL VS code extension version is out. @GreatScott000 please post your repro as well so I can verify it's the same root cause.

JohanStenberg100 commented 5 years ago

@GreatScott000 I'm now assuming you have the same issue as salgiza.

GreatScott000 commented 5 years ago

@JohanStenberg100 I apologize. I am in the middle of a big implementation and have not been able to get back to this. I do not have have a clear repro scenario to. Let's assume that my issue is the same and work from there.

JohanStenberg100 commented 5 years ago

@GreatScott000 no problem. Make sure to try the new extension when it is released and open another issue if the issue still reproduces. Thanks!

ALGitHubBot commented 5 years ago

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

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://blogs.msdn.microsoft.com/freddyk/2018/04/16/which-docker-image-is-the-right-for-you/