From 2ecab707727e050a765060743cd52495f95ff22c Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 11 Mar 2014 17:00:35 +1100 Subject: [PATCH] Fixes: U4-4182 Exception during plugins loading --- src/Umbraco.Core/CoreBootManager.cs | 8 +++----- src/Umbraco.Core/HideFromTypeFinderAttribute.cs | 13 +++++++++++++ .../PublishedContent/PublishedPropertyType.cs | 2 +- src/Umbraco.Core/PluginManager.cs | 9 --------- src/Umbraco.Core/TypeFinder.cs | 6 +++++- src/Umbraco.Core/TypeHelper.cs | 2 +- src/Umbraco.Core/Umbraco.Core.csproj | 1 + 7 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 src/Umbraco.Core/HideFromTypeFinderAttribute.cs diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs index dea05d57af..00e0daebc8 100644 --- a/src/Umbraco.Core/CoreBootManager.cs +++ b/src/Umbraco.Core/CoreBootManager.cs @@ -318,11 +318,9 @@ namespace Umbraco.Core PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver( PluginManager.Current.ResolvePropertyEditorValueConverters()); - //add the internal ones, these are not public currently so need to add them manually - PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver( - PluginManager.Current.ResolvePropertyValueConverters()); - // fixme - why not use the following syntax? - //PluginManager.Current.ResolveTypes()); + // need to filter out the ones we dont want!! + PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver( + PluginManager.Current.ResolveTypes()); // use the new DefaultShortStringHelper ShortStringHelperResolver.Current = new ShortStringHelperResolver( diff --git a/src/Umbraco.Core/HideFromTypeFinderAttribute.cs b/src/Umbraco.Core/HideFromTypeFinderAttribute.cs new file mode 100644 index 0000000000..cc32654c9c --- /dev/null +++ b/src/Umbraco.Core/HideFromTypeFinderAttribute.cs @@ -0,0 +1,13 @@ +using System; + +namespace Umbraco.Core +{ + /// + /// Used to notify the TypeFinder to ignore any class attributed with this during it's discovery + /// + [AttributeUsage(AttributeTargets.Class)] + public sealed class HideFromTypeFinderAttribute : Attribute + { + + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs index c8bf96be8f..8ef077a968 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs @@ -269,7 +269,7 @@ namespace Umbraco.Core.Models.PublishedContent : Enumerable.Empty(); } - class CompatConverter : PropertyValueConverterBase + private class CompatConverter : PropertyValueConverterBase { private readonly IPropertyEditorValueConverter _converter; diff --git a/src/Umbraco.Core/PluginManager.cs b/src/Umbraco.Core/PluginManager.cs index d08845772d..a325816909 100644 --- a/src/Umbraco.Core/PluginManager.cs +++ b/src/Umbraco.Core/PluginManager.cs @@ -507,15 +507,6 @@ namespace Umbraco.Core return ResolveTypes(); } - /// - /// Returns all available PropertyValueConverter - /// - /// - internal IEnumerable ResolvePropertyValueConverters() - { - return ResolveTypes(); - } - /// /// Returns all available IDataType in application /// diff --git a/src/Umbraco.Core/TypeFinder.cs b/src/Umbraco.Core/TypeFinder.cs index 66c6f5a7c5..8df446ed7a 100644 --- a/src/Umbraco.Core/TypeFinder.cs +++ b/src/Umbraco.Core/TypeFinder.cs @@ -525,8 +525,12 @@ namespace Umbraco.Core //now filter the types based on the onlyConcreteClasses flag, not interfaces, not static classes var filteredTypes = allSubTypes - .Where(t => (TypeHelper.IsNonStaticClass(t) + .Where(t => (TypeHelper.IsNonStaticClass(t) + //Do not include nested private classes - since we are in full trust now this will find those too! + && t.IsNestedPrivate == false && (onlyConcreteClasses == false || t.IsAbstract == false) + //Do not include classes that are flagged to hide from the type finder + && t.GetCustomAttribute() == null && additionalFilter(t))) .ToArray(); diff --git a/src/Umbraco.Core/TypeHelper.cs b/src/Umbraco.Core/TypeHelper.cs index 7fba74b2a4..7e82f50848 100644 --- a/src/Umbraco.Core/TypeHelper.cs +++ b/src/Umbraco.Core/TypeHelper.cs @@ -6,7 +6,7 @@ using System.Reflection; namespace Umbraco.Core { - /// + /// /// A utility class for type checking, this provides internal caching so that calls to these methods will be faster /// than doing a manual type check in c# /// diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index f9837f32f0..b44d06ceaf 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -304,6 +304,7 @@ +