modelsbuilder / ModelsBuilder.Original

The Community Models Builder for Umbraco
MIT License
114 stars 49 forks source link

GetModelContentType: throw exception when no UmbracoContext exists #224

Open ronaldbarendse opened 5 years ago

ronaldbarendse commented 5 years ago

This 'fixes' issue https://github.com/zpqrtbnk/Zbu.ModelsBuilder/issues/222 and should be able to get merged with PR https://github.com/zpqrtbnk/Zbu.ModelsBuilder/pull/223.

Instead of throwing an ArgumentNullException, this method now throws an InvalidOperationException indicating it requires an UmbracoContext to be present.

To make it all work, callers should ensure this using IUmbracoContextFactory.EnsureUmbracoContext() as described in https://github.com/zpqrtbnk/Zbu.ModelsBuilder/issues/222#issuecomment-538320942.

If you only need the property alias, the new GetModelPropertyTypeAlias method from PR https://github.com/zpqrtbnk/Zbu.ModelsBuilder/pull/223#issuecomment-538384680 doesn't require the UmbracoContext.

ronaldbarendse commented 5 years ago

After merging with #223, the following XML documentation should be added to the GetModelContentType method (above the ArgumentOutOfRangeException):

/// <exception cref="InvalidOperationException">This method requires an UmbracoContext, ensure this is created using IUmbracoContextFactory.EnsureUmbracoContext().</exception>