From 769623f9978bbccd2a110f122b4f9a8e77d2e5c0 Mon Sep 17 00:00:00 2001 From: aholstrup1 Date: Tue, 3 Dec 2024 13:05:55 +0100 Subject: [PATCH 1/5] Calculate preprocessor symbols --- .github/AL-Go-Settings.json | 10 ---------- build/scripts/GuardingV2ExtensionsHelper.psm1 | 10 ++++++++++ build/scripts/PreCompileApp.ps1 | 2 ++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/AL-Go-Settings.json b/.github/AL-Go-Settings.json index 744cdd0348..921513e3e0 100644 --- a/.github/AL-Go-Settings.json +++ b/.github/AL-Go-Settings.json @@ -10,16 +10,6 @@ "useProjectDependencies": true, "repoVersion": "26.0", "cleanModePreprocessorSymbols": [ - "CLEAN17", - "CLEAN18", - "CLEAN19", - "CLEAN20", - "CLEAN21", - "CLEAN22", - "CLEAN23", - "CLEAN24", - "CLEAN25", - "CLEAN26" ], "unusedALGoSystemFiles": [ "AddExistingAppOrTestApp.yaml", diff --git a/build/scripts/GuardingV2ExtensionsHelper.psm1 b/build/scripts/GuardingV2ExtensionsHelper.psm1 index 0810b9149f..33b6aec12f 100644 --- a/build/scripts/GuardingV2ExtensionsHelper.psm1 +++ b/build/scripts/GuardingV2ExtensionsHelper.psm1 @@ -268,4 +268,14 @@ function Get-MaxAllowedObsoleteVersion() { return [System.Version]::Parse($alGoSettings.repoVersion).Major } +function Get-PreprocessorSymbols() { + Import-Module -Name $PSScriptRoot\EnlistmentHelperFunctions.psm1 + + [int] $currentVersion = (Get-ConfigValue -Key "repoVersion" -ConfigType AL-Go) -split '\.' | Select-Object -First 1 + [int] $upperBound = Get-MaxAllowedObsoleteVersion + [int] $lowerBound = $CurrentVersion - 4 + + return $lowerBound..$upperBound | ForEach-Object { "CLEAN$_" } +} + Export-ModuleMember -Function *-* diff --git a/build/scripts/PreCompileApp.ps1 b/build/scripts/PreCompileApp.ps1 index 886a80cd3b..b131e9e6ce 100644 --- a/build/scripts/PreCompileApp.ps1 +++ b/build/scripts/PreCompileApp.ps1 @@ -53,6 +53,8 @@ if($appType -eq 'app') else { Compile-AppInBcContainer @tempParameters | Out-Null } + + $parameters.Value["preprocessorsymbols"] = Get-PreprocessorSymbols } if(($appBuildMode -eq 'Strict') -and !(Test-IsStrictModeEnabled)) { From 0deac233c24f1c40c23fdbf0cd06eb1e60c2a41a Mon Sep 17 00:00:00 2001 From: aholstrup1 Date: Tue, 3 Dec 2024 13:11:20 +0100 Subject: [PATCH 2/5] Refactor --- .github/actions/TestPreprocessorSymbols/action.ps1 | 2 +- build/scripts/GuardingV2ExtensionsHelper.psm1 | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/actions/TestPreprocessorSymbols/action.ps1 b/.github/actions/TestPreprocessorSymbols/action.ps1 index 97f45fbddf..34292bf0dc 100644 --- a/.github/actions/TestPreprocessorSymbols/action.ps1 +++ b/.github/actions/TestPreprocessorSymbols/action.ps1 @@ -19,7 +19,7 @@ if ($CurrentVersion -le 26) { # Define the preprocessor symbols to check for $symbolConfigs = @( - @{stem = "CLEAN"; lowerBound = ($CurrentVersion - 4); upperBound = $mainVersion}, + @{stem = "CLEAN"; lowerBound = (Get-MinAllowedCleantagVersion); upperBound = $mainVersion}, @{stem = "CLEANSCHEMA"; lowerBound = $schemaLowerBound; upperBound = $mainVersion + 3} # next lowerbound, after cleanup should be 25, then ) diff --git a/build/scripts/GuardingV2ExtensionsHelper.psm1 b/build/scripts/GuardingV2ExtensionsHelper.psm1 index 33b6aec12f..e6b4e0ff0e 100644 --- a/build/scripts/GuardingV2ExtensionsHelper.psm1 +++ b/build/scripts/GuardingV2ExtensionsHelper.psm1 @@ -268,12 +268,16 @@ function Get-MaxAllowedObsoleteVersion() { return [System.Version]::Parse($alGoSettings.repoVersion).Major } -function Get-PreprocessorSymbols() { +function Get-MinAllowedCleantagVersion() { Import-Module -Name $PSScriptRoot\EnlistmentHelperFunctions.psm1 - [int] $currentVersion = (Get-ConfigValue -Key "repoVersion" -ConfigType AL-Go) -split '\.' | Select-Object -First 1 + $lowerBound = $CurrentVersion - 4 + return $lowerBound +} + +function Get-PreprocessorSymbols() { [int] $upperBound = Get-MaxAllowedObsoleteVersion - [int] $lowerBound = $CurrentVersion - 4 + [int] $lowerBound = Get-MinAllowedCleantagVersion return $lowerBound..$upperBound | ForEach-Object { "CLEAN$_" } } From 864c63bd7a4afc1375ea2f11d8e6888001693509 Mon Sep 17 00:00:00 2001 From: aholstrup1 Date: Tue, 3 Dec 2024 13:19:53 +0100 Subject: [PATCH 3/5] Add back symbols --- .github/AL-Go-Settings.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/AL-Go-Settings.json b/.github/AL-Go-Settings.json index 921513e3e0..fc7379cc6c 100644 --- a/.github/AL-Go-Settings.json +++ b/.github/AL-Go-Settings.json @@ -10,6 +10,11 @@ "useProjectDependencies": true, "repoVersion": "26.0", "cleanModePreprocessorSymbols": [ + "CLEAN22", + "CLEAN23", + "CLEAN24", + "CLEAN25", + "CLEAN26" ], "unusedALGoSystemFiles": [ "AddExistingAppOrTestApp.yaml", From e21d7ef7e8a2a53e53e7e5ef7e34f6551b28e8a5 Mon Sep 17 00:00:00 2001 From: Alexander Holstrup <117829001+aholstrup1@users.noreply.github.com> Date: Wed, 4 Dec 2024 08:20:48 +0100 Subject: [PATCH 4/5] Update build/scripts/GuardingV2ExtensionsHelper.psm1 Co-authored-by: Maria Zhelezova <43066499+mazhelez@users.noreply.github.com> --- build/scripts/GuardingV2ExtensionsHelper.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/GuardingV2ExtensionsHelper.psm1 b/build/scripts/GuardingV2ExtensionsHelper.psm1 index e6b4e0ff0e..36dd8f142b 100644 --- a/build/scripts/GuardingV2ExtensionsHelper.psm1 +++ b/build/scripts/GuardingV2ExtensionsHelper.psm1 @@ -268,7 +268,7 @@ function Get-MaxAllowedObsoleteVersion() { return [System.Version]::Parse($alGoSettings.repoVersion).Major } -function Get-MinAllowedCleantagVersion() { +function Get-MinAllowedCleanTagVersion() { Import-Module -Name $PSScriptRoot\EnlistmentHelperFunctions.psm1 [int] $currentVersion = (Get-ConfigValue -Key "repoVersion" -ConfigType AL-Go) -split '\.' | Select-Object -First 1 $lowerBound = $CurrentVersion - 4 From df91290cc1105ce710546800da5235b34610930e Mon Sep 17 00:00:00 2001 From: Alexander Holstrup <117829001+aholstrup1@users.noreply.github.com> Date: Wed, 4 Dec 2024 08:20:57 +0100 Subject: [PATCH 5/5] Update .github/actions/TestPreprocessorSymbols/action.ps1 Co-authored-by: Maria Zhelezova <43066499+mazhelez@users.noreply.github.com> --- .github/actions/TestPreprocessorSymbols/action.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/TestPreprocessorSymbols/action.ps1 b/.github/actions/TestPreprocessorSymbols/action.ps1 index 34292bf0dc..e82b9a0487 100644 --- a/.github/actions/TestPreprocessorSymbols/action.ps1 +++ b/.github/actions/TestPreprocessorSymbols/action.ps1 @@ -19,7 +19,7 @@ if ($CurrentVersion -le 26) { # Define the preprocessor symbols to check for $symbolConfigs = @( - @{stem = "CLEAN"; lowerBound = (Get-MinAllowedCleantagVersion); upperBound = $mainVersion}, + @{stem = "CLEAN"; lowerBound = (Get-MinAllowedCleanTagVersion); upperBound = $mainVersion}, @{stem = "CLEANSCHEMA"; lowerBound = $schemaLowerBound; upperBound = $mainVersion + 3} # next lowerbound, after cleanup should be 25, then )