Bug 39574 - Compilattion Error CS0842 thrown on Expression Body getter property with explicit StructLayout
Summary: Compilattion Error CS0842 thrown on Expression Body getter property with expl...
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 4.0.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2016-03-14 00:21 UTC by Widagdo Setiawan
Modified: 2016-03-14 12:41 UTC (History)
1 user (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 Widagdo Setiawan 2016-03-14 00:21:31 UTC
- Compiles under Visual Studio 2015 update 1
- But failed on mono
  error CS0842: Automatically implemented property `Cs0842ExpressionBodyGetterBug.MyGetter' cannot be used inside a type with an explicit StructLayout attribute

-Sample code
    [StructLayout(LayoutKind.Explicit, Size = 8)]
    public struct Cs0842ExpressionBodyGetterBug
        public int DummyVariable;

        public int MyGetter => 5;

I think MyGetter should not be implemented as Automatically implemented property. Instead, it should be implemented as a normal getter with body "return 5;"
Comment 1 Marek Safar 2016-03-14 12:41:06 UTC
Fixed in master and Mono 4.4