executable-version-string-parsing
Summary
Parse version strings returned by a compiled executable (invoked via system call) to enable runtime inspection of wrapped binary dependencies. This skill bridges R and external compiled assemblies by extracting version metadata that documents the underlying implementation.
When to use
Your R package wraps a compiled .NET assembly or binary executable and you need to expose the version of that dependency to users at runtime for troubleshooting, validation, or documentation purposes. Specifically, when the assembly version is not easily queryable from within R and must be retrieved by spawning a subprocess that reports version information as text output.
When NOT to use
- The wrapped binary already exposes version metadata via an R API or environment variable — use direct API queries instead.
- The assembly version is static and baked into your R package metadata at install time — use DESCRIPTION or package-level constants.
- The underlying executable is not guaranteed to be available or installed on the user's system — version querying will fail; provide a fallback or graceful degradation.
Inputs
- Compiled .NET assembly or executable (on disk)
- Executable name or path (string)
- Version-query CLI flag or command (string, e.g. '--version')
Outputs
- Version string (character vector)
- Normalized file path to assembly (character vector)
- Validated assembly metadata (list or named character)
How to apply
Create an internal R function that invokes the wrapped executable with a version-query flag using system2(), capturing stdout to a text connection. Parse the raw text output using string matching or regular expressions to extract the version string, validate it is non-empty, and return it as a character vector. The article demonstrates this pattern: rawrr:::.getRawrrAssemblyVersion() calls the rawrr executable, captures its version output, and parses the resulting text. Combine this with a path-locating function (e.g., rawrr:::.rawrrAssembly()) that returns the normalized file path to the precompiled executable, allowing users to verify both the location and version of the dependency in a single workflow.
Related tools
Examples
rawrr:::.getRawrrAssemblyVersion()
Evaluation signals
- rawrr:::.getRawrrAssemblyVersion() returns a non-empty character vector matching semantic versioning pattern (e.g., '2.0.0' or '1.5.123')
- rawrr:::.rawrrAssembly() returns a normalized file path that exists on disk (file.exists() returns TRUE)
- Calling both functions in sequence produces consistent results across multiple invocations (idempotency)
- Text parsing correctly handles whitespace, newlines, and common version prefix patterns (e.g., 'v1.0', 'version 1.0')
- Subprocess call does not hang or raise errors when executable is present and in PATH or explicitly located
Limitations
- Subprocess invocation is platform-dependent; executable must be in PATH or explicitly located, and system2() behavior may differ on Windows, macOS, and Linux.
- Version string format is fragile: parsing logic must be updated if the executable's version output format changes between releases.
- If the executable is not installed or not found, the function will raise an error; no graceful fallback is provided for missing binaries.
- Temporary file handles and text connections must be properly closed to avoid resource leaks in long-running applications.
- Version metadata reflects only the executable version, not the internal state or schema version of binary data files (e.g., raw files may be newer or older than the reader).
Evidence
- [other] The rawrr package provides internal functions rawrr:::.rawrrAssembly() to report the .NET assembly path and rawrr:::.getRawrrAssemblyVersion() to retrieve the assembly version, enabling runtime inspection of the wrapped RawFileReader dependency.: "internal functions rawrr:::.rawrrAssembly() to report the .NET assembly path and rawrr:::.getRawrrAssemblyVersion() to retrieve the assembly version, enabling runtime inspection"
- [other] Create the internal function rawrr:::.getRawrrAssemblyVersion() that invokes the rawrr executable with a version-query flag via system2() and parses the text connection output to extract and return the version string.: "invokes the rawrr executable with a version-query flag via system2() and parses the text connection output to extract and return the version string"
- [other] Validate that both functions return non-empty character vectors and that the assembly file path exists on disk.: "Validate that both functions return non-empty character vectors and that the assembly file path exists on disk"
- [methods] R functions requesting access to data stored in binary raw files (reader family functions listed in Table 1) invoke compiled C# wrapper methods using a system call.: "R functions requesting access to data stored in binary raw files invoke compiled C# wrapper methods using a system call"
- [methods] In order to return extracted data back to the R layer we use file I/O. More specifically, the extracted information is written to a temporary location on the harddrive, read back into memory and: "extracted information is written to a temporary location on the harddrive, read back into memory and parsed into R objects"
1---2name: executable-version-string-parsing3description: Use when your R package wraps a compiled .NET assembly or binary executable and you need to expose the version of that dependency to users at runtime for troubleshooting, validation, or documentation purposes.4license: CC-BY-4.05---67# executable-version-string-parsing89## Summary1011Parse version strings returned by a compiled executable (invoked via system call) to enable runtime inspection of wrapped binary dependencies. This skill bridges R and external compiled assemblies by extracting version metadata that documents the underlying implementation.1213## When to use1415Your R package wraps a compiled .NET assembly or binary executable and you need to expose the version of that dependency to users at runtime for troubleshooting, validation, or documentation purposes. Specifically, when the assembly version is not easily queryable from within R and must be retrieved by spawning a subprocess that reports version information as text output.1617## When NOT to use1819- The wrapped binary already exposes version metadata via an R API or environment variable — use direct API queries instead.20- The assembly version is static and baked into your R package metadata at install time — use DESCRIPTION or package-level constants.21- The underlying executable is not guaranteed to be available or installed on the user's system — version querying will fail; provide a fallback or graceful degradation.2223## Inputs2425- Compiled .NET assembly or executable (on disk)26- Executable name or path (string)27- Version-query CLI flag or command (string, e.g. '--version')2829## Outputs3031- Version string (character vector)32- Normalized file path to assembly (character vector)33- Validated assembly metadata (list or named character)3435## How to apply3637Create an internal R function that invokes the wrapped executable with a version-query flag using system2(), capturing stdout to a text connection. Parse the raw text output using string matching or regular expressions to extract the version string, validate it is non-empty, and return it as a character vector. The article demonstrates this pattern: rawrr:::.getRawrrAssemblyVersion() calls the rawrr executable, captures its version output, and parses the resulting text. Combine this with a path-locating function (e.g., rawrr:::.rawrrAssembly()) that returns the normalized file path to the precompiled executable, allowing users to verify both the location and version of the dependency in a single workflow.3839## Related tools4041- **RawFileReader** (Compiled .NET assembly being wrapped; version is queried via subprocess invocation) — https://github.com/thermofisherlsms/RawFileReader42- **rawrr** (R package that implements the version-parsing functions and wraps RawFileReader) — https://github.com/fgcz/rawrr43- **system2** (R base function used to invoke the executable and capture text output)4445## Examples4647```48rawrr:::.getRawrrAssemblyVersion()49```5051## Evaluation signals5253- rawrr:::.getRawrrAssemblyVersion() returns a non-empty character vector matching semantic versioning pattern (e.g., '2.0.0' or '1.5.123')54- rawrr:::.rawrrAssembly() returns a normalized file path that exists on disk (file.exists() returns TRUE)55- Calling both functions in sequence produces consistent results across multiple invocations (idempotency)56- Text parsing correctly handles whitespace, newlines, and common version prefix patterns (e.g., 'v1.0', 'version 1.0')57- Subprocess call does not hang or raise errors when executable is present and in PATH or explicitly located5859## Limitations6061- Subprocess invocation is platform-dependent; executable must be in PATH or explicitly located, and system2() behavior may differ on Windows, macOS, and Linux.62- Version string format is fragile: parsing logic must be updated if the executable's version output format changes between releases.63- If the executable is not installed or not found, the function will raise an error; no graceful fallback is provided for missing binaries.64- Temporary file handles and text connections must be properly closed to avoid resource leaks in long-running applications.65- Version metadata reflects only the executable version, not the internal state or schema version of binary data files (e.g., raw files may be newer or older than the reader).6667## Evidence6869- [other] The rawrr package provides internal functions rawrr:::.rawrrAssembly() to report the .NET assembly path and rawrr:::.getRawrrAssemblyVersion() to retrieve the assembly version, enabling runtime inspection of the wrapped RawFileReader dependency.: "internal functions rawrr:::.rawrrAssembly() to report the .NET assembly path and rawrr:::.getRawrrAssemblyVersion() to retrieve the assembly version, enabling runtime inspection"70- [other] Create the internal function rawrr:::.getRawrrAssemblyVersion() that invokes the rawrr executable with a version-query flag via system2() and parses the text connection output to extract and return the version string.: "invokes the rawrr executable with a version-query flag via system2() and parses the text connection output to extract and return the version string"71- [other] Validate that both functions return non-empty character vectors and that the assembly file path exists on disk.: "Validate that both functions return non-empty character vectors and that the assembly file path exists on disk"72- [methods] R functions requesting access to data stored in binary raw files (reader family functions listed in Table 1) invoke compiled C# wrapper methods using a system call.: "R functions requesting access to data stored in binary raw files invoke compiled C# wrapper methods using a system call"73- [methods] In order to return extracted data back to the R layer we use file I/O. More specifically, the extracted information is written to a temporary location on the harddrive, read back into memory and: "extracted information is written to a temporary location on the harddrive, read back into memory and parsed into R objects"