Skip to content

Quick Fix to add a missing using statement does not respect AL0897 #8198

@MODUSCarstenScholling

Description

@MODUSCarstenScholling

1. Describe the bug
When using Quick Fix to add a missing using statement for a namespace to the top, the function should place it alphabetically as requested by AL0897 in case AL0897 is active.

2. To Reproduce

  1. Create an object C in namespace Favorite.C
  2. Create an object B in namespace Favorite.B
  3. Create an object A in namespace Favorite.A
  4. Create procedure X in namespace A.
  5. Create a local variable: TheC: Codeunit C;
  6. Create a local variable: TheB: Codeunit B;
  7. Click the bulb left to the error for Codeunit C (AL0185 Codeunit 'C' is missing), select Add 'using Favorite.C'
  8. Click the bulb left to the error for Codeunit B (AL0185 Codeunit 'B' is missing), select Add 'using Favorite.B'
Image
namespace Favorite.C;

codeunit 5147567 C
{

}

namespace Favorite.B;

codeunit 5147568 B
{

}

namespace Favorite.A;

// These are added when following the steps
//using Favorite.C;
//using Favorite.B;

codeunit 5147569 A
{
    local procedure X()
    var
        TheC: Codeunit C;
        TheB: Codeunit B;
    begin
        Clear(TheC);
        Clear(TheB);
    end;
}

3. Expected behavior
If rule AL0897 is active (Using statements are not ordered alphabetically), then the using statement has to be added in order to avoid this additional problem.

4. Actual behavior
The new using statement is placed below the last using statement.

Image

5. Versions:

  • AL Language: 17.0.2037090
  • Visual Studio Code: 1.108.2
  • Business Central: 27.3
  • Operating System:
    • Windows
    • Linux
    • MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions