From 10e9991f5cec36fc1c673876cae7192f3a6f2d51 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 23 Oct 2010 13:42:40 -0700 Subject: [PATCH] Features with no code should be loaded successfully Simply return a feature with no exported types instead of failing. The system is currently built with the assumption that if an extension is active, then any of its feature can be activated/loaded. --HG-- branch : dev --- src/Orchard/Environment/Extensions/ExtensionManager.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Orchard/Environment/Extensions/ExtensionManager.cs b/src/Orchard/Environment/Extensions/ExtensionManager.cs index 41f002967..f8a51dad2 100644 --- a/src/Orchard/Environment/Extensions/ExtensionManager.cs +++ b/src/Orchard/Environment/Extensions/ExtensionManager.cs @@ -92,8 +92,14 @@ namespace Orchard.Environment.Extensions { throw new ArgumentException(T("Feature {0} was not found in any of the installed extensions", featureName).ToString()); var extension = LoadedExtensions().Where(x => x.Descriptor.Name == extensionName).FirstOrDefault(); - if (extension == null) - throw new InvalidOperationException(T("Extension {0} is not active", extensionName).ToString()); + if (extension == null) { + // If the feature could not be compiled for some reason, + // return a "null" feature, i.e. a feature with no exported types. + return new Feature { + Descriptor = featureDescriptor, + ExportedTypes = Enumerable.Empty() + }; + } var extensionTypes = extension.ExportedTypes.Where(t => t.IsClass && !t.IsAbstract); var featureTypes = new List();