Try our conversational search powered by Generative AI!

EPiServer.dll, PropertyDataFactory logs warning incorrectly

Found in

EPiServer.CMS.Core 11.11.3

Fixed in

EPiServer.CMS.Core 11.14.2

(Or a related package)

Created

May 13, 2019

Updated

Mar 02, 2020

Area

CMS Core

State

Closed, Fixed and tested


Description

The log for creating a block property in PropertyDataFactory is not formatted correctly, it is not using _log.WarnFormat or creating the log message using string.format. The log message should use the ‘blockTypeReference.ModelTypeString’ so that the log message contains the type which failed to load.

Code here:

private PropertyData CreateBlockProperty(BlockTypeReference blockTypeReference)
{
Type type2;
if (!string.IsNullOrEmpty(blockTypeReference.ModelTypeString))
{
Type type = TypeResolver.GetType(blockTypeReference.ModelTypeString, throwOnError: false);
if (type == null)
{
if (_log.IsWarnEnabled)
{
_log.Warn("Could not load type '{0}', hence creating untyped property PropertyBlock<BlockData> instead");
}
type = typeof(BlockData);
}
if (!typeof(BlockData).IsAssignableFrom(type))
{
throw new TypeMismatchException(string.Format(CultureInfo.InvariantCulture, "The block type {0} does not inherit from the required class {1}", type.FullName, typeof(BlockData).FullName));
}
type2 = typeof(PropertyBlock<>).MakeGenericType(type);
}
else
{
type2 = typeof(PropertyBlock<BlockData>);
}
return CreateInstance(type2);
}