{"id":23256031,"url":"https://github.com/loresoft/Equatable.Generator","last_synced_at":"2025-08-20T13:32:33.026Z","repository":{"id":255481976,"uuid":"849599695","full_name":"loresoft/Equatable.Generator","owner":"loresoft","description":"Source generator for Equals and GetHashCode with attribute based control of equality implementation","archived":false,"fork":false,"pushed_at":"2024-12-17T08:21:49.000Z","size":162,"stargazers_count":22,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-18T19:09:52.289Z","etag":null,"topics":["equals","equatable","gethashcode","source-generator"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loresoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"loresoft"}},"created_at":"2024-08-29T22:21:55.000Z","updated_at":"2024-12-17T08:21:46.000Z","dependencies_parsed_at":"2024-09-05T17:53:43.712Z","dependency_job_id":"b62171f1-5eb8-4a1c-abeb-16be9161c786","html_url":"https://github.com/loresoft/Equatable.Generator","commit_stats":null,"previous_names":["loresoft/equatable.generator"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loresoft%2FEquatable.Generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loresoft%2FEquatable.Generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loresoft%2FEquatable.Generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loresoft%2FEquatable.Generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loresoft","download_url":"https://codeload.github.com/loresoft/Equatable.Generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230326801,"owners_count":18209050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["equals","equatable","gethashcode","source-generator"],"created_at":"2024-12-19T12:00:34.533Z","updated_at":"2025-08-20T13:32:33.020Z","avatar_url":"https://github.com/loresoft.png","language":"C#","readme":"# Equatable.Generator\n\nSource generator for `Equals` and `GetHashCode` with attribute based control of equality implementation\n\n[![Build Project](https://github.com/loresoft/Equatable.Generator/actions/workflows/dotnet.yml/badge.svg)](https://github.com/loresoft/Equatable.Generator/actions/workflows/dotnet.yml)\n\n[![Coverage Status](https://coveralls.io/repos/github/loresoft/Equatable.Generator/badge.svg?branch=main)](https://coveralls.io/github/loresoft/Equatable.Generator?branch=main)\n\n[![Equatable.Generator](https://img.shields.io/nuget/v/Equatable.Generator.svg)](https://www.nuget.org/packages/Equatable.Generator/)\n\n## Features\n\n- Override `Equals` and `GetHashCode`\n- Implement `IEquatable\u003cT\u003e`\n- Support `class`, `record` and `struct` types\n- Support `EqualityComparer` per property via attribute\n- Attribute based control of equality implementation. \n- Attribute comparers supported: String, Sequence, Dictionary, HashSet, Reference, and Custom\n- No runtime dependencies.  Library is compile time dependence only.  \n\n### Usage\n\n#### Add package\n\nAdd the nuget package to your projects.\n\n`dotnet add package Equatable.Generator`\n\nPrevent including Equatable.Generator as a dependency\n\n```xml\n\u003cPackageReference Include=\"Equatable.Generator\" PrivateAssets=\"all\" /\u003e\n```\n\n### Requirements\n\nThis library requires:\n\n- Target framework .NET Standard 2.0 or greater\n- Project C# `LangVersion` 8.0 or higher\n\n### Equatable Attributes\n\nPlace `[Equatable]` attribute on a `class`, `record` or `struct`.  The source generator will create a partial with overrides for `Equals` and `GetHashCode` for all public properties.\n\n- `[Equatable]` Marks the class to generate overrides for `Equals` and `GetHashCode`\n\n The default comparer used in the implementation of `Equals` and `GetHashCode` is `EqualityComparer\u003cT\u003e.Default`.  Customize the comparer used with the following attributes.\n\n- `[IgnoreEquality]` Ignore property in `Equals` and `GetHashCode` implementations\n- `[StringEquality]` Use specified `StringComparer` when comparing strings\n- `[SequenceEquality]` Use `Enumerable.SequenceEqual` to determine whether enumerables are equal\n- `[DictionaryEquality]` Use to determine if dictionaries are equal\n- `[HashSetEquality]` Use `ISet\u003cT\u003e.SetEquals` to determine whether enumerables are equal\n- `[ReferenceEquality]` Use `Object.ReferenceEquals` to determines whether instances are the same instance\n- `[EqualityComparer]` Use the specified `EqualityComparer`\n\n### Example Usage\n\nExample of using the attributes to customize the source generation of `Equals` and `GetHashCode`\n\n``` c#\n[Equatable]\npublic partial class UserImport\n{\n    [StringEquality(StringComparison.OrdinalIgnoreCase)]\n    public string EmailAddress { get; set; } = null!;\n\n    public string? DisplayName { get; set; }\n\n    public string? FirstName { get; set; }\n\n    public string? LastName { get; set; }\n\n    public DateTimeOffset? LockoutEnd { get; set; }\n\n    public DateTimeOffset? LastLogin { get; set; }\n\n    [IgnoreEquality]\n    public string FullName =\u003e $\"{FirstName} {LastName}\";\n\n    [HashSetEquality]\n    public HashSet\u003cstring\u003e? Roles { get; set; }\n\n    [DictionaryEquality]\n    public Dictionary\u003cstring, int\u003e? Permissions { get; set; }\n\n    [SequenceEquality]\n    public List\u003cDateTimeOffset\u003e? History { get; set; }\n}\n```\n\nWorks for `record` types too\n\n```c#\n[Equatable]\npublic partial record StatusRecord(\n    int Id,\n    [property: StringEquality(StringComparison.OrdinalIgnoreCase)] string Name,\n    string? Description,\n    int DisplayOrder,\n    bool IsActive,\n    [property: SequenceEquality] List\u003cstring\u003e Versions\n);\n```\n","funding_links":["https://github.com/sponsors/loresoft"],"categories":["Content"],"sub_categories":["177. [Equatable.Generator](https://ignatandrei.github.io/RSCG_Examples/v2/docs/Equatable.Generator) , in the [Equals](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#equals) category"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floresoft%2FEquatable.Generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floresoft%2FEquatable.Generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floresoft%2FEquatable.Generator/lists"}