Support ancient .NET in DatItems

This commit is contained in:
Matt Nadareski
2024-02-28 22:07:00 -05:00
parent de59d0252c
commit e7c45c1f50
3 changed files with 33 additions and 3 deletions

View File

@@ -345,7 +345,11 @@ namespace SabreTools.DatItems
return output;
// If the duplicate is external already or should be, set it
#if NETFRAMEWORK
if ((lastItem.DupeType & DupeType.External) != 0 || lastItem?.Source?.Index != Source?.Index)
#else
if (lastItem.DupeType.HasFlag(DupeType.External) || lastItem?.Source?.Index != Source?.Index)
#endif
{
if (lastItem?.Machine.Name == Machine?.Name && lastItem?.GetName() == GetName())
output = DupeType.External | DupeType.All;
@@ -392,9 +396,9 @@ namespace SabreTools.DatItems
key = (norename ? string.Empty
: Source?.Index.ToString().PadLeft(10, '0')
+ "-")
+ (string.IsNullOrWhiteSpace(Machine?.Name)
+ (string.IsNullOrEmpty(Machine?.Name)
? "Default"
: Machine.Name);
: Machine!.Name!);
if (lower)
key = key.ToLowerInvariant();
@@ -593,7 +597,11 @@ namespace SabreTools.DatItems
string datItemName = datItem.GetName() ?? datItem.ItemType.ToString();
// If the current item exactly matches the last item, then we don't add it
#if NETFRAMEWORK
if ((datItem.GetDuplicateStatus(lastItem) & DupeType.All) != 0)
#else
if (datItem.GetDuplicateStatus(lastItem).HasFlag(DupeType.All))
#endif
{
staticLogger.Verbose($"Exact duplicate found for '{datItemName}'");
continue;

View File

@@ -154,12 +154,21 @@ namespace SabreTools.DatItems
}
set
{
#if NETFRAMEWORK
if ((value & MachineType.Bios) != 0)
_machine[Models.Metadata.Machine.IsBiosKey] = "yes";
if ((value & MachineType.Device) != 0)
_machine[Models.Metadata.Machine.IsDeviceKey] = "yes";
if ((value & MachineType.Mechanical) != 0)
_machine[Models.Metadata.Machine.IsMechanicalKey] = "yes";
#else
if (value.HasFlag(MachineType.Bios))
_machine[Models.Metadata.Machine.IsBiosKey] = "yes";
if (value.HasFlag(MachineType.Device))
_machine[Models.Metadata.Machine.IsDeviceKey] = "yes";
if (value.HasFlag(MachineType.Mechanical))
_machine[Models.Metadata.Machine.IsMechanicalKey] = "yes";
#endif
}
}

View File

@@ -1,10 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<!-- Assembly Properties -->
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>1.1.2</Version>
<!-- Package Properties -->
<Authors>Matt Nadareski</Authors>
<Copyright>Copyright (c)2016-2024 Matt Nadareski</Copyright>
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
<RepositoryUrl>https://github.com/SabreTools/SabreTools</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
<ItemGroup>