@@ -107,6 +107,17 @@ public INamedTypeSymbol GetLayoutHbsTemplate(string layoutName)
107
107
return FindClassesWithNameAndAttribute ( layoutName , StringConstants . LAYOUTATTRIBUTEFULL , StringConstants . LAYOUTATTRIBUTE ) ;
108
108
}
109
109
110
+ /// <summary>
111
+ /// Finds a class with a certain name and attribute
112
+ /// Used to find layouts and partial templates
113
+ ///
114
+ /// Alas we have to check against both the full and the nonfull attribute name because of inconsistencies in Roslyn
115
+ /// when working with asp.net core projects
116
+ /// </summary>
117
+ /// <param name="fullName"></param>
118
+ /// <param name="attributeFull"></param>
119
+ /// <param name="attribute"></param>
120
+ /// <returns></returns>
110
121
private INamedTypeSymbol FindClassesWithNameAndAttribute ( string fullName , string attributeFull , string attribute )
111
122
{
112
123
var name = fullName . Split ( '.' ) . Last ( ) ;
@@ -142,7 +153,11 @@ public IMethodSymbol GetHelperMethod(string funtionName, List<ITypeSymbol> param
142
153
var candidates = comp . GetSymbolsWithName ( x => x . Equals ( funtionName ) )
143
154
. OfType < IMethodSymbol > ( )
144
155
. Where ( x => x . IsStatic &&
145
- x . GetAttributes ( ) . Any ( y => y . AttributeClass . Name . Equals ( StringConstants . HELPERMETHODATTRIBUTEFULL ) ) ) ;
156
+ // The check for both HelperMethodAttribute and HelperMethodAttributeFull because when loading a asp.net core project
157
+ // we the attribute name is HelpermethodAttribute while when loading a .net framework project the attribute name is
158
+ // HelperMethodAttribute
159
+ x . GetAttributes ( ) . Any ( y => y . AttributeClass . Name . Equals ( StringConstants . HELPERMETHODATTRIBUTEFULL )
160
+ || y . AttributeClass . Name . Equals ( StringConstants . HELPERMETHODATTRIBUTE ) ) ) ;
146
161
var helperMethod = candidates . FirstOrDefault ( x => DoParametersMatch ( x , parameters ) ) ;
147
162
if ( helperMethod != null )
148
163
return helperMethod ;
0 commit comments