mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-02-06 13:47:36 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb725bff19 | ||
|
|
2384cf9f9f | ||
|
|
1261930fd9 |
5
.github/workflows/build_and_test.yml
vendored
5
.github/workflows/build_and_test.yml
vendored
@@ -16,7 +16,10 @@ jobs:
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 9.0.x
|
||||
dotnet-version: |
|
||||
6.0.x
|
||||
8.0.x
|
||||
9.0.x
|
||||
|
||||
- name: Run tests
|
||||
run: dotnet test
|
||||
|
||||
5
.github/workflows/check_pr.yml
vendored
5
.github/workflows/check_pr.yml
vendored
@@ -11,7 +11,10 @@ jobs:
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 9.0.x
|
||||
dotnet-version: |
|
||||
6.0.x
|
||||
8.0.x
|
||||
9.0.x
|
||||
|
||||
- name: Build
|
||||
run: dotnet build
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Version>1.8.4</Version>
|
||||
<Version>1.8.5</Version>
|
||||
|
||||
<!-- Package Properties -->
|
||||
<Authors>Matt Nadareski</Authors>
|
||||
|
||||
@@ -850,47 +850,50 @@ namespace SabreTools.Serialization.Wrappers
|
||||
if (string.IsNullOrEmpty(key))
|
||||
return null;
|
||||
|
||||
// If we have the value cached
|
||||
if (_versionInfoStrings.ContainsKey(key))
|
||||
return _versionInfoStrings[key];
|
||||
|
||||
// Ensure that we have the resource data cached
|
||||
if (ResourceData == null)
|
||||
return null;
|
||||
|
||||
// If we don't have string version info in this executable
|
||||
var stringTable = _versionInfo?.StringFileInfo?.Children;
|
||||
if (stringTable == null || stringTable.Length == 0)
|
||||
return null;
|
||||
|
||||
// Try to find a key that matches
|
||||
#if NET20
|
||||
Models.PortableExecutable.StringData? match = null;
|
||||
foreach (var st in stringTable)
|
||||
lock (_sourceDataLock)
|
||||
{
|
||||
if (st?.Children == null)
|
||||
continue;
|
||||
|
||||
// Return the match if found
|
||||
match = Array.Find(st.Children, sd => sd != null && key.Equals(sd.Key, StringComparison.OrdinalIgnoreCase));
|
||||
if (match != null)
|
||||
{
|
||||
_versionInfoStrings[key] = match.Value?.TrimEnd('\0');
|
||||
// If we have the value cached
|
||||
if (_versionInfoStrings.ContainsKey(key))
|
||||
return _versionInfoStrings[key];
|
||||
|
||||
// Ensure that we have the resource data cached
|
||||
if (ResourceData == null)
|
||||
return null;
|
||||
|
||||
// If we don't have string version info in this executable
|
||||
var stringTable = _versionInfo?.StringFileInfo?.Children;
|
||||
if (stringTable == null || stringTable.Length == 0)
|
||||
return null;
|
||||
|
||||
// Try to find a key that matches
|
||||
#if NET20
|
||||
Models.PortableExecutable.StringData? match = null;
|
||||
foreach (var st in stringTable)
|
||||
{
|
||||
if (st?.Children == null)
|
||||
continue;
|
||||
|
||||
// Return the match if found
|
||||
match = Array.Find(st.Children, sd => sd != null && key.Equals(sd.Key, StringComparison.OrdinalIgnoreCase));
|
||||
if (match != null)
|
||||
{
|
||||
_versionInfoStrings[key] = match.Value?.TrimEnd('\0');
|
||||
return _versionInfoStrings[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_versionInfoStrings[key] = null;
|
||||
return _versionInfoStrings[key];
|
||||
_versionInfoStrings[key] = null;
|
||||
return _versionInfoStrings[key];
|
||||
#else
|
||||
var match = stringTable
|
||||
.SelectMany(st => st?.Children ?? [])
|
||||
.FirstOrDefault(sd => sd != null && key.Equals(sd.Key, StringComparison.OrdinalIgnoreCase));
|
||||
var match = stringTable
|
||||
.SelectMany(st => st?.Children ?? [])
|
||||
.FirstOrDefault(sd => sd != null && key.Equals(sd.Key, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
// Return either the match or null
|
||||
_versionInfoStrings[key] = match?.Value?.TrimEnd('\0');
|
||||
return _versionInfoStrings[key];
|
||||
// Return either the match or null
|
||||
_versionInfoStrings[key] = match?.Value?.TrimEnd('\0');
|
||||
return _versionInfoStrings[key];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user