Add OutputElementHintAttribute to control design time IntelliSense for TagHelpers.#430
Add OutputElementHintAttribute to control design time IntelliSense for TagHelpers.#430NTaylorMullen wants to merge 3 commits intonimullen/consumedocs.352from
Conversation
There was a problem hiding this comment.
Decided to not have the attribute inheritable since TargetElement is not inheritable.
|
/cc @dougbu |
There was a problem hiding this comment.
Doubt the GetCustomAttribute<T>() is so expensive that it needs to be inside this condition. Also this factory should only execute once at runtime. So calculate the hint unconditionally.
There was a problem hiding this comment.
Why waste cycles? The intention of this attribute is that it's design-time only.
There was a problem hiding this comment.
I made this suggestion because it seemed like an unnecessary optimization that mixed the hint with descriptors and required another non-var variable.
There was a problem hiding this comment.
I'd be more tempted to have a whole property called DesignTimeStuff that then had properties for each of the design-time only parts of the descriptor, which for now might be just the hint.
There was a problem hiding this comment.
Like it. UsageDescriptor would be in there too.
There was a problem hiding this comment.
Could revamp TagHelperUsageDescriptor to be the design time stuff property. Would just have to add an extra type maybe like TagHelperElementUsageDescriptor which would contain OutputElementHint for TagHelperDescriptors. TagHelperAttributeDescriptors would continue to use TagHelperUsageDescriptor.
What do you guys think?
There was a problem hiding this comment.
I don't know what these things are, so I don't think much 😄
|
⌚ |
f6b56d1 to
9055da1
Compare
5845c45 to
54481ac
Compare
|
Updated. |
- Added platform specific path handling to the TagHelperUsageDescriptorFactoryTests.
There was a problem hiding this comment.
Should this avoid the ctor and just have get/set properties? I'm sure we'll add lots more stuff in the future, and it might be annoying to have to keep making the ctor have more and more params.
There was a problem hiding this comment.
In fact, same goes for the other descriptors.
There was a problem hiding this comment.
It's deffffinitely annoying. The only reason why this descriptor uses the ctor to initialize everything is because the TagHelperDescriptor and TagHelperAttributeDescriptor do; aka for consistency.
At the initial creation of the descriptors I had them all constructorless but after a while the constructors were added and have stuck around. @dougbu If I remember correctly you showed the interest in adding the constructors initially which made sense at the time. Now that there's a boat load of properties on all of our descriptors how do you feel about nuking the ctors?
Will file an issue if @dougbu agrees (changing from ctors to no ctors will be a lot of noise + require changes to all of our comparers).
There was a problem hiding this comment.
Not only are there a boat load of properties, they're not all required.
I'm fine treating that as a separate issue.
There was a problem hiding this comment.
We moved toward constructor parameters to make the descriptors immutable while allowing serialization / deserialization. Comparisons, hash codes, and so on get messy if the descriptors can change. I know we wouldn't change the descriptors but we do store some of them in HashSets and so on.
So fine to open an issue but I'm not sure we should ever fix it 😈
There was a problem hiding this comment.
The containing descriptors are compared and / or stuck into HashSets.
There was a problem hiding this comment.
If others feel strongly about changing TagHelperAttributeDesignTimeDescriptor and TagHelperDesignTimeDescriptor to be mutable, suggest adding the public setters in this PR. Leave #441 to cover the existing TagHelperAttributeDescriptor and TagHelperDescriptor. This is possible / easy because the usage descriptors are only compared in test code.
There was a problem hiding this comment.
I'm presuming that the descriptors are never, ever mutated, so in practice this isn't an issue.
There was a problem hiding this comment.
This PR is 7 days old. Let's get it in and change the classes later.
|
Overall looks good, just had a question about the class design. |
There was a problem hiding this comment.
Keep the ?. operator together
|
We've got a buried discussion starting here |
|
⌚ |
54481ac to
4afb7b6
Compare
|
Updated |
|
|
…r TagHelpers. - Decided to not have the attribute inheritable since TargetElement is not inheritable. - Added tests to validate serialization, deserialization and construction of TagHelperDescriptors with OutputElementHints. - Changed TagHelperUsageDescriptor to TagHelperDesignTimeDescriptor and TagHelperAttributeDesignTImeDescriptor. #382
4afb7b6 to
85be731
Compare
TargetElementis not inheritable.TagHelperDescriptors withOutputElementHints.Add OutputElementHintAttribute to control inherited TagHelper IntelliSense. #382