-
Notifications
You must be signed in to change notification settings - Fork 1
Add manifest resource extensions to AssemblyExtensions #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Tyrrrz
merged 10 commits into
prime
from
copilot/add-assembly-extensions-and-async-version
Apr 12, 2026
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
abc6240
Initial plan
Copilot 029e18b
Add ExtractManifestResource, ExtractManifestResourceAsync, GetManifes…
Copilot 2ae2487
Use File.ReadAllTextAsync in ExtractManifestResourceAsync_Test
Copilot a301923
Remove unnecessary blank lines in AssemblyExtensions.cs
Tyrrrz 72912fc
Move TestResource.txt to TestData folder
Copilot 24d4512
Replace await using with using var for netstandard2.0 compatibility
Copilot c35b3ab
Add encoding overloads for GetManifestResourceString and GetManifestR…
Copilot 03a28b1
Update AssemblyExtensions.cs
Tyrrrz 48fd465
Revert ThrowIfCancellationRequested workaround, restore ReadToEndAsyn…
Copilot dd28579
Use async/await in GetManifestResourceStringAsync UTF-8 overload
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,74 @@ | ||
| using System.IO; | ||
| using System.Reflection; | ||
| using System.Threading.Tasks; | ||
| using FluentAssertions; | ||
| using PowerKit; | ||
| using PowerKit.Extensions; | ||
| using Xunit; | ||
|
|
||
| namespace PowerKit.Tests; | ||
|
|
||
| public class AssemblyExtensionsTests | ||
| { | ||
| private static readonly Assembly ThisAssembly = typeof(AssemblyExtensionsTests).Assembly; | ||
|
|
||
| // The embedded resource name follows the default MSBuild convention: | ||
| // <RootNamespace>.<RelativePath> with path separators replaced by dots. | ||
| private const string ResourceName = "PowerKit.Tests.TestResource.txt"; | ||
|
|
||
| [Fact] | ||
| public void TryGetVersionString_Test() | ||
| { | ||
| // Act | ||
| var version = ThisAssembly.TryGetVersionString(); | ||
|
|
||
| // Assert | ||
| version.Should().NotBeNullOrWhiteSpace(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void GetManifestResourceString_Test() | ||
| { | ||
| // Act | ||
| var content = ThisAssembly.GetManifestResourceString(ResourceName); | ||
|
|
||
| // Assert | ||
| content.Should().Be("hello"); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task GetManifestResourceStringAsync_Test() | ||
| { | ||
| // Act | ||
| var content = await ThisAssembly.GetManifestResourceStringAsync(ResourceName); | ||
|
|
||
| // Assert | ||
| content.Should().Be("hello"); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ExtractManifestResource_Test() | ||
| { | ||
| // Arrange | ||
| var assembly = typeof(AssemblyExtensionsTests).Assembly; | ||
| using var tempFile = TempFile.Create(); | ||
|
|
||
| // Act | ||
| var version = assembly.TryGetVersionString(); | ||
| ThisAssembly.ExtractManifestResource(ResourceName, tempFile.Path); | ||
|
|
||
| // Assert | ||
| version.Should().NotBeNullOrWhiteSpace(); | ||
| File.ReadAllText(tempFile.Path).Should().Be("hello"); | ||
| } | ||
|
Tyrrrz marked this conversation as resolved.
|
||
|
|
||
| [Fact] | ||
| public async Task ExtractManifestResourceAsync_Test() | ||
| { | ||
| // Arrange | ||
| using var tempFile = TempFile.Create(); | ||
|
|
||
| // Act | ||
| await ThisAssembly.ExtractManifestResourceAsync(ResourceName, tempFile.Path); | ||
|
|
||
| // Assert | ||
| File.ReadAllText(tempFile.Path).Should().Be("hello"); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. async variant here @copilot
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 2ae2487 — switched to |
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| hello |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.