Commit Graph

288 Commits

Author SHA1 Message Date
N. Taylor Mullen 392871beb6 Change missing section end brace error to work at EOF.
- Updated existing tests and added a new case to understand `@section {....` scenarios.
- Instead of trying to guess 1 character prior to EOF decided to log error on opening brace since we know its position. Updated error to account for change in location.

#625
2015-12-11 15:10:53 -08:00
Pranav K c7a6c099ed Removing more unused usings 2015-12-08 09:54:32 -08:00
Pranav K 2a301691db Updating tests to use moq.netcore 2015-11-23 12:15:26 -08:00
N. Taylor Mullen 6b43ebc88b Update code generation tests to account for new `TagHelperOutput`.
- Add `TagHelperOutput` unit tests.

#358
2015-11-19 16:32:08 -08:00
N. Taylor Mullen bdf869c3d5 Make `TagHelperOutput` an `IHtmlContent`.
- This allows users to write `TagHelperOutput` directly to an `IHtmlContent` accepting `TextWriter`.
- This also enables us to inspect backing fields for all of the various contents to lazily initialize them.

#358
2015-11-19 16:32:03 -08:00
Ryan Nowak 42acfe43ad Fix aspnet/Mvc#3196 Razor Compilation Allocations
This change significantly reduces the amount of string and List<ISymbol>
allocations that occur during compilation by changing the way
LiteralChunks are combined.

This is a low impact fix that addresses the performance issue, the design
issues that caused it still exist.

The problem here lies in what Razor fundamentally does - it parses HTML/C#
into tokens, and then combines them back into 'chunks' a representation
friendly to code generation. When presenting with a large block of static
HTML, Razor parses it into individual HTML tokens, and then tries to join
them in back into a single chunk for rendering. Due to details of Razor's
representation of chunks/tokens, the process of combining literals is too
expensive.

Mainly, what's done here is to not try to combine instances of
LiteralChunk. The process of merging them is too expensive and requires
lots of interm List<ISymbol> and string allocations.

Instead we produce a new 'chunk' ParentLiteralChunk, which doesn't do so
much up-front computing. Various pieces of the code that deal with
LiteralChunk need to be updated to deal with ParentLiteralChunk also,
which is the bulk of the changes here.

Note that we still have the potential for LOH allocations to occur during
codegen, but it's likely to occur O(1) for each large block of HTML
instead of O(N) as it did in the old code.
2015-11-18 12:51:11 -08:00
Ryan Nowak 5ce8740f70 Simplify ChunkTreeBuilder 2015-11-18 09:43:11 -08:00
N. Taylor Mullen 53dc4d73a4 Remove System beta tag in project.json for coreclr packages. 2015-11-12 12:23:22 -08:00
Pavel Krymets 7b248a7789 Make Compilation Abstractions naming consistent with Platform Abstractions 2015-11-06 16:18:45 -08:00
N. Taylor Mullen 0c95315500 Update tests to not require quotes for TH directives.
- Updated .cshtml files to not provide quotes for the various `TagHelper` directives.
- Updated `TagHelper` directive parsing tests. This also involved removing several tests that expected errors which no longer occur since we don't have to ensure quotes are balanced.
- Updated line mappings which significantly changed due to us no longer generating line pragmas at design time for `TagHelper` directives.

#561
2015-11-06 12:19:40 -08:00
N. Taylor Mullen 02d6b00d8f Generate `async` lambda for template attributes.
- Template attributes should be of type `Func<TextWriter, Task>`. We weren't generating an `async` lambda for attributes prior to this change resulting in a compilation failure when used at runtime and the inability to `@await` code (unless a user returns some sort of `Task`).
- Updated code generation files to reflect the new code generation behavior.

#594
2015-11-04 16:04:29 -08:00
Pavel Krymets 024c673bfa Rename Microsoft.Dnx.Compilation.Abstractions to Microsoft.Extensions.Compilation.Abstractions 2015-11-03 12:56:26 -08:00
Cesar Blum Silveira b329650a33 Merge branch 'release' into dev 2015-11-02 15:10:15 -08:00
Cesar Blum Silveira 7156de5a57 Strong name everything. 2015-11-02 14:56:23 -08:00
Chris R 99901ed4fe React to HtmlEncoder type changes. 2015-10-30 10:49:35 -07:00
N. Taylor Mullen a76f16cda8 Removed `TagHelper` infrastructure `using` statements.
- The using statements had a chance to conflict with user code. Removed them and changed the default configured type names to be `global::` full name based.
- Updated test file `TagHelperDescriptor.TypeName`s to have namespaces to make them easier to read.

