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

Add @addtaghelper directive. #142

Conversation

NTaylorMullen
Copy link
Contributor

  • Also added some infrastructure pieces for it such as the ITagHelperDescriptorResolver and the default implementation TagHelperDescriptorResolver which will be filled out in a later commit.
  • Reworked some extensibility points to allow accessibility of the descriptor resolvers per offline discussions.
  • Fixed existing tests to work with new RazorParser.
  • Validated directive syntax tree creation, errors and code generation.
    Tag Helpers: Add @addtaghelper directive and link to registration system #111

@NTaylorMullen
Copy link
Contributor Author

I can break this into two PR's if people feel that it helps with the code review process.

@NTaylorMullen NTaylorMullen changed the title Add @addtaghelper directive. [Design] Add @addtaghelper directive. Sep 17, 2014
@@ -38,6 +38,14 @@ public void AddChunk(Chunk chunk, SyntaxTreeNode association, bool topLevel = fa
}
}

public void AddAddTagHelperChunk(string lookupText, SyntaxTreeNode association)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kinda rough naming but still felt like it made sense. Feel free to object.

Copy link
Member

Choose a reason for hiding this comment

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

naming here derives from @addtaghelper naming so it makes sense. could of course change the keyword to something like @usetaghelper (and later @removetaghelper might be @ignoretaghelper).
/cc @DamianEdwards

@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AddDirective branch from b918f8b to e8673f8 Compare September 17, 2014 18:21
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AttributeCodeGeneration branch from 3f2fa4a to 6a99ea3 Compare September 19, 2014 06:53
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AddDirective branch from e8673f8 to 4cd59eb Compare September 19, 2014 06:53
@NTaylorMullen NTaylorMullen changed the title [Design] Add @addtaghelper directive. Add @addtaghelper directive. Sep 20, 2014
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AttributeCodeGeneration branch from 6a99ea3 to c80b01f Compare September 23, 2014 06:46
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AddDirective branch from 4cd59eb to 68fd42a Compare September 23, 2014 06:47
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AttributeCodeGeneration branch from c80b01f to af6249b Compare September 24, 2014 00:11
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AddDirective branch from 68fd42a to 8ba1682 Compare September 24, 2014 00:11
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AttributeCodeGeneration branch from af6249b to f0d0d67 Compare September 25, 2014 07:06
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AddDirective branch from 8ba1682 to 2f775d4 Compare September 25, 2014 07:07
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AttributeCodeGeneration branch from f0d0d67 to 7eb0f98 Compare September 25, 2014 23:20
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AddDirective branch from 2f775d4 to 369a300 Compare September 25, 2014 23:20
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AttributeCodeGeneration branch from 7eb0f98 to 4f5e86d Compare September 26, 2014 20:36
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AddDirective branch from 369a300 to e9df146 Compare September 26, 2014 20:37
internal const string InheritsHelper = "__inheritsHelper";
internal const string DesignTimeHelperMethodName = "__RazorDesignTimeHelpers__";
private static readonly string ObjectTypeString = typeof(object).ToString();
Copy link
Member

Choose a reason for hiding this comment

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

why not just generate the string "object"?

Copy link
Member

Choose a reason for hiding this comment

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

or string or (if you do initialization) var

@dougbu
Copy link
Member

dougbu commented Sep 27, 2014

on PR description "Validated directive syntax tree creation, errors and code generation." bullet, looks as if you are only newly validating the @addtaghelper directive. correct?

tabTest: TabTest.NoTabs,
expectedDesignTimePragmas: new List<LineMapping>()
{
BuildLineMapping(14, 0, 440, 14, 14, 11)
Copy link
Member

Choose a reason for hiding this comment

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

icky magic numbers. please at least name the parameters

@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AttributeCodeGeneration branch from 040a3a1 to 7399531 Compare October 3, 2014 08:04
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AddDirective branch from 145b3c4 to f3d2585 Compare October 3, 2014 08:04
@NTaylorMullen
Copy link
Contributor Author

Addressed code review comments.


Writer.WriteStartAssignment(TagHelperDirectiveSyntaxHelper);

_csharpCodeVisitor.CreateExpressionCodeMapping(
Copy link
Member

Choose a reason for hiding this comment

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

(let's help the children 😺) add comments referring reader to code in CSharpCodeParser.TagHelperDirective() that ensures LookupText is not surrounded by the quotes. Might also be worth mentioning this restores quotes that code requires then removes.

@dougbu
Copy link
Member

dougbu commented Oct 3, 2014

⌚ very close; will mainly look at comments and nameof() use next time.

@NTaylorMullen
Copy link
Contributor Author

Addressed code review comments.

private const int DisableVariableNamingWarnings = 219;

public CSharpDesignTimeHelpersVisitor(CSharpCodeWriter writer, CodeBuilderContext context)
: base(writer, context) { }
private CSharpCodeVisitor _csharpCodeVisitor;
Copy link
Member

Choose a reason for hiding this comment

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

add readonly

@dougbu
Copy link
Member

dougbu commented Oct 4, 2014

:shipit: after adding a couple of readonly modifiers and addressing the few non-nit open comment comments

- Also added some infrastructure pieces for it such as the ITagHelperDescriptorResolver and the default implementation TagHelperDescriptorResolver which will be filled out in a later commit.
- Reworked some extensibility points to allow accessibility of the descriptor resolvers per offline discussions.

#111
- Fixed existing tests to work with new RazorParser.
- Validated directive syntax tree creation, errors and code generation.

#111
@NTaylorMullen NTaylorMullen force-pushed the TagHelpers_AddDirective branch from 84f0011 to da3051a Compare October 4, 2014 19:52
@NTaylorMullen NTaylorMullen deleted the TagHelpers_AddDirective branch October 4, 2014 20:01
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.

2 participants