The last year has been pretty quiet with Glass.Mapper.Sc, we have been mostly supporting users via Slack and Consultancy. I have also been working on another project that took up a lot of my spare time. 

However over the last 6 months we have been working hard to bring you V5 of Glass.Mapper.Sc. Version 5 contains some substantial changes to the framework and our goals for this release were:

  1. Remove unused features / unpopular features. There were many things in Glass that we thought were interesting and potentially useful but unfortunately they never got used or just weren't useful. These have been removed to reduce the code base.
  2. Make the framework more flexible and extensible, this is primarily via the use of options classes as you will see in a later blog post.
  3. Reduce the amount of code that we need to maintain and bring Glass.Mapper.Sc back to primarily being a model mapping framework. This means some features outside of this scope have been removed, for example code first and the Content Search project.
  4. Improve performance for developers using code generated classes.
  5. Remove some of the configuration that made it difficult to understand how an object graph might act when lazy loading has been disabled.
  6. Change the Nuget package structure because of the removal of Powershell support when a package is installed.

Below is a summary of these changes and the major ones we will detail in a future blog post. There is also an online training course being launched which will show you all the key features of Glass.Mapper.Sc. This course is designed for both developers who have no knowledge of Glass.Mapper.Sc and more experienced developers, but more about this in another blog post.

  • V5 only supports Sitecore versions 8+.
  • For each supported version of Sitecore  we supply a separate nuget package. This means that you must install the correct nuget package for your version of Sitecore. The nuget package naming format is:

    Where version is the Major/Minor version of Sitecore you are using, e.g. 8.1 is 81 or 9 is 90. In V4 we hid this from the developer by using a powershell script to determine which Nuget packages to install. In later version of Nuget powershell scripts are no longer support so we have had to move away from this solution.
  • Updated Castle.Core to version 4.2.1
  • ISitecoreContext has been marked as obsolete and will be replaced with:
    • IMvcContent
    • IRequestContext
    • IWebFormsContext

ISitecoreContext is being replaced because it no longer fits with the architecture of Sitecore. It was also a mixture of database access and request context and therefore didn’t have a single responsibility. The above context classes have a clear usage and a single function.

  • When calling methods on SitecoreService parameters have beenreplaced with options classes. We are moving away from parameters to options classes because having parameters was limiting the framework. Every time an additional parameter was added it would result in numerous different overloads to handle the many different ways of requesting an item. This wasn’t maintainable and also gave us headaches when making the code backward compatible. It also didn’t allow users of Glass.Mapper to extend and pass in their own parameters.
    Currently the old parameters methods still exist but are marked as obsolete. This is to maintain backwards compatibility but you should plan to refactor your code to use the new options classes. Eventually the obsolete methods will be removed.
  • Glass.Mapper will now use proxy objects for all models generated unless lazy loading is disabled. In V4 Glass.Mapper would only use proxy objects when loading items via relationship on a model, e.g. parent, children. Now the root object in the object graph will be a proxy. This has allowed us to perform a set of optimisations on how fields are mapped. This optimisation will mean that Glass.Mapper performs better with developers using Code Generation with no impact on users who hand craft their models.
  • GlassView and GlassController are now marked as obsolete. These class will eventually go, they no longer offer any value and other better techniques are available.
  • The lazy loading flag has been removed from all SitecoreType configuration. This flag was causing problems because in complex object graphs it would be hard for a developer to tell if the should set it to false or not (e.g. because the model was being cached). This resulted in object graphs having a mix of lazy loaded and non-lazy objects. In V5 lazy loading is disabled when a model is requested and this affects the entire object graph. It also meant you couldn't mix a model in lazy and non-lazy graph.
  • Caching will disable lazy loading automatically, if a request or model is marked a cachable then all object from that point in the graph will have lazy loading disabled automatically.
  • Enums now have defined values instead of automatic values, you will need to recompile all code against the V5 assemblies otherwise you may have strange behaviour:
    • SitecoreEnforceTemplate
  • Remove Multiple Interface support, this feature was not widely known or used.
  • Moved the item version count to the ObjectConstruction pipeline. This will allow more customisation and flexibility.
  • The SitecoreService.Map method has been renamed SitecoreService.Populate.
  • Removed Dynamic keyword support, this was feature that wasn’t know about or widely used.
  • Removed the Glass.Mapper.Sc.ContentSearch.LuceneProvider
  • Removed code first support, this feature was not used very much and needs reimplementing. Additionally the properties that were required for code first were causing confusion for developers who weren’t using code first.

 If you would like to preview V5 you can download it from the Glass build server. Also checkout at the bottom of this page, this site is already running on V5!


 Watch this space for a series of blog posts about V5 and signup to the Glass mailing list to be kept up to date on what is happening.





Signup today to receive email updates about Sitecore release, events and training.

If you have previously subscribed you will need to subscribe again due to GDPR.