Skip to content

Add Assembly.TryGetVersionString() extension#5

Merged
Tyrrrz merged 2 commits intoprimefrom
copilot/add-assembly-trygetversionstring
Apr 12, 2026
Merged

Add Assembly.TryGetVersionString() extension#5
Tyrrrz merged 2 commits intoprimefrom
copilot/add-assembly-trygetversionstring

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

Adds a TryGetVersionString() extension on Assembly that returns the informational version string, falling back to the assembly version if AssemblyInformationalVersionAttribute is absent, and null if neither is set.

Changes

  • PowerKit/Extensions/AssemblyExtensions.cs: New extension returning AssemblyInformationalVersionAttribute.InformationalVersion ?? assembly.GetName().Version?.ToString()
  • PowerKit.Tests/AssemblyExtensionsTests.cs: Test covering the happy path against the test assembly

Usage

var version = Assembly.GetExecutingAssembly().TryGetVersionString();
// "1.2.3+abc123" (informational), "1.2.3.0" (fallback), or null

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/27692982-b613-470e-8e39-6ccfb40730e7

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
@Tyrrrz Tyrrrz added the enhancement New feature or request label Apr 12, 2026
@Tyrrrz Tyrrrz marked this pull request as ready for review April 12, 2026 12:36
Copilot AI review requested due to automatic review settings April 12, 2026 12:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Assembly extension to retrieve an assembly version string in a consumer-friendly way (prefer informational version; fall back to assembly version; otherwise null), along with a unit test in the test suite that compiles PowerKit as source.

Changes:

  • Added Assembly.TryGetVersionString() extension that reads AssemblyInformationalVersionAttribute and falls back to AssemblyName.Version.
  • Added an xUnit test for the new extension.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
PowerKit/Extensions/AssemblyExtensions.cs Introduces TryGetVersionString() that prioritizes informational version and falls back to assembly version.
PowerKit.Tests/AssemblyExtensionsTests.cs Adds a test for the new extension method.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PowerKit.Tests/AssemblyExtensionsTests.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants