This project is read-only.
2
Vote

Roslyn C# compiler doesn't recognize extension methods from most libraries written in C++/CLI and other CLI languages

description

The Roslyn C# compiler, unlike the legacy compiler, requires an assembly-level ExtensionAttribute in order for extension methods defined in that assembly to be considered. The legacy compiler only required method-level and class-level ExtensionAttributes.

This is a breaking change that was deemed acceptable due to perf wins. It did not affect C# and VB libraries, since C# and VB compilers have always provided special support for extension methods, by automatically adding the assembly-level ExtensionAttribute for you even if you leave it out.

Besides C# and VB, though, I don't know of any other CLI languages that have special compiler support for defining extension members. C# usage of libraries from all of these languages is now broken by Roslyn.

F# was noticed early, and has already been special-cased to preserve back-compat.

C++/CLI suffers from the same issue, though, and is still broken. All online documentation and sample code I can find leaves out the assembly-level attribute, because it was never needed in the past. Even the estimable Jon Skeet forgets that the assembly-level attribute is required: http://stackoverflow.com/a/995154/1366219 Another highly-voted answer here: http://stackoverflow.com/a/6012771/1366219

Other CLI languages like Nemerle, Boo, Iron*, etc will also be affected.

comments

t_sch wrote Nov 26, 2014 at 3:32 PM

Can you show an example of the assembly-level attribute.

All my tries til now ende in xdcmake not finishing during build. Weird.