-
Notifications
You must be signed in to change notification settings - Fork 267
feat: Add FileVersionInfo support #1177
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
Merged
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
8f3a2e6
Added FileVersionInfo support
6e407cd
- Implemented IFileVersionInfoFactory and moved the FileVersionInfo q…
4c569eb
Update tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/M…
t4m45 f4c4404
Update src/TestableIO.System.IO.Abstractions/IFileSystem.cs
t4m45 d68c667
Update tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/M…
8178f70
Typo fix
f240e1b
Changed the optional parameter handling of MockFileVersionInfo
7cfdca7
Fixed codacy errors "Use the overloading mechanism instead of the opt…
dd68ff2
Removed the static declarations from the FileVersionInfo factories.
2e6fa66
Implemented ProductVersionParser to mimick the behavior of the Assemb…
a8380f4
Bump version to 21.2
6628888
Removed the constructor overloads of MockFileVersionInfo and set the …
t4m45 5d8e168
fix for Codacy error: "Consider refactoring this method in order to r…
t4m45 eb509ac
Added an overload for the constructor of MockFileVersionInfo
t4m45 1f246a3
Revert "Added an overload for the constructor of MockFileVersionInfo"
t4m45 da9061e
Added FileVersionInfo support
c331fb6
- Implemented IFileVersionInfoFactory and moved the FileVersionInfo q…
b2a4ca9
Update tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/M…
t4m45 41b3d88
Update src/TestableIO.System.IO.Abstractions/IFileSystem.cs
t4m45 73b4285
Update tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/M…
4d5efbd
Typo fix
dfe0449
Changed the optional parameter handling of MockFileVersionInfo
dc49485
Fixed codacy errors "Use the overloading mechanism instead of the opt…
9feeb4e
Removed the static declarations from the FileVersionInfo factories.
c1e5520
Implemented ProductVersionParser to mimick the behavior of the Assemb…
0d92dbe
Bump version to 21.2
0e11ee4
Removed the constructor overloads of MockFileVersionInfo and set the …
t4m45 4282915
fix for Codacy error: "Consider refactoring this method in order to r…
t4m45 d661eb3
Added an overload for the constructor of MockFileVersionInfo
t4m45 6095538
Revert "Added an overload for the constructor of MockFileVersionInfo"
t4m45 4c06da3
Merge branch 'main' of https://github.com/t4m45/System.IO.Abstractions
t4m45 23bdeb4
Modified the accessibility modifier of ProductVersionParser to intern…
t4m45 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
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
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
176 changes: 176 additions & 0 deletions
176
src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileVersionInfo.cs
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,176 @@ | ||
| using System.Diagnostics; | ||
| using System.Runtime.InteropServices; | ||
| using System.Text; | ||
|
|
||
| namespace System.IO.Abstractions.TestingHelpers | ||
| { | ||
| /// <inheritdoc /> | ||
| #if FEATURE_SERIALIZABLE | ||
| [Serializable] | ||
| #endif | ||
| public class MockFileVersionInfo : FileVersionInfoBase | ||
| { | ||
| /// <inheritdoc /> | ||
| public MockFileVersionInfo( | ||
t4m45 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| [Optional] string comments, | ||
t4m45 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| [Optional] string companyName, | ||
| [Optional] int fileBuildPart, | ||
| [Optional] string fileDescription, | ||
| [Optional] int fileMajorPart, | ||
| [Optional] int fileMinorPart, | ||
| [Optional] string fileName, | ||
| [Optional] int filePrivatePart, | ||
| [Optional] string fileVersion, | ||
t4m45 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| [Optional] string internalName, | ||
| [Optional] bool isDebug, | ||
| [Optional] bool isPatched, | ||
| [Optional] bool isPrivateBuild, | ||
| [Optional] bool isPreRelease, | ||
| [Optional] bool isSpecialBuild, | ||
| [Optional] string language, | ||
| [Optional] string legalCopyright, | ||
| [Optional] string legalTrademarks, | ||
| [Optional] string originalFilename, | ||
| [Optional] string privateBuild, | ||
| [Optional] int productBuildPart, | ||
| [Optional] int productMajorPart, | ||
| [Optional] int productMinorPart, | ||
| [Optional] string productName, | ||
| [Optional] int productPrivatePart, | ||
| [Optional] string productVersion, | ||
| [Optional] string specialBuild) | ||
| { | ||
| Comments = comments; | ||
| CompanyName = companyName; | ||
| FileBuildPart = fileBuildPart; | ||
| FileDescription = fileDescription; | ||
| FileMajorPart = fileMajorPart; | ||
| FileMinorPart = fileMinorPart; | ||
| FileName = fileName; | ||
| FilePrivatePart = filePrivatePart; | ||
| FileVersion = fileVersion; | ||
| InternalName = internalName; | ||
| IsDebug = isDebug; | ||
| IsPatched = isPatched; | ||
| IsPrivateBuild = isPrivateBuild; | ||
| IsPreRelease = isPreRelease; | ||
| IsSpecialBuild = isSpecialBuild; | ||
| Language = language; | ||
| LegalCopyright = legalCopyright; | ||
| LegalTrademarks = legalTrademarks; | ||
| OriginalFilename = originalFilename; | ||
| PrivateBuild = privateBuild; | ||
| ProductBuildPart = productBuildPart; | ||
| ProductMajorPart = productMajorPart; | ||
| ProductMinorPart = productMinorPart; | ||
| ProductName = productName; | ||
| ProductPrivatePart = productPrivatePart; | ||
| ProductVersion = productVersion; | ||
| SpecialBuild = specialBuild; | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string Comments { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string CompanyName { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override int FileBuildPart { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string FileDescription { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override int FileMajorPart { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override int FileMinorPart { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string FileName { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override int FilePrivatePart { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string FileVersion { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string InternalName { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override bool IsDebug { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override bool IsPatched { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override bool IsPrivateBuild { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override bool IsPreRelease { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override bool IsSpecialBuild { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string Language { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string LegalCopyright { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string LegalTrademarks { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string OriginalFilename { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string PrivateBuild { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override int ProductBuildPart { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override int ProductMajorPart { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override int ProductMinorPart { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string ProductName { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override int ProductPrivatePart { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string ProductVersion { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string SpecialBuild { get; } | ||
|
|
||
| /// <inheritdoc cref="FileVersionInfo.ToString" /> | ||
| public override string ToString() | ||
| { | ||
| // An initial capacity of 512 was chosen because it is large enough to cover | ||
| // the size of the static strings with enough capacity left over to cover | ||
| // average length property values. | ||
| var sb = new StringBuilder(512); | ||
| sb.Append("File: ").AppendLine(FileName); | ||
| sb.Append("InternalName: ").AppendLine(InternalName); | ||
| sb.Append("OriginalFilename: ").AppendLine(OriginalFilename); | ||
| sb.Append("FileVersion: ").AppendLine(FileVersion); | ||
| sb.Append("FileDescription: ").AppendLine(FileDescription); | ||
| sb.Append("Product: ").AppendLine(ProductName); | ||
| sb.Append("ProductVersion: ").AppendLine(ProductVersion); | ||
| sb.Append("Debug: ").AppendLine(IsDebug.ToString()); | ||
| sb.Append("Patched: ").AppendLine(IsPatched.ToString()); | ||
| sb.Append("PreRelease: ").AppendLine(IsPreRelease.ToString()); | ||
| sb.Append("PrivateBuild: ").AppendLine(IsPrivateBuild.ToString()); | ||
| sb.Append("SpecialBuild: ").AppendLine(IsSpecialBuild.ToString()); | ||
| sb.Append("Language: ").AppendLine(Language); | ||
| return sb.ToString(); | ||
| } | ||
| } | ||
| } | ||
44 changes: 44 additions & 0 deletions
44
src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileVersionInfoFactory.cs
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,44 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace System.IO.Abstractions.TestingHelpers | ||
| { | ||
| /// <inheritdoc /> | ||
| #if FEATURE_SERIALIZABLE | ||
| [Serializable] | ||
| #endif | ||
| public class MockFileVersionInfoFactory : IFileVersionInfoFactory | ||
| { | ||
| private static IMockFileDataAccessor mockFileSystem; | ||
|
|
||
| /// <inheritdoc /> | ||
| public MockFileVersionInfoFactory(IMockFileDataAccessor mockFileSystem) | ||
| { | ||
| MockFileVersionInfoFactory.mockFileSystem = mockFileSystem ?? throw new ArgumentNullException(nameof(mockFileSystem)); | ||
|
Check warning on line 20 in src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileVersionInfoFactory.cs
|
||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public IFileSystem FileSystem => mockFileSystem; | ||
|
|
||
| IFileVersionInfo IFileVersionInfoFactory.GetVersionInfo(string fileName) | ||
| { | ||
| return GetVersionInfo(fileName); | ||
| } | ||
|
|
||
| /// <inheritdoc cref="Diagnostics.FileVersionInfo.GetVersionInfo(string)" /> | ||
| public static IFileVersionInfo GetVersionInfo(string fileName) | ||
| { | ||
| MockFileData mockFileData = mockFileSystem.GetFile(fileName); | ||
|
|
||
| if (mockFileData != null) | ||
| { | ||
| return mockFileData.FileVersionInfo; | ||
| } | ||
|
|
||
| throw CommonExceptions.FileNotFound(fileName); | ||
| } | ||
| } | ||
| } | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.