Add manifest resource extensions to AssemblyExtensions#14
Conversation
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>
| await ThisAssembly.ExtractManifestResourceAsync(ResourceName, tempFile.Path); | ||
|
|
||
| // Assert | ||
| File.ReadAllText(tempFile.Path).Should().Be("hello"); |
There was a problem hiding this comment.
Fixed in 2ae2487 — switched to await File.ReadAllTextAsync(tempFile.Path).
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/5361544c-ba41-4c23-89ea-d0da8aedc513 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
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*andExtractManifestResource*extension methods onAssembly. - 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.
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/23fb0196-9cbf-45e3-bb20-9242f781f68e Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/09955441-4d97-4041-b566-8365660c7d34 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…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>
…c(cancellationToken) Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/df4c76b7-6408-4110-b1ab-a043952f5807 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/1544d98f-bcd9-413b-8d10-e8c611e51498 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
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.
Ports two utility methods from
DotnetRuntimeBootstrapperinto PowerKit'sAssemblyExtensions, each with a sync and async variant.New methods
GetManifestResourceString(resourceName, encoding)— reads an embedded resource as a string using the specified encodingGetManifestResourceString(resourceName)— reads an embedded resource as a UTF-8 string (delegates to the encoding overload)GetManifestResourceStringAsync(resourceName, encoding, ct)— async variant with encodingGetManifestResourceStringAsync(resourceName, ct)— async UTF-8 variant (delegates to the encoding overload)ExtractManifestResource(resourceName, filePath)— copies an embedded resource to a fileExtractManifestResourceAsync(resourceName, filePath, ct)— async variantAll methods throw
MissingManifestResourceExceptionwhen the resource name isn't found.