Skip to content

Parse version input

This operation turns a dot-delimited string such as "1.2.3.4" into a fully populated Version instance. It backs two entry points: the shared Version.Parse(input) factory method, and the New Version(input) string constructor, which calls Parse internally and copies the result onto the instance being constructed.

Field Value
Operation ID OP-VER-001
Trigger Caller constructs New Version(input) or invokes Version.Parse(input)
Inputs input As String
Outputs New Version instance with Major, Minor, Build, and Revision populated
Primary components Version.New(input As String), Version.Parse(input As String)
Entry point SAIF.Framework.Version\Version.vb

Steps

  1. If the caller used the string constructor, New Version(input) delegates immediately to Version.Parse(input) and applies the returned segments to the new instance.
  2. Split input on the . character to produce versionParts.
  3. On failure: if input is Nothing, String.Split throws, and because there is no local guard, the exception propagates unchanged to the caller.
  4. Seed local working variables with the defaults major = "1", minor = "0", build = "0", and revision = "0".
  5. Overwrite major with versionParts(0).
  6. If the first token is blank: the blank value replaces the "1" default, so a leading empty segment is never defaulted — only the trailing segments benefit from the seeded defaults.
  7. Copy versionParts(1), versionParts(2), and versionParts(3) into minor, build, and revision respectively, but only for indexes that the split actually produced; any index the input omits keeps its seeded "0" value (BR-002).
  8. If input contains more than four dot-separated segments: every token beyond index 3 is ignored and never surfaces in the result.
  9. Construct New Version(major, minor, build, revision) and return it to the caller.
  10. If this path was entered from the string constructor: the constructor's internal Update step copies these four segment values onto the instance under construction, so the caller sees a fully initialized object rather than the intermediate result.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Caller provides version string]) --> Split[Split input on dot]
    Split --> Defaults[Seed local segment defaults]
    Defaults --> Major[Overwrite Major with first segment]
    Major --> Missing{Trailing segments present?}
    Missing -->|Yes| Copy[Copy available trailing segments]
    Missing -->|No| Keep[Keep seeded 0 defaults]
    Copy --> BuildVersion[Construct new Version instance]
    Keep --> BuildVersion
    BuildVersion --> EndOk([Return populated Version instance])

Failure and edge-case behavior

  • A Nothing input is not caught locally; the runtime exception from String.Split surfaces directly to the caller.
  • The major = "1" seed only matters when the split itself fails to produce a first token, which does not happen for any non-null input; in practice, Major is always taken verbatim from the first dot-separated segment, blank or not.
  • Segments beyond the fourth are silently dropped — a five-part input such as "1.2.3.4.5" parses identically to "1.2.3.4".

Sources

  • SAIF.Framework.Version\Version.vb