---
title: SAIF.Framework.CodeGen business rules
summary: Enumerated business rules with per-rule trigger, enforcement, and outcomes.
status: draft
owner: <owner>
last_reviewed: 2026-07-23
library: SAIF.Framework.CodeGen
reference_type: package
---

# SAIF.Framework.CodeGen business rules

This page captures business rules enforced by `SAIF.Framework.CodeGen`.

## BR-001: Enum member identifiers must be unique within a generated block

| Field | Value |
| --- | --- |
| **Statement** | Enum member identifiers must be unique within a generated block |
| **Trigger** | Two or more table rows resolve to the same computed identifier |
| **Enforcement** | `CreateCaseStatement`/`CreateEnumStatement`: `If (enumValues.ContainsKey(enumValue)) Then enumValue += row("code").ToString` |
| **Outcome** | The row's raw `code` value is appended to the identifier to disambiguate before emission |
| **Tables** | [CODE_TABLE (caller-supplied)](database-tables.md#code_table-caller-supplied) |
| **SQL** | [SQL-001](sql/SQL-001-select-code-table.md) |
| **Source** | SAIF.Framework.CodeGen\CodeTableMap.vb |

---

## BR-002: Generated enum-member identifiers must be legal VB identifiers

| Field | Value |
| --- | --- |
| **Statement** | Generated enum-member identifiers must be legal VB identifiers (cannot start with a digit) |
| **Trigger** | `GetEnumValue` computes a candidate identifier that is purely numeric |
| **Enforcement** | `GetEnumValue`: `If (IsNumeric(enumValue)) Then enumValue = "Code" & enumValue` |
| **Outcome** | Identifier is prefixed with the literal string `"Code"` |
| **Tables** | [CODE_TABLE (caller-supplied)](database-tables.md#code_table-caller-supplied) |
| **SQL** | [SQL-001](sql/SQL-001-select-code-table.md) |
| **Source** | SAIF.Framework.CodeGen\CodeTableMap.vb |

---

## BR-003: Enum-member identifier derivation strips non-alphabetic characters from the description

| Field | Value |
| --- | --- |
| **Statement** | Enum-member identifier derivation strips non-alphabetic characters from the description |
| **Trigger** | `useDescriptionAsCode = True` (the default) |
| **Enforcement** | `GetEnumValue`: `Text.RegularExpressions.Regex.Replace(row("code_descr").ToString, "[^a-zA-Z]", "", ...)` |
| **Outcome** | Only letters are retained from `code_descr` to form the identifier; when `useDescriptionAsCode = False`, the raw `code` value is used instead |
| **Tables** | [CODE_TABLE (caller-supplied)](database-tables.md#code_table-caller-supplied) |
| **SQL** | [SQL-001](sql/SQL-001-select-code-table.md) |
| **Source** | SAIF.Framework.CodeGen\CodeTableMap.vb |

---

## BR-004: Data connection is only re-established when parameters change

| Field | Value |
| --- | --- |
| **Statement** | Data connection is only re-established when parameters change |
| **Trigger** | `Connect` is called again on an already-connected `CodeTableMap` instance |
| **Enforcement** | `Connect`: compares `m_dpi.Database <> database Or m_dpi.dbUser <> dbUser` before reconnecting |
| **Outcome** | Avoids redundant `clsMSOracleDataLayer` construction when the same database/user pair is reused |
| **Source** | SAIF.Framework.CodeGen\CodeTableMap.vb |

## Notes
- No callers of `CodeTableMap` exist anywhere in this repository, so the real-world invocation context for these rules (console tool, IDE custom-tool, or manual developer use) could not be confirmed**.
- `Public Enum CodeBlockType` (`CaseStatement`, `EnumStatement`) is defined but is not referenced by any live code enforcing these rules; its intended consumer is unknown**.

## Related documentation
- [Index](index.md)
- [Overview](overview.md)
- [Architecture](architecture.md)
- [Dependencies](dependencies.md)
- [Operations and processes](operations-processes.md)
- [Configuration](configuration.md)
- [Database tables](database-tables.md)
- [SQL catalog](sql/index.md)
- [API reference](api/index.md)

> **Note:** Statements marked with `**` could not be confirmed; treat as unknown until verified.

## Sources
- SAIF.Framework.CodeGen\CodeTableMap.vb
