AutoComparer 1.0.0
dotnet add package AutoComparer --version 1.0.0
NuGet\Install-Package AutoComparer -Version 1.0.0
<PackageReference Include="AutoComparer" Version="1.0.0" />
paket add AutoComparer --version 1.0.0
#r "nuget: AutoComparer, 1.0.0"
// Install AutoComparer as a Cake Addin #addin nuget:?package=AutoComparer&version=1.0.0 // Install AutoComparer as a Cake Tool #tool nuget:?package=AutoComparer&version=1.0.0
AutoComparer
This library aims to provide a simple extension method which compares properties across objects without having to define a custom hashcode override.
The library will map those properties with a matching name and type and compare their values to see if they are equal.
The main advantage and reason why this was built is not having to update the hashcode override function when a new field is changed
Usage
In its simplest form
using AutoComparer;
bool equal = obj1.ValueEquals(obj2);
FAQ
Let's cover some corner cases...
Q: what if there is no overlap of any field of the two objects?
A: false
, at least 1 property should match
Q: property name matches in the other object, but the type is different, what happens?
A: It will be a false
, as the mapping will be valid, but types are incompatible. No implicit conversion is made.
Q: In case of nested objects, what happens to the nested object? Will it use the default Equals
method?
A: There is an optional parameter that you can set called recursivelyCheckInnerObjects
. By default it does, but if the parameter is set to true
it will instead recursively call ValueEquals
for all properties which are Classes (structures are treated with Equals
).
Q: Mapping nullables and non-nullables? A: Implicitly handled
Roadmap
More features could be added, like
- custom type transformers
- custom value transformers
- custom name overrides (for matching properties even if the name is different)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 263 | 1/1/2024 |
Initial Release