-
Notifications
You must be signed in to change notification settings - Fork 223
Add ContentBehaviorAttribute for TagHelpers. #166
Conversation
var typeInfo = type.GetTypeInfo(); | ||
var contentBehaviorAttribute = typeInfo.GetCustomAttribute<ContentBehaviorAttribute>(inherit: false); | ||
|
||
return contentBehaviorAttribute?.ContentBehavior ?? DefaultContentBehavior; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!!
b7749f9
to
5b5111a
Compare
8f15a16
to
78a61d8
Compare
5b5111a
to
03115f9
Compare
78a61d8
to
7565cd6
Compare
03115f9
to
c39c360
Compare
7565cd6
to
d3b481a
Compare
c39c360
to
41e44b3
Compare
d3b481a
to
55b4148
Compare
41e44b3
to
cabe3dc
Compare
55b4148
to
20762a7
Compare
cabe3dc
to
3e18f61
Compare
20762a7
to
ba8c7eb
Compare
3e18f61
to
42556ce
Compare
ba8c7eb
to
2e8616f
Compare
42556ce
to
09e5719
Compare
2e8616f
to
7501edc
Compare
09e5719
to
294fa36
Compare
7501edc
to
738104f
Compare
294fa36
to
0a5b27f
Compare
738104f
to
c08a823
Compare
0a5b27f
to
5355a6e
Compare
c08a823
to
7fef72c
Compare
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers | ||
{ | ||
/// <summary> | ||
/// Used to override <see cref="TagHelper"/>s functionality for when its |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// ... a <see cref="TagHelper"/>'s ...
(add a word and apostrophe)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "functionality" isn't used much (and doesn't mean much) and "for" is noise. suggest "behavior" instead of "functionality for".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... or perhaps just /// Used to override when the <see cref="TagHelper"/>'s ... method is called from generated code.
I'm not convinced you need "from generated code" but don't mention TagHelperRunner
since that's not visible to most.
var typeInfo = type.GetTypeInfo(); | ||
var contentBehaviorAttribute = typeInfo.GetCustomAttribute<ContentBehaviorAttribute>(inherit: false); | ||
|
||
return contentBehaviorAttribute?.ContentBehavior ?? ContentBehavior.None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not sure the compiler is smart enough to skip null-checking the ContentBehavior
property. either way, this looks like two null
checks rather than the one you need. so a ternary expression is more straightforward.
|
5355a6e
to
9d125d2
Compare
7fef72c
to
38a1f50
Compare
Will push this once its dependent PR's have been signed off on. |
9d125d2
to
40e755c
Compare
38a1f50
to
ed954ef
Compare
} | ||
|
||
/// <summary> | ||
/// =<see cref="Razor.TagHelpers.ContentBehavior"/> for the <see cref="ITagHelper"/>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove leading =
still |
- Added detection of custom ContentBehaviors via the ContentBehaviorAttribute in the TagHelperDescriptorFactory. - Updated some comments in the ContentBehavior enum. - Add tests to validate custom content behavior resolution. #122
40e755c
to
46a7105
Compare
ed954ef
to
4dceae9
Compare
Tag Helpers: Add ability to specify ContentBehavior #122