This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 33600 - Auto properties broken in Mono 4.2.0
Summary: Auto properties broken in Mono 4.2.0
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: High critical
Target Milestone: 4.2.0 (C6)
Assignee: Marek Safar
Depends on:
Reported: 2015-09-03 07:52 UTC by Rodrigo Moya
Modified: 2015-10-06 09:30 UTC (History)
6 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Rodrigo Moya 2015-09-03 07:52:34 UTC
After upgrading to latest packages in alpha channel (4.2.0 (explicit/2701b19)), I started seeing NRE crashes on a property that was being set in a constructor. After some debugging and trying, I can easily replicate it with this:

using System;

namespace BrokenOverrideProperty
	abstract class BaseClass
		protected BaseClass (string text)
			Whatever = text;

		public virtual string Whatever { get; set; }

	class DerivedClass : BaseClass
		public DerivedClass (string text) : base (text)

		public override string Whatever {
			get {
				return "DerivedClass";
			set {
				Console.WriteLine ("DerivedClass setter called with value " + value);

	class MainClass
		public static void Main (string[] args)
			Console.WriteLine ("Hello World!");

			var klass = new DerivedClass ("yeehah");
			Console.WriteLine ("class has value set to " + klass.Whatever);

The DerivedClass' Whatever setter is never called when running this app on mono 4.2.0, but works perfectly on mono 4.0.0 (beta channel). Replacing the auto property in the base class with a backing field, works great on both mono versions.
Comment 1 Marek Safar 2015-09-03 11:38:18 UTC
Fixed in master and Mono 4.2 branch
Comment 2 Miguel de Icaza 2015-09-03 12:52:44 UTC
This is on master: 8692db1abd7ead127bad801805cc9646ef583c0e
This is on mono-4.2.0-branch: 5382fc7b11442952cf2595cdc508843dd6b1d9a7

There is an automated test now to cover this
Comment 3 Abhishek 2015-10-06 09:30:43 UTC
I have checked this issue with the latest C6 build.
MonoFramework-MDK- Now this issue is working fine. Here is the screencast for the same:

Hence closing this issue.


Note You need to log in before you can comment on or make changes to this bug.