This project is read-only.

Struct with events emit bug


When compiling empty struct like this:
struct S { }
C# compiler normally emits explicit [StructLayout] annotation with struct size of 1 byte:
[StructLayout(LayoutKind.Sequential, Size = 1)]
struct S { }
Looks like in Roslyn, check for struct 'emptiness' ignores field-like event declarations, because emitted code for struct like this:
struct S {
    event System.Action E1;
    event System.Action E2;
    event System.Action E3;
Also has this size annotation of 1 byte:
[StructLayout(LayoutKind.Sequential, Size = 1)]
internal struct S
    [CompilerGenerated] private event Action E1;
    [CompilerGenerated] private event Action E2;
    [CompilerGenerated] private event Action E3;
Looks clearly like a bug.


pgavlin wrote Jan 14, 2015 at 8:23 PM

This was fixed with commit 59d1b58.