|
| 1 | +# Instructions for Copilot |
| 2 | +## Code Generation |
| 3 | +- All code must be written in **English**. |
| 4 | +- Explicitly declare **access modifiers** for procedures (`local`, `internal`, `public`), prioritizing `local` or `internal` as appropriate. |
| 5 | +- When using `Insert`, `Modify`, `Delete` or `DeleteAll`, always pass `true` as a parameter to ensure full execution of business logic. Example: `Insert(true)`, `Modify(true)`. |
| 6 | +- When using `FindSet()`, specify the parameter according to the block’s intent. If the table will be modified, use `FindSet(true)`; otherwise, use `FindSet(false)`. |
| 7 | +- When assigning a value to a field, **do not assign it directly**; use `Validate` to ensure the correct execution of related logic. |
| 8 | +- Do not hardcode **text** in messages or user interaction elements. Use `Labels` to facilitate translation file generation. |
| 9 | +- Do not declare multiple variables of the same type in a single line. Incorrect example: `MyInt1, MyInt2, MyInt3: Integer;`. |
| 10 | +- Control all graphical interface elements (`Message`, `Confirm`, etc.) using `GuiAllowed()` to prevent errors in background processes. |
| 11 | +- Use the correct suffix in `Label`-type variables according to their purpose: |
| 12 | + - `Msg` – Messages. |
| 13 | + - `Tok` – Constants such as tokens, URLs, etc. |
| 14 | + - `Err` – Errors. |
| 15 | + - `Qst` – For `StrMenu` or `Confirm`. |
| 16 | + - `Lbl` – Texts that require translation (`Label`, `Caption`). |
| 17 | +- Apply **SOLID** principles in code design: |
| 18 | + - **SRP** – Single Responsibility Principle: Each module should have only one reason to change. |
| 19 | + - **OCP** – Open/Closed Principle: Code should be open for extension (events, interfaces) but closed for direct modification. |
| 20 | + - **LSP** – Liskov Substitution Principle: Use interfaces to ensure implementations can be interchanged without altering expected behavior. |
| 21 | + - **ISP** – Interface Segregation Principle: Split large interfaces into several smaller, more specific ones. |
| 22 | + - **DIP** – Dependency Inversion Principle: Modules should depend on abstractions (interfaces, events), not on concrete implementations. |
| 23 | +- Do not use `Find(-)`, `Find(+)`, `Find(=)`, etc. Use `FindFirst()`, `FindLast()` or `FindSet()` instead. |
| 24 | +- Always use the most appropriate data type: `primitive types`, `List`, `Dictionary`, `JsonObject`, `TextBuilder`, among others. |
| 25 | +- All objects and procedures must be properly documented using **XML comments**. |
| 26 | +- Do not use `//` or `/* */` comments; all documentation must be provided through XML blocks above procedures and objects. |
| 27 | +- Avoid adding redundant or unhelpful comments. |
| 28 | +- When adding elements to pages, prioritize `AddFirst` or `AddLast` over `AddAfter` or `AddBefore`. |
| 29 | +- Ensure **referential integrity** when linking fields. |
| 30 | +- In event subscriptions, explicitly configure: `SkipOnMissingLicense = false` and `SkipOnMissingPermission = false`. |
| 31 | +- Remove unnecessary lines such as redundant calls to `Reset` or default initializations for newly created variables. |
| 32 | +- When a variable refers to an object, use the exact **same name** as the object, with no spaces, quotes, or special characters. |
| 33 | +- Consider the **cyclomatic complexity** of the code. |
| 34 | +- Simplify control structures and avoid unnecessary `begin/end` blocks. |
| 35 | +- If a function has more than six parameters, consider using structures like `Dictionary`, `Record`, or others to simplify the call. |
| 36 | +- Always declare the **exact length** for `Text` or `Code` type fields and variables. |
| 37 | +- If adding `FlowField` type fields in a table, make sure to set `Editable = false`. |
| 38 | +- Use **PascalCase** for naming objects, functions, and variables. |
| 39 | +- Do not use `Option`; create an `Enum` type instead. |
| 40 | +- When subscribing to an event that receives a table as a parameter, first check if it is **temporary**. If it is, use `exit;`. |
| 41 | +- Do not include code directly within **triggers**; create separate functions that can be called from the trigger. |
| 42 | +- In new tables, add the `DataClassification` property **only at the table level**, **never on individual fields**. |
| 43 | +- In table extensions, **do not add `DataClassification` at the table level**; this will cause an error. Add it only to specific fields. |
| 44 | +- Avoid **hardcoding** object IDs. Use the **object name** instead. |
| 45 | +- Structure the code according to its purpose. Prioritize in the following order: |
| 46 | + - Use **codeunits** for general and reusable logic. |
| 47 | + - Use **tables** for logic related to entities. |
| 48 | + - Use **pages** exclusively for user interaction. |
| 49 | +- All variable names must be **clear and descriptive**. Avoid meaningless abbreviations or single letters. |
| 50 | +- When creating a table, define the `DrillDownPageId` and `LookupPageId` properties, referencing the corresponding list-type page. |
| 51 | +- Use the condition directly in validations. Avoid constructs like `if Condition = true` or `= false`. |
| 52 | + |
| 53 | +## Code Review |
| 54 | +- Verify that all added procedures are documented with XML blocks. |
| 55 | +- Ensure the code complies with all established generation instructions. |
| 56 | +- Make code review comments in English and respectfully insulting the developer in Spanish as a loving reminder that they can do better. |
| 57 | + |
| 58 | +## Commit Message Generation |
| 59 | +- The message must be written in English. |
| 60 | +- Use the following format: |
| 61 | + `[Type] - [Branch Name] - [Brief Description]` |
| 62 | + Example: `Bug - EV001 - Optimización del cálculo de impuestos` |
| 63 | +- Include a clear, precise, and concise description of the changes made. |
| 64 | + |
| 65 | +## Pull Request Title and Description Generation Instructions |
| 66 | +- Titles: Use a clear format that includes the main purpose of the changes. |
| 67 | + Example: `Fix: Error in discount calculation logic` |
| 68 | +- Descriptions: Include an overview of the changes made, explaining their impact and purpose. |
0 commit comments