Bug 29691 - Compiler error for read-only auto-properties with certain names
Summary: Compiler error for read-only auto-properties with certain names
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
: 30419 ()
Depends on:
Reported: 2015-05-03 22:47 UTC by Philippe Leybaert
Modified: 2015-08-26 09:09 UTC (History)
4 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 Philippe Leybaert 2015-05-03 22:47:14 UTC
The following doesn't compile in Xamarin Studio 5.9 (Mono 4.0.0 C# compiler):

    public class MyClass
        Type Type { get; } // compiler error 1

        public MyClass()
            Type = typeof(string); // compiler error 2

Two compiler errors:

error 1: error CS0118: `System.Type' is a `type' but a `variable' was expected
error 2: error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer

The code compiles fine in VS2015RC

However, the following compiles fine in Xamarin Studio:

    public class MyClass
        Type Type { get; set; } // Adding a setter makes it work

        public MyClass()
            Type = typeof(string);

This also compiles fine:

    public class MyClass
        Type Type1 { get; } // changing the name to Type1 makes it work

        public MyClass()
            Type1 = typeof(string);
Comment 1 Marek Safar 2015-05-04 12:32:19 UTC
Fixed in master
Comment 2 Marek Safar 2015-05-26 05:47:08 UTC
*** Bug 30419 has been marked as a duplicate of this bug. ***
Comment 3 Jahmai 2015-08-26 01:42:49 UTC
What release will this fix be in?
Comment 4 Marek Safar 2015-08-26 08:58:45 UTC
The fix is available in Mono 4.2
Comment 5 Jahmai 2015-08-26 09:03:02 UTC
When will that be released? I checked Beta and Alpha channels and they are both 4.0.x.
Comment 6 Jahmai 2015-08-26 09:09:29 UTC
Sorry, I should be more specific. When will this fix (and the other C# 6 language feature bugs) be available in Xamarin.iOS and Xamarin.Android.