Commit Graph

215 Commits

Author SHA1 Message Date
sornaks 168fcbb9c1 Replacing BufferedEntryCollection with BufferedHtmlContent so any IHtmlContent can be added to a TagHelperContent.
- Introducing a new logic to calculate IsEmpty/IsWhitespace.
- Making Buffer private in DefaultTagHelperContent.
- Making SetContent non-abstract.
2015-08-10 14:54:10 -07:00
N. Taylor Mullen 4604c807c4 Add ability for unbound complex `TagHelper` attributes to flow through MVC attribute resolution system.
- Today MVC has specific rules about resolving Razor attribute values. Ex: `true` => attribute name being used as attribute value. This change ensures that unbound complex `TagHelper` attribute use that same logic.
- Added configuration to `GeneratedTagHelperContext` for `AddHtmlAttributeValues`.
- Had to be careful with code generating `AddHtmlAttributeValues`. In the case of `data-`; they can appear as complex attributes but may not contain any pieces that are `DynamicAttributeBlockChunk`s. Had to protect against this scenario.
- Updated existing test files.
- Added a new code gen test case to showcase the various use-cases of unbound dynamic `TagHelper` attributes.

#247
2015-08-10 11:29:22 -07:00
Troy Dai fa9f2ace5f Update CoreCLR versions 2015-08-04 10:15:31 -07:00
N. Taylor Mullen 48a6b567d6 Remove ~/ handling from core Razor.
- Removed parsing, chunk generation and code generation.
- Removed related tests.
- Did not modify existing unrelated tests with ~/ since it's just plain text and may be valid for end-users.

#427
2015-07-31 15:55:29 -07:00
N. Taylor Mullen a8fd85db1e Add ability to execute child content more than once.
- Added a boolean overload that specifies whether the user wants to retrieve cached content.
- Added tests to validate `TagHelperExecutionContext` `GetChildContentAsync` and that `TagHelperContext` passes the appropriate values through.

#459
2015-07-31 15:23:49 -07:00
N. Taylor Mullen 3b5692a5a5 Removed extra IVT from `Microsoft.AspNet.Razor`.
- Added tests to validate `IsStringProperty` on `TagHelperAttributeDescriptor`s.

#464
2015-07-28 14:58:59 -07:00
N. Taylor Mullen e722f90481 Transition `HashCodeCombiner` to use the `aspnet/Common` variation.
- Updated `LocationTagged<TValue>` to handle `null` implicit values.
- Removed `InternalsVisibleTo` declaration on `Microsoft.AspNet.Razor` to the runtime test project.
- Updated `TagHelperDescriptor` tests to utilize helper methods to construct `TagHelperDescriptor`s. This was needed since the `InternalsVisibleTo` declaration was removed.

#449
2015-07-28 10:45:08 -07:00
N. Taylor Mullen 4d0821f953 Transition Razor test comparers to new project.
- Changed namespaces for test comparers.

#461
2015-07-28 10:38:09 -07:00
N. Taylor Mullen a66490c012 Format runtime tests project.json. 2015-07-27 12:03:06 -07:00
N. Taylor Mullen 3ab6f56284 Fix `DesignTimeDescriptorFactory.CreateDescriptor` call to properly retrieve type from `TypeInfo`.
- Added `TagHelperDescriptorFactory` level tests to validate correct information is being pased to the `TagHelperDesignTimeDescriptorFactory`.

#457
2015-07-24 15:07:07 -07:00
N. Taylor Mullen c87dd8d9de Fix EditorBrowsableAttribute detection to apply to individual attributes.
- Prior to this change we'd return early and not generate any found descriptors if ANY property on a `TagHelper` had editor browsable never.
- This issue was hidden from tests due to us using the wrong comparer. Updated the comparer and failures occurred without the `TagHelperDescriptorFactory` change (yay).

#454
2015-07-23 15:26:46 -07:00
N. Taylor Mullen b762830a43 Consume `EditorBrowsableAttribute` on `TagHelper`s.
- Changed `TagHelperDescriptorFactory` to not create individual descriptors when `EditorBrowsableAttribute` is present and set to `EditorBrowsableState.Never`.
- Added tests to validate the `TagHelperDescriptorFactory` creates the attribute correctly.
- Did not look down the inheritance chain for `EditorBrowsableAttribute` because `TargetElement` is not inherited.

