Commit Graph

34 Commits

Author SHA1 Message Date
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
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
Ajay Bhargav Baaskaran 7af2f6ff36 [Fixes #961] Disable instrumentation for TagHelper attribute values 2017-02-01 15:26:13 -08:00
Ajay Bhargav Baaskaran 406522d14b [Fixes #958] Added support for AddTagHelper, RemoveTagHelper and TagHelperPrefix directives 2017-01-30 15:40:05 -08:00
Ryan Nowak 93981ab13e Update codegen to be compatible with MVC 2017-01-27 16:47:33 -08:00
Ryan Nowak 2b2cf6efec Correct an issue with codegen for taghelperprefix
The issue here is that when a taghelper prefix is in use it will be
including in the HTML output, when it should be chopped off.

See the diff in the codegen for examples.
2017-01-27 11:13:46 -08:00
Ryan Nowak d187edbd76 Use the TagHelperBinder to dedupe taghelpers
This change does deduplication of taghelpers during the binding/rewriting
phase. This is needed when a taghelper has multiple sets of html
attributes that are required (behaves like an OR). This is used lots in
MVC.

The old codebase used to do this in the codegen phase, but it seems
beneficial to do as early as possible.
2017-01-26 15:36:42 -08:00
Ryan Nowak 0bf9abbedf Hardcoding the right value for MVC 2017-01-26 13:39:55 -08:00
Ryan Nowak 243446d225 Quick fix for MVC. Hardcoding fullname of HelperResult. 2017-01-26 10:37:52 -08:00
Ryan Nowak ec45d8ea8c Remove typeof from codegen
The C# codegen was using some of the new names for various TagHelper
constructs instead of the old namespace.

This change reverts to the old names.
2017-01-24 13:45:50 -08:00
Ryan Nowak 851dd7ba3b Add support for TagHelper directives
This commit adds support to the TagHelperBinderSyntaxTreePass to interpret
@addTagHelper, @removeTagHelper, and @tagHelperPrefix.

I also ported all the original tests for this feature and updated them to
call new APIs.

The bulk of the changes here were updates to baseline tests that weren't
correctly using @addTagHelper
2017-01-20 17:44:35 -08:00
Ryan Nowak 4a49ee2164 Adds support for imports to IR lowering
This change adds support for 'imports' - extra source files which contain
directives that can merged with 'main' source files. The purpose of course
is to support things like global usings or addTagHelpers, like
_ViewImports in MVC does today.

Instead of a one-off this is now a feature of the Razor langugage since
things like addTagHelper have an impact on the parsing behavior. Also,
having a standard imports concept keeps out feature creep, for instance
the 'global' usings we have today could really just be an import.

Imports allow single-line directives including the fundamental directives
like addTagHelper, using, and other friends. Code, content, and block
directives are not merged and will be ignored. We can consider making
these kinds of things warnings in the future.
2017-01-20 10:43:53 -08:00
Ryan Nowak a84f35022e Rename a test
Imports is something different, this is a test for usings.
2017-01-18 15:33:35 -08:00
Ajay Bhargav Baaskaran ffd455b77e Adds Instrumentation support
Instrumentation is added as an optional pass that can be configured by
MVC.
2017-01-11 17:27:52 -08:00
Ryan Nowak e072a7f452 Fix build break
These baselines needed to updated after changing the namespace
of this type.
2017-01-10 11:53:39 -08:00
Ajay Bhargav Baaskaran eb0a2a1833 [Fixes #915] Added TagHelper preallocated attribute optimization pass 2017-01-03 11:05:57 -08:00
Ryan Nowak e84bc66700 First cut of adding API sets
This change defines stages for IR processing. The comments in RazorIRPass
really explain the details. I've also made the preliminary changes to the
stuff we've built so far to follow the new conventions.

This is building towards multitargeting for Razor, being able to target
both Razor Pages and Razor MVC Views from the same engine, being able to
target different codegen and methods from within the same engine.
2016-12-30 17:58:39 -08:00
Ajay Bhargav Baaskaran 0dacf01f54 [Fixes #912] Added TagHelper design time code generation support 2016-12-28 15:22:07 -08:00
Ajay Bhargav Baaskaran 9dece91975 [Fixes #882] Added TagHelper runtime code generation support 2016-12-27 11:29:25 -08:00
N. Taylor Mullen f47a40a4a7 Add Razor design time code generation.
- Added a common csharp rendering phase base to put shared assets of runtime and design time code gen.
- Added a new `DesignTimeIRPass` to setup the IR bits to provide accurate intellisense.
- Added a `CodeGenerationIntegrationTest` and moved the RuntimeCodeGenerationTests into it. This way we can re-use the cshtml files and it makes searching/running the tests easy..
- Updated how line mappings are calculated for some nodes.

#848
2016-12-27 11:06:58 -08:00
Ajay Bhargav Baaskaran af499794c5 [Fixes #878] Removed marker nodes from IR
- Also fixed SourceMappings content length in Markup spans
2016-12-22 15:11:52 -08:00
N. Taylor Mullen c6150ba287 Move section support into IR.
- Previously we'd special case `@section` at code generation time; now we transform the directive into an IR node.
- Changed the expectations of `DefineSection` to not take in a section writer. It's now expected to modify what `Write`, `WriteLiteral` etc. write to when inside of the lambda. This is done today in TagHelpers via `StartTagHelperWritingScope`.
- Updated baseline files to reflect new `DefineSection` expectations.
- Updated IR tests since we no longer leave around `DirectiveIRNode`s.

#901
2016-12-22 14:39:25 -08:00
Ryan Nowak b473101927 Fix line endings 2016-12-20 08:56:18 -08:00
Ajay Bhargav Baaskaran e2dd09c918 [Fixes #881] Added TagHelper IR support 2016-12-15 11:46:35 -08:00
N. Taylor Mullen eb230e0408 Port existing CSharp code generation integration tests.
- Added code generation test infrastructure to validate ported tests.

#847
2016-12-14 11:18:31 -08:00
N. Taylor Mullen 5d4c4e1ccf Add Razor runtime code generation.
- Added TabSize,IsIndentingWithTabs and NamespaceImports to the RazorParser options. These are replacements for the existing RazorEngineHost abstraction.
- Added RazorParserOptions consumption pattern to more than just the parsing phase.
- Added a ChecksumIRNode to ensure Debugging can work.
- Updated tests to to react to new Checksum and Namespace nodes in the IR tree.
2016-12-14 11:18:30 -08:00
N. Taylor Mullen f09fd291a7 Make `HtmlContentIRNode` content newlines platform agnostic.
- Prior to this the platform that the newlines were escaped on would be the platform the baselines would pass on.
- Updated baselines to reflect new newline escaping.

#888
2016-12-08 10:59:52 -08:00
N. Taylor Mullen 2639fad8ab Transitioned SourceLocation => MappingLocation on IRNodes.
- Also modified the property name from `SourceLocation` => `SourceRange` to avoid ambiguity.
- Updated IR baselines
- Updated IR baseline infrastructure to conditionally render the document location.

#884
2016-12-08 10:18:28 -08:00
Ryan Nowak 026f9ffb69 Nodes that have children should use .Children
This removes special casing for nodes that contain children that were
hiding them in a .Content or .Value property.
2016-12-07 17:58:31 -08:00
Ryan Nowak 853c28e568 Add integration testing
This change adds a basic framework for doing baselined integration tests.
This is very similar to what we do elsewhere with generated files and
tests that read them from resources.

What's here now is the support to do this kind of baselining with IR in a
pretty readable serialization format.

This is a building block and the intent is that we'd do something similar
in the future for syntax nodes and C# source.

Looking at the code of the tests in particular, we'll also build the
ability to capture the documents at key points (such as before/after a
targeted phase) and then verify them in the same manner.
2016-12-06 11:25:04 -08:00
N. Taylor Mullen d06e5b6002 Add legacy parser 2016-11-16 14:06:00 -08:00