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)

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 [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.
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!

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.


Create a new report for Bug 33600 on Developer Community or GitHub if you have new information to add and do not yet see a matching report.

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments


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.

Related Links: