Commit Graph

83 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
Troy Dai fa9f2ace5f Update CoreCLR versions 2015-08-04 10:15:31 -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 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 6a7cd0f490 Making TagHelperContent implement IHtmlContent. 2015-07-10 15:44:22 -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
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 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
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
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
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
Doug Bunting 294fb5c3cd Quick fix: Missed `null` checks in 7dc0508 2015-05-11 22:12:28 -07:00
Doug Bunting 7dc0508c03 Add `[HtmlAttributeName(..., DictionaryAttributePrefix="prefix")]` part 1
- related to #89 because we need more descriptor comparers in more places
- separate `TagHelperAttributeDescriptorComparer` and `TypeBasedTagHelperDescriptorComparer`
 - encourages reuse and most will soon be used in multiple classes
- add `null` checks to `EquivalenceComparer`
 - also give parameters better names

nits:
- use `<inheritdoc/>` in `TagHelperDescriptorComparer`
 - also give it an explicit constructor
- make product comparers easier to subclass
 - base test `CaseSensitiveTagHelperAttributeDescriptorComparer` on product code
2015-05-10 22:15:29 -07:00
N. Taylor Mullen e5e4a22966 Update LICENSE.txt and license header on files. 2015-05-01 13:58:52 -07:00
Doug Bunting 6384977e96 Improve `GetHashCode()` implementations and their consistency with `Equals()`
- #362 and more
- make a few more properties immutable
 - in a few cases, just remove `private` setters
 - in others, adjust consuming code to handle the changes
- make `Equals()` commutative
 - use `GetType() == obj.GetType()` if necessary
- use only immutable values in `GetHashCode()` calculations
 - avoid `object.GetHashCode()`; that calculates hash of reference
 - add warnings about `RazorError` property setters but use properties
 - BUT lack of immutable values leads to some static `GetHashCode()` calculations
- correct important typo in `TagHelperDescriptorComparer`
- ensure `Equals()` does not `throw` an NRE e.g. in `LineMapping`
- add `SyntaxTreeNode.GetEquivalenceHash()`
- make `SourceLocation.Equals()` and `SourceLocation.CompareTo()` consistent

Update affected tests
- code generators and edit handlers less likely to be equal; adjust expectations

Add lots of tests
- not for all updated classes but enough to see impact of odd choices

nits:
- remove some `Equals()` and `GetHashCode()` overrides in `SpanCodeGenerator` subclasses
 - no longer unique
- remove redundant null checks e.g. when also done in `base.Equals()`
- add `StringComparer.Ordinal` if `StringComparison.Ordinal` used in `Equals()`
- make some `CSharpLineMappingWriter` fields `readonly`
- remove unused `LineMapping` constructor
2015-04-28 20:35:04 -07:00
Doug Bunting 1111405786 Remove extra `[NotNull]` definition and second AssemblyInfo.cs file
- add necessary build-time dependency
- add missing `using Microsoft.Framework.Internal;` statements
- remove `[NotNull]` from tests
 - avoid duplicate definitions of `[NotNull]` from referenced projects
- remove incorrect NotNullArgument.cs and second AssemblyInfo.cs files entirely
 - merge content into AssemblyInfo.cs file in expected location

nit: clean up some trailing whitespace
2015-04-28 15:56:31 -07:00
N. Taylor Mullen dcee0d2ff7 Add tests for ReadOnlyTagHelperAttributes and TagHelperAttributes.
#279
2015-04-27 12:06:08 -07:00
Doug Bunting de95f67400 Add `HtmlAttributeNotBoundAttribute`
- #182
- ignore otherwise-bound (i.e. `public`) properties in tag helpers

nits:
- add more `TagHelperDescriptorFactory` tests e.g. of `internal` properties
- remove `private` setter from `HtmlAttributeNameAttribute`
- use `null` propagation to shorten `IsAccessibleProperty` expression
- clean up some trailing whitespace
2015-04-24 22:57:41 -07:00
N. Taylor Mullen 5bcda94b2c Create error when TagHelper binds to HTML attribute starting w/ data-.
- Added TagHelperDescriptorFactory tests to validate TagHelperAttributeDescriptor creation.

#342
2015-04-15 11:24:08 -07:00
N. Taylor Mullen c9c8e802a7 Add PreElement and PostElement to TagHelperOutput.
- These two new properties will enable TagHelper authors to render content before and after the TagHelper's HTML element.
- Added tests to correspond with existing test coverage.
- Modified existing tests to double check for TagHelperOutput.Pre/PostElement.
- Refactored all DefaultTagHelperContent pieces of TagHelperOutput to be get only properties.

#341
2015-04-14 11:49:10 -07:00
Doug Bunting 3f7c75e299 Remove and sort `using`s; reacting to #320 change
- automated pass then restore any `using`s the compiler needs
- in a couple of cases, make `using` conditional
2015-04-07 17:08:09 -07:00
Doug Bunting e469b26b45 Rationalize some names and namespaces
- #320
- `ParserErrorSink` -> `ErrorSink`
- move `ErrorSink`, `RazorError`, and `SourceLocation` to root namespace
- move `RazorErrorTest` and `SourceLocationTest` to root test namespace
2015-04-07 17:08:03 -07:00
sornaks 585002baf8 Issue #2123 - Adding AppendFormat to TagHelperContent. 2015-04-07 08:31:25 -07:00
Doug Bunting 261dd108fd Merge remote-tracking branch 'origin/release' into dev 2015-04-03 12:09:04 -07:00
Doug Bunting 01aa492b7e Add a few more `<Service/>` items 2015-04-02 22:57:40 -07:00
Doug Bunting 076d4736ab Update .xproj files for Microsoft.Web.AspNet.* -> Microsoft.DNX.* rename 2015-04-02 13:49:28 -07:00
N. Taylor Mullen 3c622cb8ef Fix theory based test for Mono. 2015-04-01 20:06:46 -07:00
N. Taylor Mullen be4fb7649f Fix reflected attribute ordering in tests for Mono build.
https://github.com/davidfowl/MonoBugs/issues/3
2015-04-01 19:52:56 -07:00
N. Taylor Mullen 37a90af7d0 Fix mono build. 2015-04-01 19:13:34 -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
Ryan Nowak 444ea25b44 Fix build break in razor tests
This message changed because we got a fix in CoreCLR for a bug in the
host that was impacting Type.GetType and breaking data contract
serializer.
2015-03-20 19:27:26 -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
sornaks 7daec14e49 Issue #318: Removing Generate*() methods. 2015-03-17 13:15:03 -07:00
N. Taylor Mullen c844314ee6 Updated xunit.runner.kre => xunit.runner.aspnet 2015-03-12 15:54:39 -07:00
N. Taylor Mullen 0196df4081 Update .kproj => .xproj. 2015-03-11 14:03:14 -07:00
N. Taylor Mullen 080ef6343c Remove BOM from project.json, *.cmd, *.sh and *.shade files. 2015-03-09 12:58:07 -07:00
N. Taylor Mullen 04276b5ddf Update aspnet50/aspnetcore50 => dnx451/dnxcore50. 2015-03-08 12:54:58 -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
N. Taylor Mullen 677df32160 Add tests to validate TagHelperExecutionContexts Items bag.
- Added TagHelperScopeManager tests to ensure that the Items bag is correctly wrapped.
- Added test to TagHelperExecutionContext to make sure items bags are properly propogated.
- Updated existing unit tests to abide by the new constructor format of TagHelperScopeManager, TagHelperContext and TagHelperExecutionContext

#238
2015-02-22 19:13:18 -08:00