Skip to content

Add manifest resource extensions to AssemblyExtensions#14

Merged
Tyrrrz merged 10 commits intoprimefrom
copilot/add-assembly-extensions-and-async-version
Apr 12, 2026
Merged

Add manifest resource extensions to AssemblyExtensions#14
Tyrrrz merged 10 commits intoprimefrom
copilot/add-assembly-extensions-and-async-version

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

Ports two utility methods from DotnetRuntimeBootstrapper into PowerKit's AssemblyExtensions, each with a sync and async variant.

New methods

  • GetManifestResourceString(resourceName, encoding) — reads an embedded resource as a string using the specified encoding
  • GetManifestResourceString(resourceName) — reads an embedded resource as a UTF-8 string (delegates to the encoding overload)
  • GetManifestResourceStringAsync(resourceName, encoding, ct) — async variant with encoding
  • GetManifestResourceStringAsync(resourceName, ct) — async UTF-8 variant (delegates to the encoding overload)
  • ExtractManifestResource(resourceName, filePath) — copies an embedded resource to a file
  • ExtractManifestResourceAsync(resourceName, filePath, ct) — async variant

All methods throw MissingManifestResourceException when the resource name isn't found.

var json = Assembly.GetExecutingAssembly().GetManifestResourceString("MyApp.config.json");
var latin = Assembly.GetExecutingAssembly().GetManifestResourceString("MyApp.data.txt", Encoding.Latin1);

await Assembly.GetExecutingAssembly().ExtractManifestResourceAsync("MyApp.bootstrap.exe", targetPath);

Copilot AI and others added 2 commits April 12, 2026 18:45
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/7d6f3603-259f-4fb5-bca3-a3b31e1779cc

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…tResourceString, and GetManifestResourceStringAsync to AssemblyExtensions

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/7d6f3603-259f-4fb5-bca3-a3b31e1779cc

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 19:21
Copilot AI review requested due to automatic review settings April 12, 2026 19:21
await ThisAssembly.ExtractManifestResourceAsync(ResourceName, tempFile.Path);

// Assert
File.ReadAllText(tempFile.Path).Should().Be("hello");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

async variant here @copilot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 2ae2487 — switched to await File.ReadAllTextAsync(tempFile.Path).

Copilot AI requested a review from Tyrrrz April 12, 2026 19:24
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

Ports manifest-resource helpers into PowerKit.Extensions.AssemblyExtensions to simplify reading embedded resources as UTF-8 strings and extracting them to files, with sync/async variants.

Changes:

  • Add GetManifestResourceString* and ExtractManifestResource* extension methods on Assembly.
  • Add a new embedded test resource (TestResource.txt) to the test project.
  • Add tests validating string reading and extraction behavior against the embedded resource.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
PowerKit/Extensions/AssemblyExtensions.cs Adds new manifest-resource read/extract extension methods (sync + async).
PowerKit.Tests/TestResource.txt Adds a simple embedded resource used by the new tests.
PowerKit.Tests/PowerKit.Tests.csproj Embeds TestResource.txt into the test assembly.
PowerKit.Tests/AssemblyExtensionsTests.cs Adds tests for the new extensions (string read + file extraction).

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

Comment thread PowerKit/Extensions/AssemblyExtensions.cs
Comment thread PowerKit/Extensions/AssemblyExtensions.cs Outdated
Comment thread PowerKit.Tests/AssemblyExtensionsTests.cs
Comment thread PowerKit/Extensions/AssemblyExtensions.cs
Comment thread PowerKit.Tests/TestData/TestResource.txt
Comment thread PowerKit/Extensions/AssemblyExtensions.cs
Comment thread PowerKit.Tests/TestData/TestResource.txt
Comment thread PowerKit/Extensions/AssemblyExtensions.cs Outdated
…esourceStringAsync

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/17bd53fb-ccc8-4472-b8d6-2ba22ff107a7

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Comment thread PowerKit/Extensions/AssemblyExtensions.cs Outdated
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


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

Comment thread PowerKit.Tests/AssemblyExtensionsTests.cs
Comment thread PowerKit.Tests/AssemblyExtensionsTests.cs
Comment thread PowerKit/Extensions/AssemblyExtensions.cs
Comment thread PowerKit/Extensions/AssemblyExtensions.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