Commit Graph

510 Commits

Author SHA1 Message Date
Ryan Brandenburg a7eb30ddca Remove old razor 2017-03-17 14:58:13 -07:00
N. Taylor Mullen 8f9ff1abd9 Clean up TagHelperDescriptor APIs.
- Removed all design time descriptors and put their API surface into their corresponding descriptor. Part of removing the design time API surface was removing the tracking of `<Remarks>`, it wasn't used so there's on need to track it until we need it.
- Removed the Type requirement from `TagHelperDescriptor`. With this separation we'll be able to have abstract `TagHelper`s that aren't based on a class implementation.
- Removed Prefix from the `TagHelperDescriptor` API surface. It was a legacy requirement based on how the Razor parser was put together. We can work around this now.
- Stripped correlation information from the immediate `TagHelperDescriptor` API surface. Instead this information is now tracked in `TagMatchingRule`s. This change means that you will not have multiple `TagHelperDescriptor`s per `TagHelper`; instead it's all tracked in a single descriptor. A side effect of this change was the transformation of `IsIndexer` => 3 new properties.
- Renamed many descriptor types and property names.
- Added builder APIs to construct TagHelpers since they're inherently immutable in their API surface.
- Added `ITagHelperDescriptorBuilder` to represent `TagHelper`s that are built from an `ITagHelper` implementing class. It re-introduces the `TypeName` association of a `TagHelper`.
- Added `ITagHelperBoundAttributeDescriptorBuilder` to represent that an attribute was associated with a property.
- Added validation methods to the descriptor builders to enable consumers to validate the current state of the builder and add diagnostics as necessary.
- Moved descriptors away from RazorError.
- Updated the various comparers to understand the descriptors new API.
- Added a new `RazorDiagnosticFactory` abstraction to handle `RazorDiagnostic`s and their corresponding errors/ids etc. This new API should allow for easy addition of new `RazorDiagnostic` errors.
- Updated the `DefaultTagHelperDescriptorFactory` to construct `TagHelperDescriptor`s using the new builder APIs and in the new descriptor format (1 descriptor per type).
- Updated `ViewComponentTagHelperDescriptorFactory` to construct `TagHelperDescriptor`s with the builder API.
- With both factory implementations code was duplicated because the ViewComponent work will be moving outside of Razor once we have the proper hooks.
- Updated `TagHelper` binding bits to capture a binding result in order to query which rules appy to a given tag name.
Addressed feedback
- Update tests to react to new `TagHelperDescriptor` API.
- Remove case sensitive comparers and some cleanup
- Added TagHelperDescriptorJsonConverter, RazorDiagnosticJsonConverter and added serialization tests
2017-03-17 12:18:05 -07:00
Ryan Nowak 90b48347a5 Port the legacy RazorEditorParser 2017-03-16 12:47:29 -07:00
Nate McMaster 9b3e8d0cda React to aspnet/Testing#259 2017-03-16 09:31:55 -07:00
Nate McMaster 43a41398ac Unify dependency versions to one file 2017-03-15 16:44:00 -07:00
Ajay Bhargav Baaskaran 310ccc31d0 Include default imports when ImportsFileName is null 2017-03-14 19:33:18 -07:00
Pranav K 2fc88fe9c1 Add support for base path in FindHiearchicalItems
Required for https://github.com/aspnet/Mvc/issues/5915
2017-03-13 11:15:11 -07:00
Pranav K 7d43bfc709 Add RazorSourceDocument.Create(string template)
Add document and fix casing of RazorSourceDocument.FileName
Fixes #1063
2017-03-13 09:44:06 -07:00
Jass Bagga a418a175a9 Add TagName to TagHelperContext
Addresses #1065
2017-03-09 14:59:11 -08:00
Pranav K a034b2ed04 Collate diagnositcs from Imports 2017-03-08 18:29:17 -08:00
Ryan Nowak 871f9e43ca Update versions of VS and Roslyn 2.0.0 dependencies
VS has gone RTM so, updating to the RTM versions of those dependencies.

Roslyn does not publish our shim packages on NuGet.org, so updating those
to a non-ancient version for projects that use 2.0.0. The projects that
use 1.3.x are staying put for now.

