Getting or setting object properties or fields is an essential feature in any object-oriented programming language, although the implementation and usage can vary. In the case of C#, is there a way to manipulate objects similar to how dictionaries are manipulated? The answer is yes, and there are several options available, such as FastMember, Leo, Newbee ObjectVisitor, or Cosmos ObjectVisitors.
Here is a brief comparison of these four projects:
- FastMember is based on IL and does not support .NET Core / .NET Next.
- Leo is developed based on NCC Natasha and does not support value types, dynamic types, collections, arrays, dictionaries, etc.
- Newbee ObjectVisitor is implemented based on expression trees but the project has been archived.
- Cosmos ObjectVisitor supports value types, dynamic types, partially supports collections, arrays, dictionaries, but it only supports .NET 6+ projects and depends on cosmos-stack.
- Additionally, the L, N, and C projects all have highly complete features such as Repeat and Validate, and it seems that providing implementations as extension packages would be better.
With careful consideration of the comparison results from the aforementioned four projects and taking into account the functional architecture requirements of Project Hana, a new project named "Project Magic Wand" has emerged.
![image](https://private-user-images.githubusercontent.com/980129/273236161-a56720d0-a142-43e2-842b-cafd6b909cb0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTc4NjUzMzQsIm5iZiI6MTcxNzg2NTAzNCwicGF0aCI6Ii85ODAxMjkvMjczMjM2MTYxLWE1NjcyMGQwLWExNDItNDNlMi04NDJiLWNhZmQ2YjkwOWNiMC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjA4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYwOFQxNjQzNTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zZDI4MDQwYjRiNjA1MDUxY2RiYTFhOTEzZDQyZmEwYTJmYjc2NzUxYzdlZjYxMTc0N2RlNDg4MWQ4ZmE0OGVmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.1pn51y0SEETAfyan3adReJU3Srs1-1XyUjM9Qeo73cI)
Project Magic Wand should offer the following capabilities:
- It should be backward compatible with .NET Framework 4.6.1 and support NFX/Core/Next,
- It should support various types, including value types (primitive types and structs), reference types, dynamic types, collections, arrays, and dictionaries,
- It should enable reading and writing of public/private instance members and static members (properties or fields), as well as reading of read-only members (properties or fields),
- It should support accessing "nested members" and "members of a collection", and
- Non-core functionalities like Repeat and Validate should be excluded from the project and left to the community ecosystem for implementation through extension packages.
The aforementioned goals will be progressively implemented and optimized through multiple iterations. We will closely follow and refine the project based on the standards proposed by Cosmos CEP and the requirements and goals expressed by the user group.