mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-08 18:31:36 +01:00
Add events knowledge domain and review leaf skill
Add a new `events` knowledge domain covering AL events & subscribers, wired into the AL review pipeline. - 3 atomic articles (+ .good.al/.bad.al samples) under microsoft/knowledge/events/: the IsHandled override pattern, thin OnBefore/OnAfter integration-event publishers, and static vs manual subscribers. - New leaf skill microsoft/skills/review/al-events-review.md sourcing the events domain. - Wired into microsoft/skills/review/al-code-review.md (sub-skills + Source + description) and README.md (leaf-skill count + domain list). AL event syntax verified against Microsoft Learn. Samples are demonstration-only (not compiled by CI). Additive change; no contract change. Part of #34. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
45c2b2f5ec
commit
54ddd8ecc2
12 changed files with 477 additions and 2 deletions
|
|
@ -0,0 +1,38 @@
|
|||
// Demonstration-only AL. Not compiled by CI; illustrates the article.
|
||||
|
||||
// Anti-pattern 1: no OnBefore/IsHandled hook. A partner cannot replace this
|
||||
// rule without overwriting base code, so the behaviour is not extensible.
|
||||
codeunit 50222 "Shipping Charge NoHook Bad"
|
||||
{
|
||||
procedure CalculateShippingCharge(OrderAmount: Decimal) Charge: Decimal
|
||||
begin
|
||||
if OrderAmount >= 1000 then
|
||||
Charge := 0
|
||||
else
|
||||
Charge := 49;
|
||||
end;
|
||||
}
|
||||
|
||||
// Anti-pattern 2: the hook exists but the 'if IsHandled then exit;' guard is
|
||||
// missing, so the default logic still runs after a subscriber handled the call.
|
||||
codeunit 50223 "Shipping Charge Guard Bad"
|
||||
{
|
||||
procedure CalculateShippingCharge(OrderAmount: Decimal) Charge: Decimal
|
||||
var
|
||||
IsHandled: Boolean;
|
||||
begin
|
||||
OnBeforeCalculateShippingCharge(OrderAmount, Charge, IsHandled);
|
||||
|
||||
// Bug: no 'if IsHandled then exit;' here. Even when a subscriber set
|
||||
// Charge and IsHandled := true, the default below overwrites the result.
|
||||
if OrderAmount >= 1000 then
|
||||
Charge := 0
|
||||
else
|
||||
Charge := 49;
|
||||
end;
|
||||
|
||||
[IntegrationEvent(false, false)]
|
||||
local procedure OnBeforeCalculateShippingCharge(OrderAmount: Decimal; var Charge: Decimal; var IsHandled: Boolean)
|
||||
begin
|
||||
end;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue