What does Realm.Fody do?

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • Realm Xamarin

    Realm is a mobile database: a replacement for SQLite & ORMs

  • For the developers in the audience that never heard of it, Realm is an (amazing) offline-first (mostly) mobile object database with some really nice features. This article is not an introduction to Realm though, nevertheless I expect it should be easy to follow along even if you've never used it before. If you're curious and want to learn more about it, the official documentation is a good place to start. Besides, Realm open source, so you can check the source code for the .NET SDK on Github.

  • JustDecompile Engine

    The decompilation engine of JustDecompile

  • As you can see IL code is not exactly human readable, and it's also quite verbose. If you want to have an idea of how your code looks like in IL you can use a decompiler tool such as JustDecompile or ILSpy.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • ILSpy

    .NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!

  • As you can see IL code is not exactly human readable, and it's also quite verbose. If you want to have an idea of how your code looks like in IL you can use a decompiler tool such as JustDecompile or ILSpy.

  • Fody

    Extensible tool for weaving .net assemblies

  • Working with IL weaving as part of the building process is quite complex though, and this is where Fody enters into the picture. Fody is an extensible tool that allows to simplify the weaving process by taking care of all the heavy lifting.

  • PropertyChanged

    Injects INotifyPropertyChanged code into properties at compile time

  • All the weaving libraries (also called weavers or addin) using Fody need to have the .Fody suffix, so it's quite easy to recognize them. As an example, if you ever had to implement INotifyPropertyChanged manually in a class with dozens of properties you would probably welcome weaving (and Fody) with open arms. By creating all the plumbing code directly in IL, libraries like PropertyChanged.Fody allows to inject the necessary notification code without the need to modify anything in the original source code.

  • ModuleInit

    Adds a module initializer to an assembly.

  • Module initializers are a kinda obscure feature of .NET that allows writing initialization code for an assembly. They allow libraries to do one-time initialization when loaded, without the need for the user to explicitly call anything. It's a quite niche feature, but unfortunately it was not exposed in C#, and that led to users finding their own way of using it, like with ModuleInit.Fody. Given the need for it, Microsoft then decided to add it in supported platform starting from C# 9.0.

  • csharplang

    The official repo for the design of the C# programming language

  • Unfortunately, source generators can only add code to the compilation, but not modify it, and thus they cannot provide the same functionality that weaving does. For instance, it's not possible to modify setters and getters of properties (at least until C# won't allow partial properties...). This limitation means that it is not possible to simply convert weaving libraries to source generators, and a more nuanced solution is needed.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts