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
Status: VERIFIED FIXED
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
URL:
Depends on:
Blocks:
 
Reported: 2015-09-03 07:52 UTC by Rodrigo Moya
Modified: 2015-10-06 09:30 UTC (History)
6 users (show)

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


Attachments

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.
XamarinStudio-5.10.0.812_feb7640e9c013af8bb30a6a72e5c3d2ebcefdcbd
MonoFramework-MDK-4.2.1.62.macos10.xamarin.x86_cc1cf601d6439b454efb38a0e28f607b54868abd. Now this issue is working fine. Here is the screencast for the same:
http://www.screencast.com/t/ZXA6Bham0Gd

Hence closing this issue.

Thanks!

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