Bug 39574

Summary: Compilattion Error CS0842 thrown on Expression Body getter property with explicit StructLayout
Product: [Mono] Compilers Reporter: Widagdo Setiawan <widagdos>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: 4.0.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Tags: Is this bug a regression?: ---
Last known good build:

Description Widagdo Setiawan 2016-03-14 00:21:31 UTC
- Compiles under Visual Studio 2015 update 1
- But failed on mono 4.3.2.467/ba2e5e4
  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
    {
        [FieldOffset(0)]
        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