diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentDetectionConventions.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentDetectionConventions.cs new file mode 100644 index 0000000000..214f9e36a4 --- /dev/null +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentDetectionConventions.cs @@ -0,0 +1,28 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.CodeAnalysis.Razor +{ + internal static class ComponentDetectionConventions + { + public static bool IsComponent(INamedTypeSymbol symbol, INamedTypeSymbol icomponentSymbol) + { + if (symbol is null) + { + throw new ArgumentNullException(nameof(symbol)); + } + + if (icomponentSymbol is null) + { + throw new ArgumentNullException(nameof(icomponentSymbol)); + } + + return + symbol.DeclaredAccessibility == Accessibility.Public && + !symbol.IsAbstract && + symbol.AllInterfaces.Contains(icomponentSymbol); + } + } +} diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs index f160b53a90..ebc1947ca7 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs @@ -573,10 +573,8 @@ namespace Microsoft.CodeAnalysis.Razor return false; } - return - symbol.DeclaredAccessibility == Accessibility.Public && - !symbol.IsAbstract && - symbol.AllInterfaces.Contains(_symbols.IComponent); + var isComponent = ComponentDetectionConventions.IsComponent(symbol, _symbols.IComponent); + return isComponent; } } }