Commit Graph

133 Commits

Author SHA1 Message Date
Doug Bunting cef0971d3e `throw new ArgumentNullException(...)` -> `[NotNull]`
- add `[NotNull]` in some `public` or `protected` callers as well
- add `[NotNull]` in `SeekableTextReader` constructors
- add `where TSymbolType : struct` to replace incorrect `null` checks
- remove `T` type parameters in changed files e.g. change to `TWriter`
- remove tests of removed code

nits:
- change `TextReaderExtensions` to consistently call other extensions as statics
- wrap some long doc comments
2015-05-06 14:21:05 -07:00
Doug Bunting 42552c982d Quick fix: Remove project.json warning
- `resources` -> `resource`

Example warning during `dnu build --quiet`:
```
...\test\Microsoft.AspNet.Razor.Test\project.json(3,34): warning: Property "resources" is deprecated. It is replaced by "resource".
```
Primarily resulted in VS Error List noise. Above does not normally show up in
`build.cmd` runs because `dnx . test` does not show build warnings.
2015-05-05 16:07:24 -07:00
N. Taylor Mullen e5e4a22966 Update LICENSE.txt and license header on files. 2015-05-01 13:58:52 -07:00
N. Taylor Mullen e3fdb8886a Add Multiple attribute same name understanding to TagHelperChunk.
- This also involved adding understanding to CSharpTagHelperCodeRenderer.
- When rebasing this commit was lost as part of: 7c604d2b11 .

#279
2015-04-30 14:57:23 -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 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 dcee0d2ff7 Add tests for ReadOnlyTagHelperAttributes and TagHelperAttributes.
#279
2015-04-27 12:06:08 -07:00
Pranav K dc4ee8b915 * Adding FilePath to SourceLocation
* Using SourceLocation.FilePath when printing line pragmas, if available.
2015-04-16 15:08:36 -07:00
N. Taylor Mullen fedd53aab8 Update Razor directives to format correctly when entering newline.
- Existing Razor directives layout, inherits, addTagHelper, tagHelperPrefix and removeTagHelper should only ever span a single line and need to cause a re-parse when a newline is entered during design time. To do this modified their AcceptedCharacters to accept anything other than newline rather than anything.
- Updated existing tests to now expect AcceptedCharacters.AnyExceptNewLine when directives are present.
- This change also enables the model directive in Mvc since it also uses the inherit directives core parsing.

#332
2015-04-15 11:32:47 -07:00
N. Taylor Mullen 9722319762 Refactor some pieces of Razor.
- String => string
- Updated RazorTemplateEngine to have better spacing.
2015-04-12 16:49:04 -07:00
Victor Hurdugaci 7e5387e7ab Update resource names 2015-04-08 15:09: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
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
N. Taylor Mullen 1ac518d9cb Remove RazorDirectiveAttribute and related tests.
- These were not used.

#344
2015-04-03 12:19:50 -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
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 05eb00b258 Update RazorError to be deserialized.
- Added tests to ensure RazorError can be serialized/deserialized.

#330
2015-03-23 15:25:52 -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
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
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 e14dbdf9be Add parser error for empty TagHelper bound attributes.
- Errors are only created for TagHelper bound attributes that are not bound to string.
- Added tests to validate proper errors for expected input.

#289
2015-02-13 12:10:50 -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
Doug Bunting 7b8126367c Minor: `LineMapping` and `MappingLocation` debug visualizations were types' full names
- add `ToString()` overrides for these classes

Nits:
- improve assertion failures about code mapping mismatches
- add `GENERATE_BASELINES` reminder to test project.json
2015-01-15 16:32:06 -08:00
Doug Bunting 26afdbd889 Plumb `ParserErrorSink` through to `CodeBuilderContext`
- precursor for #129
- remove unused `GeneratorResults` ctor to avoid duplicating `ParserResults` code

nit: make a few `ParserResults` properties immutable
- also change `ParserErrors` type to `IEnumerable<RazorError>`
2015-01-15 16:31:33 -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
Ajay Bhargav Baaskaran ff3ddfcc53 removed SessionState directive 2014-12-29 14:56:20 -08:00
N. Taylor Mullen e30e74dc5a Handle unclosed and invalid structure HTML tags for TagHelpers.
- Added detection of unclosed tags (tags without begin/end).
- Added recovery of potentially unclosed tags.
- Added detection of invalid structure tags (tags that do not end with '>').
- Modified detection of bad attribute values to be parse errors instead of runtime errors.
- Modified RazorParser to sort errors. This made writing tests more intuitive and ultimately ensures that the editor shows errors in the correct order.
- Added tests to validate invalid tag structure.
- Added tests to validate invalid attributes.
- Added tests to validate unclosed tags.

#104
2014-12-22 14:28:35 -08:00
N. Taylor Mullen a86b0dca3e Add line mappings to project TagHelper attribute values.
- We now create LineMappings for instances where a TagHelper's attribute value is not of a string type.
- This will enable the Razor editor to create projections from .cshtml => .cs for TagHelper attributes.
- Modified the TagHelperCodeGenerator and TagHelperBlockBuiler to accurately track the attribute values start locations so it could flow into code generation.
- Modified existing tests to account for the new line mappings.

#207
2014-12-19 17:26:33 -08:00