#447
2015-07-16 14:49:09 -07:00
sornaks ec5d1b4f4a Merge branch 'htmlcontentpart1' into dev 2015-07-10 15:45:48 -07:00
sornaks 6a7cd0f490 Making TagHelperContent implement IHtmlContent. 2015-07-10 15:44:22 -07:00
N. Taylor Mullen 2031a73918 Normalize tests project.json formatting. 2015-07-10 15:40:03 -07:00
N. Taylor Mullen c9c07bd393 Update test project.json to not depend on Moq for CoreCLR. 2015-07-10 15:38:37 -07:00
Doug Bunting 69d8e52bf9 Add support for get-only indexer properties
- #399
- move invalid `HtmlAttributeNameAttribute.Name` checking to `TagHelperDescriptorFactory`
- add a few new error cases
 - but does not cover all the new error cases e.g. `[HtmlAttributeName(...)]` on a get-only `int` property

nit:
- `resx` target removed some older resources from `RazorResources.Designer.cs`
2015-06-30 23:03:10 -07:00
Sornakumar Sundararajan 1f480386f4 Making CreateCodeWriter protected so that it can be overridden in Mvc. 2015-06-30 14:51:23 -07:00
N. Taylor Mullen 85be731e2b Add OutputElementHintAttribute to control design time IntelliSense for 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
2015-06-30 12:13:04 -07:00
N. Taylor Mullen eda9edc41d Fix Travis-CI.
- Added platform specific path handling to the TagHelperUsageDescriptorFactoryTests.
2015-06-29 17:17:13 -07:00
Doug Bunting 308eddc095 Quick fix: Do not check a platform-specific message 2015-06-25 15:56:21 -07:00
N. Taylor Mullen 9055da1894 Add tests to validate creation of TagHelperUsageDescriptors.
- Could not add tests to validate the full TagHelperDescriptorFactory.CreateDescriptors => TagHelperUsageDescriptors due to how the runtime loads assemblies (does it in memory without XML).
- Added serialization tests to include TagHelperUsageDescriptors.
- Updated existing tests to use new TagHelperDescriptor/TagHelperAttributeDescriptor constructors.

#352
2015-06-25 15:10:38 -07:00
N. Taylor Mullen 0bb9457fd9 Change duplicate TagHelper bound attributes to flow to output.
- Duplicate TagHelper bound attributes used to be ignored entirely; they now flow to the output as if they were unbound.
- Added code generation test to verify duplicate attributes. Added runtime and design time versions.
- Updated existing tests that happened to have duplicate bound attributes.

#418
2015-06-25 11:11:04 -07:00
N. Taylor Mullen 039062c5eb Fix C# design time projections for complex TagHelper attributes.
- TagHelper attributes that have expressions intermingled within them (resulting in Block elements) resulted in Spans in the attribute being falsely marked as SpanKind.Markup.
- Updated tests to account for new SpanKind.Code behavior.
- Added complex scenario to validate SpanKind.Code is flowed through to surround attributes.

#387
2015-06-25 10:27:03 -07:00
N. Taylor Mullen ddbd603653 Enable instrumentation for TagHelpers.
- Removed old code that disabled instrumentation for TagHelper bodies. Instrumentation will throw out sections for begin/end context that don't make it to the final output.
- Added instrumentation around WriteTagHelperAsync. Any content inside of the TagHelper will get sub-mapped via begin/end context.
- Hand verified BasicTagHelpers.cs begin/end context tests to ensure correctness.

#172
2015-06-10 12:52:25 -07:00
N. Taylor Mullen a1df1702e5 Add support for C# 6 exception filters.
- Added new handling of the C# try catch statement to allow exception filters after catch statements.
- Added tests to validate valid and invalid scenarios.

#402
2015-06-10 10:08:10 -07:00
N. Taylor Mullen 619cbc3716 Refactored several tests from TagHelperParseTreeRewriterTest into TagHelperBlockRewriterTest.
- Split the tests into their corresponding impact areas. We were testing a lot of bits that were not specific to the TagHelperParseTreeRewriter in its corresponding tests.

#370
2015-06-08 14:52:01 -07:00
N. Taylor Mullen b0b4ac4f3f Enable TagHelper attributes to render in the order they were originally.
- This was accomplished by changing when/how TagHelper attributes are rendered. Previously they were rendered: Bound => Unbound. Now they're rendered in the order that they exist on the TagHelperChunk.
- Regenerated test files to account for new re-ordering of TagHelper attributes.
- Added duplicate, unbound HTML attribute, unminimized same name test to ComplexTagHelpers.
- Did not add additional tests (other than the one noted above) since the current tests seem to be heavily impacted by the re-organization of code rendering; effectively showcasing the fix.

