This project is read-only.

PEWriter should generate CIL to ECMA-355 specification when serializing PermissionSet blob.


See legacy compiler bug here:

ECMA-355 specification says that the PermissionSet blob attribute array should contain a 16-bit int after the fully-qualified type name. Roslyn instead puts a count of the (NumNamed + NamedArg) bytes followed by a compressed integer for the number of named arguments.

Attached is a patch including a failing unit test and a patch that fixes this bug.

file attachments


Micah071381 wrote Apr 12, 2014 at 9:46 AM

Currently, the CLR behaves as desired when provided with this malformed blob. Mono also handles it as the CLR does, rather than to specification (see:, search for LAMESPEC).

I am uncertain whether or not CIL is versioned and if not, whether the CLR would be able to detect whether it is looking at valid CIL or invalid CIL. Since backwards compatibility is a concern, it may be unrealistic to fix this bug. In such an event, I suggest (probably the wrong place) that an effort is made to alter ECMA-355 to reflect what implementations actually do rather than have a specification that is incompatible with every major implementation of it.