#580
2015-10-29 16:23:38 -07:00
Pavel Krymets e4d1259da5 Remove usage of CallContextLocator 2015-10-29 12:06:12 -07:00
N. Taylor Mullen 22ecf85f88 Added `TagHelper` support for `enum`s.
- If a `TagHelper` attribute is an `enum` then you no longer need to provide the `enum` name. To override this functionality you can add the `@` symbol.
- Added code generation tests.
- Added `TagHelperDescriptorFactoryTest`s that double for Precompilation tests.

#196
2015-10-29 10:04:07 -07:00
Pavel Krymets 42d41a0049 Rename Microsoft.Runtime.Abstractions to Microsoft.Extensions.PlatformAbstractions 2015-10-22 18:43:18 -07:00
Doug Bunting 117bbe7f65 Rename `AppendEncoded()` to `AppendHtml()` and `SetContentEncoded()` to `SetHtmlContent()`
- aspnet/Mvc#3225, 2 of 3
- also correct parameter names
2015-10-22 16:49:37 -07:00
N. Taylor Mullen 6a7082d89e Move `DefaultTagHelperContent` from `Razor.Runtime.TagHelpers` to `Razor.TagHelpers`.
#578
2015-10-22 15:23:23 -07:00
N. Taylor Mullen 6d0b268440 Add `Init` method to `TagHelper`s.
- The init method allows multiple `TagHelper`s to inject data into the `context.Items` bag to properly function when running in unison with other `TagHelper`s that need to communicate with children.
- Transition `GetChildContentAsync` from `TagHelperContext` to `TagHelperOutput`.
- Move `TagHelperContext.GetChildContentAsync` tests to `TagHelperOutputTest`.
- Added `Init` test to ensure `TagHelperRunner` calls it in the correct order.

#571
2015-10-22 15:10:08 -07:00
N. Taylor Mullen b1ad14fd46 Rename `Microsoft.AspNet.Razor.Runtime.TagHelpers`.
- Changed non-user facing type names to `Microsoft.AspNet.Razor.TagHelpers`.
- Updated folder structure to reflect new namespaces.
- Updated generated code files to reflect new runtime type namespaces.

#578
2015-10-22 10:45:43 -07:00
N. Taylor Mullen bd2a98e5ec Rename `Microsoft.AspNet.Razor.TagHelpers`.
- Name changed to `Microsoft.AspNet.Razor.Compilation.TagHelpers`.
- Changed folder locations to reflect namespace change.

#578
2015-10-22 10:25:19 -07:00
N. Taylor Mullen deaf2dc828 Enable `TagHelper`s to properly flatten to enable partial parsing.
- `TagHelper`s used to not flatten correctly resulting in inconsistent start locations for `SyntaxTreeNode`s following/within `TagHelper`s.
- This change indirectly corrected bad indentation that existed in generated C#.
- Added a test to validate `TreesAreDifferent` returns expected behavior when modifying content inside of `TagHelper`.
- Added `TagHelperBlock` `Flatten` test.

#553
2015-10-16 15:57:37 -07:00
N. Taylor Mullen 2d4092ca32 Add line pragmas to dynamic attributes.
- This enables debugging and proper error reporting for dynamic attributes. Without the pragmas errors would showcase generated Razor C# instead of their corresponding .cshtml files.
- Did not have to do any `TagHelper` specific changes since they utilize the same core attribute rendering logic.
- Updated generated C# files for tests.

#569
2015-10-16 09:41:12 -07:00
N. Taylor Mullen ed617d17e9 Remove linemappings file. 2015-10-15 15:20:57 -07:00
Pranav K 11af72a9c6 Renaming Microsoft.Framework.* -> Microsoft.Extensions.* 2015-10-03 15:44:39 -07:00
Pranav K 3e8b7b607d Refactor WriteAttribute \ AddHtmlAttribute
Fixes #177
2015-09-30 16:12:10 -07:00
Ajay Bhargav Baaskaran bc103fcaa4 Fix: Index out of bounds for incomplete attribute value
- #555
- Added a unit and a code generation test
2015-09-30 14:51:43 -07:00
Ryan Nowak 9a41bafea7 Fix #526 - use extension methods for AppendFormat
These changes make TagHelperContent with the IHtmlBuilder pattern, but
retain the signatures returning TagHelperContent.

