Bug 33600

Summary: Auto properties broken in Mono 4.2.0
Product: [Mono] Compilers Reporter: Rodrigo Moya <rodrigo.moya>
Component: C#Assignee: Marek Safar <masafa>
Severity: critical CC: abhishekk, masafa, miguel, mono-bugs+mono, mono-bugs+runtime, pj.beaman
Priority: High    
Version: unspecified   
Target Milestone: 4.2.0 (C6)   
Hardware: PC   
OS: Mac OS   
Tags: 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 [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.