# Generator diagnostics

Every build-time warning and error the source generator can raise, with its SCGDB id, what triggers it, and how to suppress or escalate it from .editorconfig.

## Overview

Beyond emitting code, the source generator inspects your tables and `.sql` procedure files at build time and reports problems as standard Roslyn diagnostics. Each one has a stable **`SCGDB###`** id, shows up in the IDE error list and in `dotnet build` output, and points at the offending property, attribute, or `.sql` file.

Because they are ordinary compiler diagnostics, you control their severity from `.editorconfig` exactly like any analyzer rule — see [Configuring severity](#configuring-severity). All diagnostics share the `Socigy.DB` category.

---

## Table & column definitions

These fire on the `[Table]` class or property they describe, so the squiggle lands directly on your C# source.

| Id | Severity | Triggered when |
|----|----------|----------------|
| `SCGDB001` | Error | `[AutoIncrement]` is applied to a property whose type is not `short`, `int`, or `long`. |
| `SCGDB002` | Error | `[Encrypted]` is combined with `[ValueConvertor]`, `[JsonColumn]`, or `[RawJsonColumn]` on the same property. See [Encrypted columns](/database/0.3.0/defining-models/encrypted-columns). |
| `SCGDB016` | Warning | A `[Table]` class declares no `[PrimaryKey]` column. Generated `Update()` / `Delete()` need a primary key to target rows. |
| `SCGDB017` | Warning | A `[Table]` class has no mapped columns. |
| `SCGDB018` | Error | A `[Column("")]` is given an empty or whitespace name. |

---

## SQL procedure files

These fire while processing [procedure-mapping](/database/0.3.0/advanced/procedure-mapping) `.sql` files and attach to the `.sql` file itself.

| Id | Severity | Triggered when |
|----|----------|----------------|
| `SCGDB003` | Warning | A `.sql` file contains no `{{Type}}` / `{{Type.Property}}` placeholder. Suppress per-file with `-- @ignore warning` — see [Suppressing the placeholder warning](/database/0.3.0/advanced/procedure-mapping#suppressing-the-placeholder-warning). |
| `SCGDB004` | Error | A placeholder references a type that does not exist in the compilation. |
| `SCGDB005` | Error | A `{{Type.Property}}` placeholder references a property that does not exist on the named type. |
| `SCGDB006` | Error | A placeholder is malformed; it must be `{{TypeName}}` (table) or `{{TypeName.PropertyName}}` (column). |
| `SCGDB007` | Error | A placeholder references a type that is not a `[Table]` / `[FlagTable]`. |
| `SCGDB008` | Error | A placeholder's simple type name is ambiguous; use a fully-qualified name. |
| `SCGDB009` | Warning | A `-- @param` is declared but never referenced in the SQL body. |
| `SCGDB010` | Warning | The SQL body references `@name` but no matching `-- @param` declaration exists. |
| `SCGDB011` | Warning | The `-- @returns` type cannot be resolved in the compilation. |
| `SCGDB012` | Warning | A `-- @param` line is malformed; expected `-- @param name: CSharpType`. |
| `SCGDB013` | Warning | A `.sql` file is registered as `<AdditionalFiles>` but lives outside `Socigy/Procedures/`, so it was ignored. |
| `SCGDB014` | Warning | A `.sql` file has an empty body after its header and produced no method. |
| `SCGDB015` | Error | Two procedure files resolve to the same method name in the same namespace group. Only the first is emitted. |

> **NOTE** `SCGDB009` and `SCGDB010` analyse raw SQL text, so unusual constructs (PostgreSQL `@@` operators, casts inside string literals) can occasionally produce a false positive. They are warnings by design — silence an individual rule with `.editorconfig` if it does not fit your SQL style.

---

## Suppressing diagnostics

### Per-file: `-- @ignore warning`

The missing-placeholder warning (`SCGDB003`) is silenced for a single `.sql` file by adding the directive to its header:

```sql
-- @ignore warning: optional free-form reason
```

See [Procedure mapping → Suppressing the placeholder warning](/database/0.3.0/advanced/procedure-mapping#suppressing-the-placeholder-warning).

### Inline: `#pragma` and `[SuppressMessage]`

Diagnostics reported on a `.cs` location (the table and column rules) can be suppressed inline like any analyzer warning:

```csharp
#pragma warning disable SCGDB016
[Table("audit_log")] // intentionally key-less, append-only table
public partial class AuditLog { /* ... */ }
#pragma warning restore SCGDB016
```

---

## Configuring severity

Set any diagnostic's severity from `.editorconfig`. The section glob must match the **file the diagnostic points at** — `.cs` for table/column rules, `.sql` for procedure rules — or use a global section:

```ini
# Promote the missing-primary-key warning to an error
[*.cs]
dotnet_diagnostic.SCGDB016.severity = error

# Make a missing schema placeholder a hard build error
[*.sql]
dotnet_diagnostic.SCGDB003.severity = error

# Silence "declared but unused parameter" everywhere
[*.sql]
dotnet_diagnostic.SCGDB009.severity = none
```

Valid severities are `error`, `warning`, `suggestion`, `silent`, `none`, and `default`.

> **NOTE** `.editorconfig` severity and the `-- @ignore warning` directive are independent and complementary. Use the directive to silence one file; use `.editorconfig` to change a rule across the whole project.