#225
2015-06-04 15:32:45 -07:00
Doug Bunting 113d80c6f5 Ensure `CodeVisitor`s consistenctly find tag helpers
- #412
- fix `CSharpTagHelperRunnerInitializationVisitor` and `CSharpUsingVisitor`
- fix existing test of the tag helper in a section scenario
2015-06-01 09:03:09 -07:00
Doug Bunting d545f47fe4 Avoid errors when generating baselines
- ignore missing expected output resources in this mode
- update `BaselineWriter` to avoid `IOException`s (file access issues)
 - serialize file operations
 - one file handle per file
- repeatedly `rm TestFiles/CodeGenerator/Output/*; `dnx . test`; no errors

also
- add generation of design-time line mappings
- fix ChunkGenerator -> CodeGenerator typo in path names
- update files only if they have changed
 - new `TestFiles.Exists()` method to support this check
- do not check results in `CSharpCodeBuilderTests` if `GENERATE_BASELINES` set

nits:
- update BOM in CodeBlockWithTextElement.cs to avoid future `git diff`s
- use more `var` and improve variable names in `TestFile`
- wrap long lines
2015-06-01 08:42:23 -07:00
N. Taylor Mullen 3ba92523ff Remove special casing of '*' in TagHelperDescriptorProvider.
- Requesting a '*' tagName from the TagHelperDescriptorProvider could only happen if a user was directly calling into it (extremely unlikely). Therefore I've removed the special casing to make the logic more simple.
- Removed tests that expected this behavior.

#324
2015-05-29 15:06:14 -07:00
N. Taylor Mullen ed92b6992d Addressed code review comments. 2015-05-29 12:50:01 -07:00
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
N. Taylor Mullen 0e61b49881 Add support for '*' at the end of required attributes.
- [TargetElement(Attributes ="prefix-*")] is now supported.
- Added '*' to the list of invalid non whitespace characters in TagHelperDescriptorFactory.
- Modified TagHelperDescriptorProvider to respect suffixed wildcards in TagHelperAttributeDescriptor.Attributes.
- Added tests to validate wildcard required attributes

#361
2015-05-21 15:01:32 -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
Doug Bunting 0e296283f9 Address a round of nits
- clean up trailing curly braces (Java style)
 - affected lots of files touched for #89 fix
- a couple of trailing whitespace removals
2015-05-19 17:39:26 -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 407a2ceae6 Remove unneeded NamespaceKeywordLength from AddImportCodeGenerator.
- This was completely unused outside of the AddImportCodeGenerator.
2015-05-18 17:21:50 -07:00
Doug Bunting 94f2f904b3 Add `[HtmlAttributeName(..., DictionaryAttributePrefix="prefix")]` part II
- relates to #89 because that changes `string` property checks and needs this refactor
- determine `string`-ness when creating `TagHelperAttributeDescriptor`s
 - add `TagHelperAttributeDescriptor.IsStringProperty` (set in constructor)
 - avoid repeated `string` comparisons and be more explicit
- change `TagHelperBlockRewriter` to centralize more of the `string`-ness determination
 - also add `TryParseResult` DTO, avoiding multiple `out` parameters
- refactor `CSharpTagHelperCodeRenderer` to allow reuse of core attribute value rendering
- test all of it
 - add `TagHelperDescriptorTest` to confirm serialization / deserialization

minor:
- fix `TagHelperBlockRewriter.TryParseBlock()` end quote removal when tag is malformed

nits:
- remove dangling mention of fixed bug #220
- make recently-added `TagHelperBlockRewriterTest` tests realistic
 - multiple `TagHelperDescriptor`s for same tag helper have identical `Attributes`
2015-05-15 23:17:52 -07:00
Ajay Bhargav Baaskaran 2fe78d70db [Fixes #217] Applying error squiggly to full directive 2015-05-15 12:26:21 -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
Pranav K 7d8f5d7b84 Revert "Reacting to updated CoreCLR packages"
This reverts commit f180bd9900.
2015-05-15 12:19:37 -07:00
Pranav K f180bd9900 Reacting to updated CoreCLR packages 2015-05-15 08:59:23 -07:00
Doug Bunting 70486710ea Quick fix: Add `System.Runtime.Serialization.Primitives` dependency
- tests failing
- root cause is likely similar to reason MVC Core has same dependency
 - something must have changed in the framework packages without manifest fixes
2015-05-14 10:47:39 -07:00
Ajay Bhargav Baaskaran 7bd338fc4a [Fixes #266] Maintain HTML provided case for TagHelper attributes 2015-05-13 15:27:38 -07:00