Commit Graph

19 Commits

Author SHA1 Message Date
Pranav K a6d611aecd Introduce RazorCompilation 2017-02-22 10:22:18 -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 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
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
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 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
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 e2dd09c918 [Fixes #881] Added TagHelper IR support 2016-12-15 11:46:35 -08:00
N. Taylor Mullen 61b2b0d4e7 Add model for differentiating design time and runtime parsing.
- If needed, a phase/feature can always retrieve the syntax tree to lookup whether the parse tree was made in a "design time" fashion.
- Future DesignTime / Runtime specific bits will be added to their corresponding `AddRuntimeDefaults`/`AddDesignTimeDefaults` methods.
2016-12-14 12:39:25 -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 2db4985c21 Modify functions, section and inherits to use extensible directives.
- Removed existing type names used to track `@functions`, `@section` and `@inherits`.
- Updated parsing logic to reflect existing directive behaviors.
- Added additional IR and syntax tree pass in order to fulfill the default directive expectations.
- Updated tests to to expect new extensible directives parse structure.

#894
2016-12-14 11:12:40 -08:00
Ryan Nowak 46018f9512 Add IR phase
This change adds a phase which runs IR passes. Design and code are almost
exactly the same as the existing SyntaxTree phase. However all of this is
public because the IR is public API.
2016-11-29 21:28:27 -08:00
N. Taylor Mullen cf7489e600 Port WhiteSpaceRewriter and ConditionalAttributeCollapser.
- Add an `HtmlNodeOptimizationPass` that does all of the `RazorSyntaxTreeRewriting` that legacy used to achieve outside of `TagHelper`s.
- Add tests for `HtmlNodeOptimizationPass` to verify it's executing appropriate bits.

#849
2016-11-22 12:04:31 -08:00
Ryan Nowak d8b626c843 Implement IR lowering phase
This is a first cut of IR lowering and includes the basic node types and
some tests.
2016-11-22 11:25:23 -08:00
N. Taylor Mullen 6c8ef157b4 Add TagHelper binding abstractions.
- Added a TagHelperFeature to hold TagHelper specific pieces that can be replaced.
- Built a syntax tree pass that applies the ported TagHelper bits.
- Updated tests that expected different RazorEngine defaults.
- Added new tests to verify binder pass.
2016-11-21 11:04:42 -08:00
Ryan Nowak b74ea5d74e Fix failing tests 2016-11-16 14:06:02 -08:00
Ryan Nowak b341340d1f Add skeleton of syntax phases 2016-11-16 14:06:01 -08:00
Ryan Nowak 6b9b75841f Add Razor Evolution Engine and primitives 2016-11-16 14:05:58 -08:00