BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News AutoMapper and Working with Cross-Platform Assemblies

AutoMapper and Working with Cross-Platform Assemblies

With the creation of CoreCLR and the increasing popularity of Xamarin, it is becoming more and more important that .NET libraries are offered in a cross-platform fashion. Sometimes one can get away with using the PCL format, but more often than, cross-platform really means multiple platform builds.

Jimmy Bogard of AutoMapper fame ran into just this problem with Microsoft made a feature request for CoreCLR support for AutoMapper.

The traditional way to deal with multiple platform builds is to create a separate project file for each platform. One project would be the “master” and contain all of the source code. The other projects would use linked files to include just the files appropriate for the target platform.

This pattern doesn’t work with CoreCLR/vNext projects. Instead of picking individual files, this project type defaults to including all of the files via wildcards. Including all of the files in each project in turn requires heavy use of conditional compilation directives.

It should be noted that you don’t need vNext style projects to use wildcards. Though not exposed in the Visual Studio IDE, C# project files have always had the option to use wildcards instead of explicitly listing each file.

For more about cross-platform assemblies and Jimmy Bogard’s work on AutoMapper, check out his article titled Cross-Platform AutoMapper (again).

Rate this Article

Adoption
Style

BT