Cleaning up MVVMCross ViewModels with Fody

Live property updates are printed to the console using the default MvvmCross property notifications.

Setup

PropertyChanged.Fody package can be found and added using the default NuGet manager in Rider IDE.
PropertyChanged weaver should be set in the Fody config to work correctly.

Basic Usage

Advanced Usage

Ignoring Unneeded Properties

[DoNotNotify]
public string Email { get; set; }
No PropertyChanged events raised for ignored Email property.

Property Interception

public string Email { get; set; }

// ReSharper disable once UnusedMember.Local
private void OnEmailChanged()
{
Debug.WriteLine($"New email is: {Email}");
}

Ignoring Unneeded Methods

Connectivity event subscription conflicts with Fody.PropertyChanged methods signature.
Method conflicts end up with build-time warnings.
[SuppressPropertyChangedWarnings]
private void OnConnectivityChanged(
object sender,
ConnectivityChangedEventArgs e
)
{
Debug.WriteLine($"Is Connected: {e.IsConnected}");
}

Xamarin | iOS | Android Developer with 7 years of experience. All things actionable tips, real-life examples and coding guides to help you grow professionally.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store