This project is read-only.
2
Vote

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

description

See legacy compiler bug here: https://connect.microsoft.com/VisualStudio/feedback/details/840765/compiler-generates-cil-that-is-not-to-specification

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

comments

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: http://stuff.mit.edu/afs/athena/software/mono_v3.0/arch/amd64_ubuntu1204/mono/external/ikvm/reflect/CustomAttributeData.cs, 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.