BusinessCentral.LinterCop icon indicating copy to clipboard operation
BusinessCentral.LinterCop copied to clipboard

LinterCop for BC24?

Open GOB-Andrea opened this issue 11 months ago • 10 comments

Hello everyone, We have already converted our workspace to BC24. In VS Code we don't get any LC-warnings since then and in our pipelines we get 10000x a warning in the following style:

(...) An instance of analyzer BusinessCentral.LinterCop.Design.Rule0001FlowFieldsShouldNotBeEditable cannot be created from C:\app\BusinessCentral.LinterCop.dll : Could not load file or assembly 'Microsoft.Dynamics.Nav.CodeAnalysis, Version=13.0.14.47012, (...). The system cannot find the file specified.

We receive the pipeline warnings regardless of whether we specify in the pipeline config that we want to work with the preview version or the normal version. We really like working with the LinterCop and would therefore like to know when there will be a BC24 compatible (preview) version.

Many thanks in advance!

GOB-Andrea avatar Mar 27 '24 08:03 GOB-Andrea

The LinterCop should work with the AL Language version 13.0 for BC version 24.

Can you maybe share more details on your pipeline setup? Is this Azure DevOps or Github? Are you using AL-Go, ALOps, COSMO Alpaca, BcContainerHelper, ...?

Arthurvdv avatar Mar 30 '24 08:03 Arthurvdv

@Arthurvdv Thanks for your reply!

In VSCode the LinterCop now runs with the normal AL-Language and even with the pre-release version (13.0.971907 and 14.0.963280). So we can confirm that it generally works.

Unfortunately, it still does not run in the pipeline. We use Azure DevOps and the latest BCContainerHelper. Any ideas?

GOB-Andrea avatar Apr 02 '24 14:04 GOB-Andrea

I'm afraid I'll need some details to have a repo on this.

If could share the YAML/PowerShell of your ADO pipelines that would be very helpful.

Arthurvdv avatar Apr 06 '24 12:04 Arthurvdv

Good Morning @Arthurvdv

i can share a few bits of our code.

This is how we download the LinterCop DLL

function Get-LinterCop {
    [CmdletBinding()]
    param(
        [Parameter()]
        [string]$TargetPath,
        [Parameter()]
        [switch]$PreReleases
    )

    $latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/StefanMaron/BusinessCentral.LinterCop/releases"

    if ($PreReleases.isPresent) {
        $latestRelease = $latestRelease[0]
    }
    else {
        $latestRelease = ($latestRelease | Where-Object { $_.prerelease -eq $false })[0]
    }

    Write-Host $latestRelease

    Invoke-WebRequest -Uri $latestRelease.assets[0].browser_download_url -OutFile $TargetPath
}

In short, it looks like this in our task

    if ($useLinterCop) {
        $linterCopTargetPath = Join-Path $BuildPath 'BusinessCentral.LinterCop.dll'
        Get-LinterCop -TargetPath $linterCopTargetPath -PreRelease:$($Config.LinterCopPreRelease)
        $CustomCodeCops = $linterCopTargetPath
    }

    $compileParameter = @{
        'containerName'               = $ContainerName
        'appProjectFolder'            = $AppPath
        'appOutputFolder'             = $PackagesPath
        'appSymbolsFolder'            = $PackagesPath
        'EnableCodeCop'               = $EnableCodeCop
        'EnableAppSourceCop'          = $EnableAppSourceCop
        'EnablePerTenantExtensionCop' = $EnablePerTenantExtensionCop
        'EnableUICop'                 = $EnableUICop
        'FailOn'                      = $FailOn
        'rulesetFile'                 = $rulesetFile
    }

    if (-not [string]::IsNullOrEmpty($CustomCodeCops)) {
        $compileParameter.Add('CustomCodeCops', $CustomCodeCops)
    }

    Compile-AppInBcContainer @compileParameter 

mjegob avatar Apr 08 '24 06:04 mjegob

I think I maybe have a idea on howto resolve this.

The LinterCop can only work with the latest AL Language, where you need to specify this with the vsixFile parameter on creating the container.

It will be something like New-BCContainer -accept_eula -artifactURL $artifactUrl -vsixFile (Get-LatestAlLanguageExtensionUrl)

Arthurvdv avatar Apr 13 '24 16:04 Arthurvdv

Hi @Arthurvdv sorry for the late response. I think you're right. Usually we use Get-LatestAlLanguageExtensionUrl but as we started using the preview build, we're using the vsix from the container.

Does the LinterCop support the preview version of the compiler? So we could use Get-LatestAlLanguageExtensionUrl -allowPrerelease

mjegob avatar Apr 19 '24 06:04 mjegob

Hi @Arthurvdv - are you saying that we can only use LinterCop with the latest compiler version??

Then it basically means that we no longer can use LinterCop for development in BC version 14 (the new compiler does not support debugging in v14). :(

Wouldn't it be possible to use an older version of the vscode extension? Just as it is possible with the AL Language and AZ AL Dev extensions, where we can choose to install an older version (from the Extension Uninstall button).

epernst avatar Apr 19 '24 12:04 epernst

Does the LinterCop support the preview version of the compiler?

@mjegob, While it does support the Pre-Release version of the AL Language, I'm not sure if relying on this in your pipelines is the best way forward. It could be that things break in the LinterCop on the Pre-Release of AL.

Wouldn't it be possible to use an older version of the vscode extension?

@epernst Let's continue this conversation here: https://github.com/StefanMaron/BusinessCentral.LinterCop/issues/580

Arthurvdv avatar Apr 21 '24 15:04 Arthurvdv

@mjegob, While it does support the Pre-Release version of the AL Language, I'm not sure if relying on this in your pipelines is the best way forward. It could be that things break in the LinterCop on the Pre-Release of AL.

@Arthurvdv so we shouldnt use the LinterCop in preview versions, only in official versions?

mjegob avatar Apr 22 '24 06:04 mjegob

@mjegob We're making progress on supporting the Next Major version of the AL Language, but unfortunately this isn't always easy.

An example https://github.com/StefanMaron/BusinessCentral.LinterCop/issues/606 where Next Major pipelines could fail if the LinterCop is always included.

Arthurvdv avatar May 06 '24 13:05 Arthurvdv