RecordEnumerableEquality.Fody
0.0.7
dotnet add package RecordEnumerableEquality.Fody --version 0.0.7
NuGet\Install-Package RecordEnumerableEquality.Fody -Version 0.0.7
<PackageReference Include="RecordEnumerableEquality.Fody" Version="0.0.7" />
paket add RecordEnumerableEquality.Fody --version 0.0.7
#r "nuget: RecordEnumerableEquality.Fody, 0.0.7"
// Install RecordEnumerableEquality.Fody as a Cake Addin #addin nuget:?package=RecordEnumerableEquality.Fody&version=0.0.7 // Install RecordEnumerableEquality.Fody as a Cake Tool #tool nuget:?package=RecordEnumerableEquality.Fody&version=0.0.7
<img src="assets/logo.png" height="30px"> Record Enumerable Equality - Fody
Overview
RecordEnumerableEquality.Fody
is a Fody add-in that enables deep equality comparison for C# records containing properties implementing IEnumerable<T>
. This allows for comparison of records with collections in a straightforward and intuitive manner, ensuring that two records with the same collection elements are considered equal, even if the instances of the collections are different.
Installation
To install RecordEnumerableEquality.Fody
, you can use the NuGet package manager. Run the following command in the Package Manager Console:
Install-Package RecordEnumerableEquality.Fody
Or add the package to your project file:
<PackageReference Include="RecordEnumerableEquality.Fody" Version="0.0.6" />
Usage
To use RecordEnumerableEquality.Fody
, simply define your records with properties that implement IEnumerable<T>
, and the Fody add-in will handle the deep equality comparison and hashing for you.
Example
Here is an example demonstrating the functionality:
var mc = new MainClass()
{
Property1 = "Hello",
SubClasses = new List<SubClass>()
{
new ()
{
Property2 = "Hello",
Property3 = "World!"
},
new ()
{
Property2 = "Hello1",
Property3 = "World2!"
},
}
};
var mc1 = new MainClass()
{
Property1 = "Hello",
SubClasses = new List<SubClass>()
{
new ()
{
Property2 = "Hello",
Property3 = "World!"
},
new ()
{
Property2 = "Hello1",
Property3 = "World2!"
},
}
};
Console.WriteLine($"Equals: {mc.Equals(mc1)}");
var hashCode = mc.GetHashCode();
var hashCode1 = mc1.GetHashCode();
Console.WriteLine($"HashCode1: {hashCode}");
Console.WriteLine($"HashCode2: {hashCode1}");
Console.WriteLine($"HashCode Equals: {hashCode == hashCode1}");
public record MainClass
{
public string Property1 { get; set; }
public List<SubClass> SubClasses { get; set; } = new List<SubClass>();
}
public record SubClass
{
public string Property2 { get; set; }
public string Property3 { get; set; }
}
Output
Equals: True
HashCode1: 12345678
HashCode2: 12345678
HashCode Equals: True
Without the Add-in, the output would be not equal and the hash codes would be different.
Contributing
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.
- Fork the repository.
- Create a new feature branch.
- Commit your changes.
- Push the branch.
- Open a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Acknowledgements
Special thanks to the Fody community for their support and contributions.
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 is compatible. 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. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.