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

View File

@@ -154,12 +154,21 @@ namespace SabreTools.DatItems
} }
set 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)) if (value.HasFlag(MachineType.Bios))
_machine[Models.Metadata.Machine.IsBiosKey] = "yes"; _machine[Models.Metadata.Machine.IsBiosKey] = "yes";
if (value.HasFlag(MachineType.Device)) if (value.HasFlag(MachineType.Device))
_machine[Models.Metadata.Machine.IsDeviceKey] = "yes"; _machine[Models.Metadata.Machine.IsDeviceKey] = "yes";
if (value.HasFlag(MachineType.Mechanical)) if (value.HasFlag(MachineType.Mechanical))
_machine[Models.Metadata.Machine.IsMechanicalKey] = "yes"; _machine[Models.Metadata.Machine.IsMechanicalKey] = "yes";
#endif
} }
} }

View File

@@ -1,10 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <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> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <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> </PropertyGroup>
<ItemGroup> <ItemGroup>