The code change is dealing with something that was obsoleted.
2017-03-08 08:57:49 -08:00
Ryan Nowak 9a27405718 Add LanguageServices test project 2017-03-06 17:55:00 -08:00
Yves57 dee8d8694f Prevent LOH allocations when constructing large Razor Source Documents. (#1049)
* Prevent LOH allocations when constructing large Razor Source Documents.

* Feedback
2017-03-06 16:50:05 -08:00
Ryan Nowak cefca39510 Fix broken padding in design time
The padding calculation for C# expression wasn't taking into account the
` = ` so all of the padding values for expressions were off by 3.
2017-03-06 15:54:47 -08:00
Ryan Nowak 966cd4a68d Introducing BasicWriter and TagHelperWriter
These are the replacements for CSharpRenderingConventions
2017-03-06 13:12:57 -08:00
Ryan Nowak 7730d33482 Introducing DocumentWriter 2017-03-03 15:00:09 -08:00
Ajay Bhargav Baaskaran d422e61c3e Make CSharpRenderingContext and friends public 2017-02-28 19:04:51 -08:00
Pranav K 27e66c3750 Add tests for RazorPageGenerator 2017-02-28 14:15:52 -08:00
Pranav K 12a502d775 Move FileSystemRazorProject into Razor.Evolution
Add tests
2017-02-28 14:15:52 -08:00
Pranav K a6d611aecd Introduce RazorCompilation 2017-02-22 10:22:18 -08:00
Ajay Bhargav Baaskaran cb5b8a45f1 [Fixes #959] Generate LineMapping for Using statements with source
- Also generate/test IR baselines with all code generation tests
2017-02-21 16:51:05 -08:00
Ryan Nowak c76ae277a3 Add baselines for codegen tests
This will make is much easier to investigate failures that bubble up to
the codegen level. You'll be able to see if there was a change to the IR
rather than just the final code.
2017-02-17 16:41:46 -08:00
Ryan Nowak 1ae0b21630 Replace CSharpIRToken with RazorIRToken
Deletes CSharpIRToken to use the more general RazorIRToken class.

Rather than using the visitor to visit tokens, now writing a
CSharpExpresionIRNode is an 'atom', and will write its tokens itself.
2017-02-17 16:27:31 -08:00
Ajay Bhargav Baaskaran ed9068cef4 Replace RazorError with RazorDiagnostics in public API 2017-02-17 15:44:37 -08:00
Ryan Nowak 965ae5490f Introducing RazorIRToken
This IR node will be part of the new token model for IR. It will be used
by all nodes that contain user content. Going forward, tokens will be the
thing that contains text and produces line mappings.

This commit just introduces the class.
2017-02-17 11:22:53 -08:00
Pranav K 075771a12d Re-enable netcoreapp1.1 tests (part 2) 2017-02-16 15:29:31 -08:00
Pranav K cfa4689d47 Re-enable netcoreapp1.1 tests
Fixes #1003
2017-02-16 14:09:12 -08:00
Ryan Nowak e35ee53ee5 DefaultRazorIRLoweringPhase is too agressive
This change fixes a bug where DefaultRazorIRLoweringPhase is too
aggressive in merging HTML spans. You can hit the bug by delimiting two
html spans with a metacode character like:

<foo>@{ <bar/> }</foo>

The lowering phase will combine these HTML nodes, which is invalid as they
don't have contiguous spans.

The change here is to merge spans only when they both have an invalid
location or are contiguous.
2017-02-16 10:53:09 -08:00
Ryan Nowak 7a1a6dd1d6 Part 2 of RuntimeTarget
Introducing ExtensionIRNode and an implementation of templates based on
the new feature set.

Now TemplateIRNode is-a ExtensionIRNode. It's implemented using just
extensibility and isn't part of the standard razor codegen. I'm adding it
to the RazorEngine so that it's still there by default.

I've also included a pattern for visitors to special case
ExtensionIRNode-derived classes that they know about. This requires a
little bit of boilerplate but makes it easy to traverse just the nodes you
care about while keeping the set of nodes open.

For now the general codegen feature still hasn't had a refactor, but this
opens things up for us to start finishing things like MVC's @inject
directive.
2017-02-15 18:08:19 -08:00
Ajay Bhargav Baaskaran 4b2245eeb9 [Fixes #924] Correct RightShiftAssign operator 2017-02-15 16:31:40 -08:00
Nate McMaster 4fd441ae35 Temporarily disable tests on .NET Core that rely on .NET Core 2.0 API 2017-02-15 10:04:59 -08:00
Nate McMaster 279855d947
Downgrade to stable packages 2017-02-14 16:15:35 -08:00
Ajay Bhargav Baaskaran 8ac5468714 Refactor IR phases
- Added DirectiveRemovalIRPass
 - Added IRazorDocumentClassifierPhase, IRazorDirectiveClassifierPhase and
   IRazorIROptimizationPhase
 - Added all the related passes and default implementations
 - Refactored DefaultDirectiveIRPass to do the right thing
 - Execute method in IR passes now return void
 - Added tests for the new phases
2017-02-14 14:51:36 -08:00
Pranav K 80172c641d Fix building the vsix inside VS 2017-02-14 12:55:43 -08:00
Doug Bunting 4861ef3391 Bump test projects up to .NET 4.5.2
- aspnet/Testing#248
- xUnit no longer supports .NET 4.5.1
- build tests for desktop .NET only on Windows
2017-02-14 08:48:29 -08:00
Ryan Nowak 0dbf62196c Introduces RuntimeTarget and abstraction for APIs
This is a new abstraction that represents the api surface available for
codegen to target. Every kind of document should have an associated
RuntimeTarget or just use the default.

To prevent breakage, our DocumentClassifierBase class will provide a
default API set to implementors (like MVC).

I haven't fundamentally changed how codegen is done yet, I've just hidden
it behind a new abstraction. The RuntimeTarget now is also responsible for
selecting between design time and runtime.

The bulk of the noise here is from splitting a lot of the codegen stuff
into its own files.
2017-02-13 15:34:51 -08:00
N. Taylor Mullen f861c23d1f Allow RazorSourceDocument to consume empty streams.
- Added tests to validate how encoding flows when used with empty streams in addition to their usability (not throwing).

#947
2017-02-13 12:11:38 -08:00
Ryan Nowak 62420209a5 Fix a failing test 2017-02-09 16:19:34 -08:00
Ryan Nowak ea778b9b6d Implement a simple base for document classifiers
This should allow us to de-dupe a lot of code in MVC.
2017-02-09 15:22:33 -08:00
Ajay Bhargav Baaskaran 260b869a07 Remove DirectiveIRNode from the IR document after the default directive classifier has run 2017-02-09 12:56:58 -08:00
Ajay Bhargav Baaskaran 02675da467 Handle single line directives properly 2017-02-08 13:41:27 -08:00
Pranav K d293547f24 Adding more tests 2017-02-08 11:17:43 -08:00
Pranav K 8b764c57e4 Parse string directive tokens correctly 2017-02-08 11:17:43 -08:00
Pranav K 2eba53de1b Add support for optional directives 2017-02-07 19:20:49 -08:00
Ajay Bhargav Baaskaran adf18d4810 Make LineMapping public 2017-02-03 15:50:34 -08:00
N. Taylor Mullen 3f5d1bb2d6 Remove literal directive tokens.
- Literal directive tokens acted as a way for a user to provide markup bits to be required when parsing a directive.
- Removed source implementations.
- Removed tests validating the feature.

#969
2017-02-03 12:02:16 -08:00
Pranav K a801a49377 Add an API to RazorProject to navigate hierarchical files
Fixes #962
2017-02-03 11:25:15 -08:00
N. Taylor Mullen c49d7b8c27 Add support for new style Roslyn dotless commits.
- Roslyn swapped the way they performed dotless commit insertions. They went from:
date => date. => DateTime.  to
date => date. => date => DateTime => DateTime.
The problem with the new approach is that date => DateTime would be rejected and therefore force the editor to reparse and reclassify any dots as HTML giving improper IntelliSense.
- Updated Razor implicit expression edit handling to allow identifier => identifier replacements as long as the identifiers didn't result in keyword or directives.
- Added tests to verify the scenarios impacted.
2017-02-01 15:43:08 -08:00
Ajay Bhargav Baaskaran 7af2f6ff36 [Fixes #961] Disable instrumentation for TagHelper attribute values 2017-02-01 15:26:13 -08:00
Ryan Nowak e549270b4a Add RazorDiagnostic type
This is a replacement for RazorError, is conceptually equivalent with
Diagnostic from Roslyn.

The next PR will start exposing this through our public API rather than
the legacy type.
2017-01-31 15:53:22 -08:00