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# ()
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)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

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 [MSFT] 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.