Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Add OutputElementHintAttribute to control design time IntelliSense for TagHelpers.#430

Closed
NTaylorMullen wants to merge 3 commits intonimullen/consumedocs.352from
nimullen/elementhint.382
Closed

Add OutputElementHintAttribute to control design time IntelliSense for TagHelpers.#430
NTaylorMullen wants to merge 3 commits intonimullen/consumedocs.352from
nimullen/elementhint.382

Conversation

@NTaylorMullen
Copy link
Copy Markdown

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to not have the attribute inheritable since TargetElement is not inheritable.

@NTaylorMullen
Copy link
Copy Markdown
Author

/cc @dougbu

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why waste cycles? The intention of this attribute is that it's design-time only.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this suggestion because it seemed like an unnecessary optimization that mixed the hint with descriptors and required another non-var variable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like it. UsageDescriptor would be in there too.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what these things are, so I don't think much 😄

@dougbu
Copy link
Copy Markdown
Contributor

dougbu commented Jun 25, 2015

@NTaylorMullen NTaylorMullen force-pushed the nimullen/consumedocs.352 branch from f6b56d1 to 9055da1 Compare June 25, 2015 22:46
@NTaylorMullen NTaylorMullen force-pushed the nimullen/elementhint.382 branch 2 times, most recently from 5845c45 to 54481ac Compare June 29, 2015 23:05
@NTaylorMullen
Copy link
Copy Markdown
Author

Updated.

- Added platform specific path handling to the TagHelperUsageDescriptorFactoryTests.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, same goes for the other descriptors.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only are there a boat load of properties, they're not all required.

I'm fine treating that as a separate issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😈

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The containing descriptors are compared and / or stuck into HashSets.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm presuming that the descriptors are never, ever mutated, so in practice this isn't an issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is 7 days old. Let's get it in and change the classes later.

@Eilon
Copy link
Copy Markdown
Contributor

Eilon commented Jun 30, 2015

Overall looks good, just had a question about the class design.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the ?. operator together

@dougbu
Copy link
Copy Markdown
Contributor

dougbu commented Jun 30, 2015

We've got a buried discussion starting here

@dougbu
Copy link
Copy Markdown
Contributor

dougbu commented Jun 30, 2015

@NTaylorMullen NTaylorMullen force-pushed the nimullen/elementhint.382 branch from 54481ac to 4afb7b6 Compare June 30, 2015 19:01
@NTaylorMullen
Copy link
Copy Markdown
Author

Updated ?. spacing and comment.

@dougbu
Copy link
Copy Markdown
Contributor

dougbu commented Jun 30, 2015

:shipit: (I wasn't waiting on those minor comments 😈)

…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
@NTaylorMullen NTaylorMullen force-pushed the nimullen/elementhint.382 branch from 4afb7b6 to 85be731 Compare June 30, 2015 19:13
@NTaylorMullen NTaylorMullen deleted the nimullen/elementhint.382 branch June 30, 2015 19:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants