Minor Update to Unicorn Code Generation Package

Minor Update to Unicorn Code Generation Package

I have just pushed a minor update to my tiny Unicorn / Rainbow Code Generation Package. You can find it on GitHub and NuGet.

Version 0.3 now features:

  • Tested against Unicorn 4 / Rainbow 2 and Sitecore 9
  • Generate code for any item, not just templates

Unicorn 4 Support

The package works fine against Unicorn 4 and is still backwards compatible to the earlier version. I have left the NuGet minimum dependency unchanged (v1.4 for Rainbow) but the T4 template now by default references the latest version.

Sitecore 9 Support

Sitecore 9 added a dependency to Microsoft.Extensions.DependencyInjection.Abstractions and Microsoft.Extensions.DependencyInjection. You now need to install Microsoft.Extensions.DependencyInjection in Version 1.0 via NuGet and then reference the DLLs in the T4 Template. I have added this in the template (but commented out, just enable for Sitecore 9).

Generate code for any item

You can now generate code for any item, this is e.g. useful for referencing well-known items via their GUID (e.g. config items or renderings). This is now possible via a newly added RainbowCodeGeneration.RainbowReader.GetItems() method. Below is an example for a T4 template that recursively generates code for all items in a configuration. The code is also available in the Test project on GitHub.

The header (including the configuration) for the template is the same as for the existing T4 template that installs with the package.

 

Leave a Reply

Your email address will not be published. Required fields are marked *