Shared libraries
ObjectKit
Source-generated structural copy and equality
A source generator that emits Copy and equality for a partial class marked [Copyable]. There is no reflection fallback. Version 0.1.1 is in source and is not on nuget.org yet.
Install
dotnet add package NuvyntraLabs.NET.ObjectKitPackage ID: NuvyntraLabs.NET.ObjectKit
NuvyntraLabs.NET.* is a class library, not a Plugin.Maui.* package. The install command applies after 0.1.1 is published. Until then, reference the project in the hub submodule.
Example
[Copyable]
public partial class Person
{
public string Name { get; set; } = "";
public int Age { get; set; }
}
Person copy = person.Copy();
bool same = person.Equals(copy);Overview
NuvyntraLabs.NET.ObjectKit copies and compares a marked class without reflection. Prefer Mapperly for object-to-object mapping. The type must be a non-generic, non-nested, concrete partial class with a public parameterless constructor. Copied members are public properties with a public getter and a public set or init accessor. Supported types are string, enums, value types, and Nullable<T>. If the generator cannot copy the type, the build fails.
Capabilities
- Inherited properties are copied. Static properties and indexers are skipped. A keyword property name is emitted with @.
- OBK001–OBK006 reject a non-class, a non-partial, abstract or static, generic, nested, or constructor-less type.
- OBK007–OBK009 reject a property with no public getter, no public set or init, or a type that is not a string, enum, or value type.
- The generator ships inside the package. Nullable, trim, and Native AOT compatible.
- .NET
- Source generator
- Equality
Discussion
Comment on NuvyntraLabs.NET.ObjectKit. The thread lives on this component's GitHub repository. Sign in with GitHub — Giscus uses Discussions, Utterances uses Issues.
Issues are not enabled on this repository
Open the conversation on GitHub, or use the Giscus tab if Discussions are available.