From 07369b02d83ab3eb6b03120f95ca933a92f773ee Mon Sep 17 00:00:00 2001 From: Arthur van de Vondervoort Date: Thu, 26 Nov 2026 17:17:48 +0100 Subject: [PATCH 1/2] docs(PC0031): document hand-off suppression and the single-body scope Co-Authored-By: Claude Fable 5.1 --- content/docs/analyzers/PlatformCop/PC0031.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/docs/analyzers/PlatformCop/PC0031.md b/content/docs/analyzers/PlatformCop/PC0031.md index 0d5176e..20c3aa1 100644 --- a/content/docs/analyzers/PlatformCop/PC0031.md +++ b/content/docs/analyzers/PlatformCop/PC0031.md @@ -48,7 +48,9 @@ The diagnostic is not raised for `Modify`, `ModifyAll`, `DeleteAll`, or `Init`. The diagnostic is also suppressed when the write operation is inside a conditional branch (`if`, `case`, `while`, `for`, `foreach`), because the write may only execute on a path where the record was not loaded via partial records. `repeat..until` loops are still flagged because the body always executes at least once. -Temporary record variables (no SQL backing, no JIT load) and record variables where `Clear()` or `Reset()` is called between the `SetLoadFields` and the write operation (resetting the partial records state) are also skipped. +Temporary record variables (no SQL backing, no JIT load) are skipped, and so is a record variable whose partial-records state is reset or handed off between the partial read and the write operation: `Clear()`, `Reset()`, `SetLoadFields()` without arguments, passing the variable by `var` to a procedure or event publisher, passing it to `Codeunit.Run`, `Page.Run` or a similar built-in, or calling a table procedure on it. The callee may reset the load selection, so the write is no longer known to JIT-load. Passing the variable by value does not suppress the diagnostic: the callee works on a copy with its own load selection. + +The rule analyzes one procedure or trigger body and its local variables only. Global variables, parameters, flows through other procedures and event subscribers are not analyzed, because the record's load state is not visible there: which procedure ran first on a global, what the caller did before passing a parameter, or whether a publisher loaded the record partially cannot be determined statically, and procedures from a dependency have no body to inspect. A subscriber that needs additional fields of a record it receives should call `AddLoadFields` rather than `SetLoadFields`, which would overwrite the publisher's selection. ### See also From ac8021f91edb74bf2532ae3c9e5b22f715d30489 Mon Sep 17 00:00:00 2001 From: Arthur van de Vondervoort Date: Thu, 26 Nov 2026 17:29:46 +0100 Subject: [PATCH 2/2] docs(PC0031): by-value RecordRef hand-offs also suppress Co-Authored-By: Claude Fable 5.1 --- content/docs/analyzers/PlatformCop/PC0031.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/analyzers/PlatformCop/PC0031.md b/content/docs/analyzers/PlatformCop/PC0031.md index 20c3aa1..bab5ec9 100644 --- a/content/docs/analyzers/PlatformCop/PC0031.md +++ b/content/docs/analyzers/PlatformCop/PC0031.md @@ -48,7 +48,7 @@ The diagnostic is not raised for `Modify`, `ModifyAll`, `DeleteAll`, or `Init`. The diagnostic is also suppressed when the write operation is inside a conditional branch (`if`, `case`, `while`, `for`, `foreach`), because the write may only execute on a path where the record was not loaded via partial records. `repeat..until` loops are still flagged because the body always executes at least once. -Temporary record variables (no SQL backing, no JIT load) are skipped, and so is a record variable whose partial-records state is reset or handed off between the partial read and the write operation: `Clear()`, `Reset()`, `SetLoadFields()` without arguments, passing the variable by `var` to a procedure or event publisher, passing it to `Codeunit.Run`, `Page.Run` or a similar built-in, or calling a table procedure on it. The callee may reset the load selection, so the write is no longer known to JIT-load. Passing the variable by value does not suppress the diagnostic: the callee works on a copy with its own load selection. +Temporary record variables (no SQL backing, no JIT load) are skipped, and so is a record variable whose partial-records state is reset or handed off between the partial read and the write operation: `Clear()`, `Reset()`, `SetLoadFields()` without arguments, passing the variable by `var` to a procedure or event publisher, passing it to `Codeunit.Run`, `Page.Run` or a similar built-in, or calling a table procedure on it. The callee may reset the load selection, so the write is no longer known to JIT-load. Passing a `Record` variable by value does not suppress the diagnostic: the callee works on a copy with its own load selection. A `RecordRef` passed by value still refers to the same table instance, so it does suppress it. The rule analyzes one procedure or trigger body and its local variables only. Global variables, parameters, flows through other procedures and event subscribers are not analyzed, because the record's load state is not visible there: which procedure ran first on a global, what the caller did before passing a parameter, or whether a publisher loaded the record partially cannot be determined statically, and procedures from a dependency have no body to inspect. A subscriber that needs additional fields of a record it receives should call `AddLoadFields` rather than `SetLoadFields`, which would overwrite the publisher's selection.