Removed a bunch of tests that are no redundant with tests for the
extension methods in HttpAbstractions. Kept a few explemars in place to
ensure that the basic plumbing functions as desired.
2015-09-27 22:47:23 -07:00
Pranav K e87f10e8f8 Change ITypeInfo.IsTagHelper to ITypeInfo.ImplementsInterface(ITypeInfo)
Fixes #511
2015-09-25 21:38:36 -07:00
N. Taylor Mullen d2a7a355cc Change `[RestrictChildren]` to allow non-`TagHelper` tags.
- Updated the `TagHelperParseTreeRewriter` loosen child restrictions to non-`TagHelper` HTML elements.
- Updated tests to showcase that non-`TagHelper` elements are allowed to be restricted.
- Added an additional test case to showcase sub-sub nesting of non-`TagHelper` restricted children.

#543
2015-09-25 16:27:48 -07:00
N. Taylor Mullen 816b1f4190 Update `Lookahead` method in `Tokenizer` to maintain its existing buffer.
- Added tests to verify correctness.

#527
2015-09-25 16:23:42 -07:00
N. Taylor Mullen 67739ea565 Add `ParentTag` to `[HtmlTargetElement]`.
- `ParentTag` allows `TagHelper`s to restrict where they apply based on their immediate parent tag.
- Changed the `TagHelperParseTreeRewriter` to understand non-`TagHelper` HTML elements to properly determine a parent tag when applying `TagHelperDescriptor.RequiredParent`. This change will also enable `[RestrictChildren]` to apply to more than just `TagHelper`s.
- Added tests to validate that partial and well formed tags properly discover `TagHelper`s. Also added tests that validate that descriptors are properly created based on `TagHelper` types.

#474
2015-09-24 10:30:36 -07:00
Ryan Nowak c9341ee3d7 React to removal of ToString on TagHelperContent
The code generator generates calls to ToString() on a TagHelperContent
when used with dynamic content inside an attribute that needs to be passed
to a TagHelper as a string.

This change updates the codegen to use GetContent(IHtmlEncoder)
2015-09-23 11:07:44 -07:00
Ryan Nowak 323befaaf1 Avoid GetContent and ToString in TagHelperContent tests 2015-09-22 21:28:59 -07:00
Ajay Bhargav Baaskaran 3f34add497 Removed support for regex type names in @addTagHelper and @removeTagHelper
- #426
- Updated tests to not use regex patterns
2015-09-22 17:48:59 -07:00
N. Taylor Mullen 7239eb015c Add support for data bound symbols as attribute names.
- Took the HTML5 spec approach of disallowing specific characters and accepting all others.
- Added several parser and code generation tests to cover both `TagHelper` and non-`TagHelper` variations of symbol bound attribute names.

#137
2015-09-22 16:12:37 -07:00
Pranav K 9c456965a6 ITypeInfo.FullName should return the same value as TypeInfo.FullName
Fixes #523
2015-09-21 17:00:35 -07:00
Pranav K 388362245f Making HashCodeCombiner usage non-fluent
React to https://github.com/aspnet/Common/issues/40
2015-09-21 14:46:07 -07:00
Ajay Bhargav Baaskaran 153ed57d66 [Fixes #472] Added temporary parse error for helper directive 2015-09-21 12:09:31 -07:00
N. Taylor Mullen 0253c563be Update tests to run correctly on stable mono. 2015-09-18 17:04:03 -07:00
Kiran Challa 392b7a3710 Reacting to Dnx runtime sources changes 2015-09-18 16:28:26 -07:00
N. Taylor Mullen c494cb344d Enable `TagHelper`s with `[RestrictChildren]` to log errors for no tag name tags when targeted by catch all.
#534
2015-09-18 15:41:58 -07:00
N. Taylor Mullen 635514453b Enable `TagHelper`s with `[RestrictChildren]` to log errors for no tag name tags.
- Added test cases for situations when tags have no names.

#534
2015-09-18 14:47:48 -07:00
N. Taylor Mullen 36450c978b Add support for `@tagHelperPrefix` and `[RestrictChildren]`.
- Added a test to validate prefixed `TagHelper`s can have children with `TagHelper` prefixes.

#532
2015-09-18 12:31:07 -07:00
N. Taylor Mullen fb6a08d5de Allow `TagHelper`s inside of text/html typed script tags.
- To limit the impact of the change ensured that we only do extra work in the case that we detect a script tag with a `type` attribute.
- The parsing changes include normal HTML parsing behaviors when we detect that a script tag has a `type` attribute with value `text/html`.
- Added unit and code generation tests to validate `text/html` script tag behavior.

#502
2015-09-17 21:14:40 -07:00
Pranav K 33a0f7a0db Replace NotNullAttribute with thrown exceptions 2015-09-16 22:06:25 -07:00
Pranav K 381c055e2f Removing NotNullAttribute from Microsoft.AspNet.Razor 2015-09-14 11:58:28 -07:00