Commit Graph

63 Commits

Author SHA1 Message Date
N. Taylor Mullen 6df8bc23f1 Renamed CodeBuilder related classes to CodeGenerator
- Now that what used to be CodeGenerators are now ChunkGenerators we can rename the CodeBuilder into its correct structure: a CodeGenerator.
- Moved the TagHelperAttributeValueCodeRenderer from the TagHelpers namespace into the CodeGeneration namespace.
- Went through several classes and remove and sorted usings.
- Updated test files to abide by the new naming convention of Builders => CodeGenerators.

#140
2015-05-27 17:00:41 -07:00
N. Taylor Mullen 5df9b52afe Renamed and moved several Razor classes for clarity.
- Renamed CodeGenerators to ChunkGenerators.
- Updated location of TestFiles from TestFiles/CodeGenerator/CS/{Output|Source} => TestFiles/CodeGenerator/{Output|Source}.
- Removed ChunkTree test; it was a legacy test used to experiment with Razor rendering (not a real test).
- Removed CSharpRazorCodeGenerator; it's now replaced with RazorCodeGenerator. It was an empty class that did nothing.
- Updated ChunkBlock => ParentChunk. Also updated several patterns throughout the code base that referenced these blocks as blocks and not parents.
- Moved Chunks and ChunkGenerators into the Chunks/Chunks.Generators namespace/folder structure. Updated test project to reflect the same.
- Moved CodeBuilders and CodeVisitors to the CodeGeneration/CodeGeneration.Visitors namespace/folder structure. Updated test project to reflect the same.
- Moved several TagHelper assets outside of their own namespaces and into Razors more general structures; such as CodeGeneration and Chunks/Chunks.Generators.

