Increment version from template¶
This operation advances an existing Version instance according to a caller-supplied four-part format template, typically used in version-stamping workflows during a build. Each template segment independently chooses one of four behaviors: auto-increment the prior numeric value (*), retain the current value (empty token), substitute a literal string, or expand a date placeholder. Once all four segments are resolved, the assembled string is re-parsed and applied back onto the same instance.
| Field | Value |
|---|---|
| Operation ID | OP-VER-004 |
| Trigger | Caller invokes Version.Increment(format) |
| Inputs | format As String, current Major, Minor, Build, and Revision values |
| Outputs | Updated Version instance (Me) |
| Primary components | Version.Increment, Version.Parse, Version.Update, Extensions.ToInt |
| Entry point | SAIF.Framework.Version\Version.vb |
Steps¶
- Snapshot the instance's current
Major,Minor,Build, andRevisionvalues intom_lastVersion, preserving the pre-increment state for use in wildcard substitution. - Split
formaton.and initialize the assembly template"{0}.{1}.{2}.{3}". - On failure: if
formatisNothing,String.Splitthrows and the exception propagates to the caller unhandled. - Iterate segment indexes
0through3, mapping each index to the corresponding current value —Major,Minor,Build, orRevision. - For each index, attempt to read the matching token from the split
formatarray. - If the array access fails because
formatsupplied fewer than four segments: fall back to the prior segment value (lastValue) for that position, so a short-format string still resolves to a complete four-part result. - If the token contains
*, substitute the placeholder with(lastValue.ToInt + 1)— the prior value's numeric form, incremented by one (BR-001, BR-003). ToIntnormalizes the prior segment before the increment is applied, matching the same rule used for comparisons.- On failure: a prior segment value that is non-numeric or fails conversion normalizes to
0before incrementing, so the resulting segment becomes1rather than raising an error (BR-001). - If the token is an empty string, keep the segment's existing value unchanged rather than replacing or blanking it (BR-004).
- For any other token, copy the literal text into the output segment as-is; no numeric validation is applied to literal tokens.
- Once all four segments are resolved, replace any
{year},{month}, and{day}placeholders in the assembled string with the corresponding parts of the current date (Now) (BR-005). - Parse the fully assembled four-part string with
Version.Parse, apply the result to the current instance viaUpdate, and returnMe. - This final parse reuses the same segment-splitting and default-filling logic described in Parse version input, so any segment left incomplete by the template resolves the same way a directly parsed string would.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Caller invokes Increment]) --> Snapshot[Snapshot current version as last version]
Snapshot --> Split[Split format into per-segment tokens]
Split --> Loop{Evaluate each segment token}
Loop -->|Wildcard| Auto[Increment normalized prior value by 1]
Loop -->|Empty| Keep[Keep existing segment value]
Loop -->|Literal| Literal[Copy literal token unchanged]
Loop -->|Missing token| Fallback[Fall back to prior segment value]
Auto --> Date[Expand year month day placeholders]
Keep --> Date
Literal --> Date
Fallback --> Date
Date --> Parse[Parse the assembled four-part string]
Parse --> Update[Apply parsed segments to current instance]
Update --> EndOk([Return Me, updated in place])
Failure and edge-case behavior¶
- A
Nothingformatis not handled locally; the resulting exception propagates to the caller. - A
formatstring shorter than four segments is not rejected — the missing positions simply fall back to their prior values through the array-access failure path rather than an explicit length check. - Literal segment text passes through without numeric validation; only the wildcard path is normalized through
ToInt. - Wildcard increments always operate on the normalized prior value, so a malformed or non-numeric current segment increments from
0rather than failing (BR-001, BR-003).
Related documentation¶
Sources¶
SAIF.Framework.Version\Version.vb