Extension method for site setting deployments, optimize AddTokenToPath - This week in Orchard (11/08/2021)

Gábor Domonkos's avatar
Performance, Media Library, Documentation, This week in Orchard

The development of Orchard Core of course has been continued after the release of 1.0. Are you curious about the newest improvements of Orchard Core? Well, let's check them out!

Orchard Core updates

Optimize AddTokenToPath

The community tries to make Orchard Core as optimized and as fast as it could be. C# and ASP.NET Core with other third-party libraries offer several tricks and techniques to achieve this goal. For example, you can use ZString instead of StringBuilder. ZString is a library that provides StringBuilder and StringWriter with zero allocation, meaning it's allocating an array on the stack for small buffers, instead of creating new StringBuilders and StringWriters every time. All ZString methods only allocate the final string. Also, ZString has enabled to access the inner buffer, so if the output target has stringless API, you can achieve completely zero allocation.

Or another improvement could be to not use string.Split that causing array allocation, use sub-strings instead.

Optimize AddTokenPath

Add extension method for site setting deployments

Whenever you would like to add a deployment step that allows exporting your custom site settings, you need to register three services with the transient, scoped, and singleton lifetimes. It's not a huge issue though because you can easily open a Startup.cs file of a module that contains these kinds of registrations and see how you can do it in your module but having an extension method for site setting deployments could reduce the lines that you need to copy every time. The new AddSiteSettingsPropertyDeploymentStep allows you to register your custom site settings deployments just in one line! Check out the Startup.cs files of any module to see the new way of registering your site setting deployments.

Extension method for site setting deployments

Not use a current culture when checking invalid Autoroute path

If you enable the Localization module and set a default culture to a non en-US culture, e.g. th-TH, you will get a validation error when trying to save a content item with an Autoroute part. Here is the screenshot when trying to save a content item and a default culture is th-TH.

Not use a current culture when checking invalid autoroute path

This issue is from AutoroutePartExtensions.ValidatePathFieldValue method. Inside the method, there is a call of autoroute.Path?.IndexOf("//") which returns 0 instead of -1 when a current culture is th-TH. According to the MS document, IndexOf(String) searches a word by using culture and case sensitivity.

Refer to Recommendations for string usage, we should use StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase for the non-linguistic string search. There is no case in a space and //, so the fix here was to pick StringComparison.Ordinal and to match IndexOf which is case-sensitive.

Check if Autoroute Path has invalid characters

Cypress 8.2.0 and Trumbowyg 2.25.1

If you are a huge Orchard Core enthusiast and like to check out the recent changes of the CMS from time to time, you may notice that the community upgrades the different .NET/Client-side/Test libraries from time to time. The Orchard Core documentation has a Libraries page under the Resources one where you can see the versions of these libraries that are used across the main branch of Orchard Core. Antoine Griffard recently updated Cypress to 8.2.0 and Trumbowyg to 2.25.1! With these updates, you can make sure that if you would like to use the built-in libraries of Orchard Core you will always have the latest versions!

Orchard Core used libraries

News from the community

Lombiq Technologies: new developer colleagues and new group photo

We had a great company trip last week where almost all of the colleagues of Lombiq gathered together to spend the whole day together offline. This was a great opportunity to update our group photo on our official website, so head to the About us page where you can see the most, but not all of our team as of the summer of 2021.

Lombiq team 2021 summer

And we also have two new colleagues to introduce: Ádám Jakab and Szabolcs Deme. Don't forget to check out their bio too!

DotNest Core

DotNest Core is a complete redevelopment of the DotNest platform, all on the latest version of Orchard Core. We've been running it with a couple of select few customers for a while now, and it's time to open it up a bit more. While you can't yet just simply create an Orchard Core-based DotNest site, you can sign up for our limited beta here. You'll soon be able to get a fully functional, reliably hosted Orchard Core site on DotNest where you can build your personal website or something to showcase your Orchard skills with.

Sign up for the DotNest Core beta

Orchard Dojo Newsletter

Lombiq's Orchard Dojo Newsletter has 215 subscribers! We have started this newsletter to inform the community around Orchard with the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post is published to Orchard Dojo, including This week in Orchard of course.

Do you know of other Orchard enthusiasts who you think would like to read our weekly articles? Tell them to subscribe here!

No Comments

Add a Comment