#140
2015-05-27 17:00:25 -07:00
Doug Bunting 60c47c8874 Add `[HtmlAttributeName(..., DictionaryAttributePrefix="prefix")]` part III
- #89 remainder
- support adding attributes (that aren't otherwise bound) to a tag helper dictionary
- use two `TagHelperAttributeDescriptor`s for dictionary and indexer
 - most exising descriptor properties have two meanings depending on new `IsIndexer`
 - add `TagHelperAttributeDescriptor.IsNameMatch()`
- create no `TagHelperAttributeDescriptor`s if property name or `HtmlAttributeNameAttribute`
  is invalid
 - avoid corner case misfeatures where invalidity removes just one descriptor
- extend handling of invalid attribute names to include `[HtmlAttributeName]`
- handle prefix matches in `TagHelperBlockRewriter`
 - add parse error when resolved dictionary key is `string.Empty`
- generate code for indexer property assignments
 - add code generation for runtime error if using indexer when property is `null`
 - use new `GeneratedTagHelperContext.FormatInvalidIndexerAssignmentMethodName` for message
- code generation now handles attributes in source order; thus above errors occur only when
  expected if dictionary is also initialized in the Razor source
 - surprisingly generation order change did not break existing tests!

nits:
- improve `TagHelperDescriptorFactory_InvalidBoundAttributeName` wording
 - rename resource to `TagHelperDescriptorFactory_InvalidAttributeNameOrPrefixStart`
- correct order of arguments to `FormatTagHelperDescriptorFactory_InvalidBoundAttributeName`
- correct `TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed` resource
- correct `TagHelperDescriptorFactoryTest` test names
 - remove a few unnecessary `ToArray()` calls
- update `TagHelperAttributeDescriptorComparer` comments
2015-05-20 22:01:00 -07:00
N. Taylor Mullen 1879ac6427 Add support for static usings.
- Added special cases to the using statement parser to understand `@using static Foo`.
- Added several unit tests to validate the static using structure.
- Modified existing import code generation tests to validate several static usings.

#44
2015-05-20 21:47:23 -07:00
Ajay Bhargav Baaskaran aaa14cd36b More bug fix for #379 2015-05-20 13:55:12 -07:00
Ajay Bhargav Baaskaran 47577fd936 [Fixes #379] Ignoring whitespace at the end of text tag 2015-05-19 17:21:28 -07:00
N. Taylor Mullen 58c0a36200 Add support for null conditional operators in implicit expressions.
- Added case in ImplicitExpression handling to understand question marks.
- text?. is special compared to text. because with text. we currently validate content after text. to determine if it's an expression or if it's a period. Now with ?. we always treat it as an expression because ?. is not a useful sentance of any kind.
- Added unit tests to validate new implicit expression handling
- Added runtime and design time code generation tests to validate null conditional operators.

#44
2015-05-19 16:34:08 -07:00
N. Taylor Mullen b25bf01158 Add TagHelper support for unbound data- attributes.
- Involved updating the HtmlMarkupParser to properly separate data- attributes. Prior to this change `data-foo="abc @DateTime.Now def"` would involve 1 Span for `data-foo="abc` 1 Span for `@DateTime.Now` and 1 Span for `def"`. This was very unique behavior from an attribute standpoint (as far as Razor is concerned) and made it difficult for the TagHelper rewriting system to rewrite attributes. With this change it gets broken out as follows: `|data-foo="|abc| @DateTime.Now| def|"|`.
- Added unit tests to validate the various ways you can write unbound data- attributes.
- Updated the BasicTagHelpers codegeneration test to intermix some unbound data- attributes.

#342
2015-05-18 22:43:03 -07:00
N. Taylor Mullen 0882ff4a13 Add tests to validate minimized attributes.
- Added parse level rewriting tests to validate new TagHelper rewritten structures for minimized attributes.
- Updated existing parser tests to understand minimized attributes.
- Added codegen test to validate understanding of minimized attributes.
- Added TagHelperExecutionContext tests to validate maintaining of runtime TagHelperOutput tests.
- Refactored part of the TagHelperParseTreeRewriterTest file into a base class file so we can make better rewriting tests.

#220
2015-05-15 12:23:11 -07:00
Ajay Bhargav Baaskaran 7bd338fc4a [Fixes #266] Maintain HTML provided case for TagHelper attributes 2015-05-13 15:27:38 -07:00
Ajay Bhargav Baaskaran 4d80c96f9c [Fixes #50] Removed unnecessary whitespaces before text tag 2015-05-13 10:55:52 -07:00
N. Taylor Mullen 2d20063ba5 Remove layout directive.
- Removed all instances of the layout directive from src and test projects.

#359
2015-04-27 14:48:53 -07:00
N. Taylor Mullen 7d7b2795e1 Change tests to utilize Environment.NewLine.
- Normalized newlines for code generation tests. We default all tests to use \r\n. This way we can have a consistent test experience cross plat.
- For tests that expected indexes that were affected by new lines I modified them to account for cross plat scenarios.
- Added a few test classes to ensure we could normalize newlines for codegen tests.

#106
2015-04-03 23:50:21 -07:00
Doug Bunting 33407ef1be Enforce new invariants around HTML encoding
- #335
- bound `string` attribute values are _not_ encoded
 - rework `CSharpCodeVisitor` and `CSharpTagHelperCodeRenderer` to enable this case
- values in `TagHelperOutput.Attributes` are encoded unless special-cased elsewhere
 - `Dictionary<string, object>` type allows `RazorPage` to use `HtmlString`
- wrap HTML unbound attribute values using `Html.Raw()`
2015-03-30 11:09:26 -07:00
N. Taylor Mullen 2b6220205d Updated duplicate TargetElement TagHelper tests.
#326
2015-03-20 00:20:36 -07:00
N. Taylor Mullen 842549bba9 De-dupe TagHelperDescriptors based on Type for rendering.
- This can occur if you have multiple [TargetElement] attributes that overlap. Ultimately the descriptor is the same because its the same type, just the required attributes differ.
- Added tests to validate.

#326
2015-03-19 22:46:49 -07:00
Ajay Bhargav Baaskaran fa40fe6e46 Fix build break 2015-03-19 16:16:18 -07:00
Ajay Bhargav Baaskaran 7b468344c0 [Fixes #169] Await TagHelper generated objects 2015-03-19 16:08:07 -07:00
N. Taylor Mullen 4345b06e88 Add tests to validate TagHelper attribute targeting.
- Added tests to validate TargetElementAttribute, TagHelperDescriptorFactory, CSharpTagHelperCodeRenderer and TagHelperParseTreeRewriterTests.
- Renamed HtmlElementNameAttributeTest to TargetElementAttributeTest.

#311
2015-03-17 21:48:54 -07:00
Ajay Bhargav Baaskaran b3c60976a4 Removed @helper directive 2015-03-17 13:54:37 -07:00
sornaks 7daec14e49 Issue #318: Removing Generate*() methods. 2015-03-17 13:15:03 -07:00
sornaks bd9d57d33e Introducing buffering in TagHelperOutput.PreContent, Content, PostContent. 2015-03-04 12:56:13 -08:00
Ajay Bhargav Baaskaran 7ecce1b666 Replaced WebUtility.HtmlEncode with IHtmlEncoder.HtmlEncode 2015-03-03 11:32:05 -08:00
N. Taylor Mullen 4bd02badda Add tests to verify tagHelperPrefix directive.
- Added parsing, sub-rewriting, rewriting and code generation tests for runtime/designtime.
- Fixed existing tests to utilize new class structures.

#309
2015-03-02 17:07:07 -08:00
Youngjune Hong 23e6264715 Fix1571 - Supporting self-closing tags for taghelpers 2015-02-20 16:27:31 -08:00
N. Taylor Mullen f53b6bb0e3 Change '?' in add and remove TagHelper to mean 1 character.
- Modified tests to account for new behavior of the '?' character in @addtaghelper and @removetaghelper.

#297
2015-02-16 18:59:20 -08:00
Doug Bunting fbe331c1ab Camel-case tag helper directives
- #264
2015-02-13 15:10:37 -08:00
N. Taylor Mullen cf3d049272 Add tests to validate TagHelper escape functionality.
- Added extensive unit tests.
- Added functional test to validate output for runtime and design time.

#187
2015-02-03 14:34:47 -08:00
N. Taylor Mullen 32f0858e8f Add tests for @addtaghelper and @removetaghelper wildcard ability.
- Also added tests to ensure cases of @addtaghelper "MyAssemblyName" create an error.
- Regenerated all CS files to folow new format.

#285
2015-02-03 12:16:01 -08:00
N. Taylor Mullen 7afd78b36a Fix empty attribute projections for TagHelpers.
- Added TagHelperParseTreeRewriter tests, attempted to cover all empty attribute edge cases.
- Added Codegen tests to validate output and DesignTimeLineMappings.

#271
2015-02-02 15:49:08 -08:00
N. Taylor Mullen a658c1336f Added CodeGen for TagHelper content mode redesign.
- Modified the CSharpTagHelperCodeRenderer to understand a single line of TagHelper rendering (instead of doing different things based on ContentBehavior).
- Modified existing CodeGen output to reflect new content changes.

#221
2015-01-16 11:51:02 -08:00
N. Taylor Mullen c38761f504 Remove ContentBehavior.
- Removed all tests and instances of ContentBehavior in preparation for moving to a non-ContentBehavior based design.
- Removed ContentBehavior specific CodeGeneration.

#221
2015-01-16 11:34:45 -08:00
Doug Bunting de4cafa8cd Handle complex expressions for bound non-string tag helper attributes
- #129 and support aspnet/Mvc#1253
- add new `CSharpTagHelperAttributeValueVisitor` that writes the raw expression
- add tests of embedded `@(...)` and mix that with normal expressions
- add new resources for errors in `CSharpTagHelperAttributeValueVisitor`
 - write errors using `ParserErrorSink`
- update baselines to match new code generation

nits:
- cleanup long lines in `CSharpTagHelperCodeRenderer`
- remove a few unused resources
2015-01-15 16:32:16 -08:00
N. Taylor Mullen 2d2c2cdf0f Add warning disable for unused variable warnings for TagHelper fields.
- Added a 0414 warning disable/restore around the __tagHelperStringValueBuffer since it's the only TagHelper utility field that "may" never be used.
- Regenerated baselines for TagHelper test files.

#260
2015-01-13 14:44:22 -08:00
DamianEdwards 7890a1b34c Added TagHelperContext.UniqueId:
- The ID is created at view compilation time and is unique per TagHelperExecutionContext and thus per HTML element in the source for which Tag Helpers will run
- #241
2014-12-12 16:25:42 -08:00
N. Taylor Mullen 54155e47e5 Add DesignTime code generation support for TagHelpers.
- We now generate a subset of the TagHelper runtime code during DesignTime. This enables users to see errors in the editor
- Added tests to validate design time code generation.
- Refactored runtime code generation tests (we now use a lot of their infrastructure for the design time pieces).

#208
2014-11-07 10:57:50 -08:00
N. Taylor Mullen 7ab25918e0 Add tests to validate @removetaghelper functionality.
- Added utility methods to construct valid SyntaxTreeNodes that represent the @removetaghelper directive.
- Added parse level unit tests to validate the @removetaghelper generates an accurate SyntaxTreeNode.
- Added parse level unit tests to validate the @removetaghelper throws with bad formats.
- Added TagHelperRegistration unit tests to validate the AddOrRemoveTagHelperCodeGenerators are understood and affect the descriptors found.
- Added Designtime mapping tests to validate correct source mappings are made to ensure proper coloring and lack-of C# intellisense.
- Added end-to-end tests to validate @removetaghelper can essentially disable TagHelpers on a page.

#112
2014-10-29 11:31:00 -07:00
Pranav K a2a05e7153 Modify CSharpCodeWriter to generate async lambdas for section
Fixes #85
2014-10-13 17:00:38 -07:00
N. Taylor Mullen 7db4ed7f7e Add tests to validate @addtaghelper directive.
- Fixed existing tests to work with new RazorParser.
- Validated directive syntax tree creation, errors and code generation.

#111
2014-10-09 12:57:46 -07:00
NTaylorMullen 05d8193775 Add test for TagHelperAttributeValueCodeRenderer extensibility.
- Tested that we can successfully plugin our own TagHelperAttributeValueCodeRenderer.
- Moved some existing TagHelper test logic into its own base type to enhance code reusability.

#119
2014-10-09 12:57:40 -07:00
N. Taylor Mullen c3b51cbbdf Add code generation tests for tag helpers.
#72
2014-10-09 12:57:34 -07:00
Pranav K 83da8e257d Generate code for expressions in design time to enable intellisense
Fixes #80
2014-10-08 09:53:27 -07:00
Pranav K f913d8929f Updating CSharpCodeVisitor to generate implicit expressions on a single
line

Fixing 151
2014-10-01 17:20:00 -07:00
Pranav K 5369842384 Ensure pragma checksum is prepended to generated file
Fixes #160
2014-09-29 14:45:26 -07:00
Pranav K 11ee402eec Reviving support for instrumentation in CSharpCodeVisitor
Fixes #42
2014-09-22 17:59:29 -07:00
N. Taylor Mullen 9bd2fdecac Modified tests to account for await accepting dots.
#45
2014-05-15 10:52:01 -07:00
N. Taylor Mullen 662dc087bd Addressed code review comments.
#28
2014-05-09 14:49:02 -07:00
N. Taylor Mullen 32f6f4df00 Modify tests to account for new generated output.
Added pragma warning disable 1998 to surrounded generated execute method.

#28
2014-05-09 11:09:45 -07:00
N. Taylor Mullen 20c91146f1 Remove copyright header from generated test files. 2014-05-09 11:08:22 -07:00
N. Taylor Mullen 570760ddc7 Modified tests to account for new code generation.
#30
2014-05-09 11:06:30 -07:00