Commit Graph

475 Commits

Author SHA1 Message Date
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
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
Ajay Bhargav Baaskaran 98d5d1c70e Flow parser errors over to the CSharpDocument 2017-01-26 15:32:03 -08:00
Ryan Nowak 0bf9abbedf Hardcoding the right value for MVC 2017-01-26 13:39:55 -08:00
Ryan Nowak 6a95002f0e Fix lowering of taghelpers inside a section
The IR lowering phase was attaching the 'tag helper fields' node to the
builder instead of to the top-level node (document). This meant that
things wouldn't be where we expect when the first tag helper occurrence is
inside a directive block (section).

Found this porting MVC to use the new Razor codebase.
2017-01-26 13:06:06 -08:00
Ajay Bhargav Baaskaran 7725c20c47 Enabled Razor.Evolution tests on linux 2017-01-26 12:34:35 -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 03b63d97a2 Quick fixes from MVC
We're close to hooking up new Razor to MVC. This is a set of enabling
'quick fix' changes to resolve some blockers to using Razor.Evolution in
the product.

Main issues:
 - Types not public enough - anything in the .Legacy namespace is still
   slated from 'improvement'
 - Wrong references. We don't want .Workspaces in MVC, so moving the heavy
   lifting of TagHelper discovery to CodeAnalysis.Razor.
2017-01-24 09:22:28 -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 9ecd30cb2f Add Microsoft.CodeAnalysis.Razor
This project will have all of our roslyn-dependent infrastructure that we
need for designtime and runtime.
2017-01-20 15:26:39 -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
Nate McMaster 79663ef90e Upgrade to RC.3 2017-01-20 09:01:49 -08:00
N. Taylor Mullen 6e647854fa Add support for `ViewComponentTagHelpers`.
- Hardcoded `ViewComponent` discovery.
- Hardcoded `ViewComponentTagHelperDescriptor` creation.
- Added test to validate that ViewComponents are discovered and transitioned into TagHelpers properly.
- Avoided adding a reference to MVC to prevent circular references. This resulted in custom marker attributes to represent `ViewComponent`s. Also made a lot of use of `ViewComponent` conventions (ending in "ViewComponent").

#932
2017-01-19 10:18:11 -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
Ryan Nowak be10bb5f7b Remove support for includes
I was mistaken, this isn't a feature we will need for _ViewStart.
2017-01-18 09:11:03 -08:00
BrennanConroy ea21469c11 Change Xunit versions 2017-01-17 16:42:34 -08:00
N. Taylor Mullen d218bc3173 Remove AssemblyName requirement from TagHelperDescriptorFactory method.
- The assembly name is accessible on the provided type. No need to pass one in.
2017-01-17 14:47:40 -08:00
Ryan Nowak d7527d2e0a Create new way of suppressing unique Id generation
Adds a way of suppressing generation of guid ids that isn't based on a
global static.
2017-01-17 11:06:41 -08:00
Ryan Nowak 242ea0ee3f Add parsing of includes and imports
Also adds the source document to the RazorSyntaxTree and does some cleanup
related to this. This lets us verify which tree goes to which document and
that seems important.

Added basic tests to verify that parsing happens, though it's not being
used for anything right now.
2017-01-13 11:25:20 -08:00
N. Taylor Mullen 8215d28ada Port TagHelperDescriptorFactory tests.
- Ported the existing descriptor factory tests and fixed issues with the current implementation.
- Ported documentation tests with the exception of the localization variants.
- Updated the DefaultTagHelperResolver to filter TagHelper types based on accessibility.
- Added DefaultTagHelperResolver tests.

#851
2017-01-13 10:35:10 -08:00
Ryan Nowak 208da8ca12 Add plumbing for imports and includes
Groundwork for support of _ViewImports _ViewStart and others.
2017-01-12 09:25:19 -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
N. Taylor Mullen ee59368467 Add Microsoft.CodeAnalysis.Razor.Workspaces.Test project.
#851
2017-01-10 12:12:36 -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
Ryan Nowak 59b24fb724 Make TagHelperDescriptor public for tooling 2017-01-10 09:06:05 -08:00
N. Taylor Mullen ead9692ab1 Disable Cross plat tests for design time code gen tests. 2017-01-09 15:25:38 -08:00
Nate McMaster 91bc4b3940 Remove redundant references 2017-01-05 18:12:53 -08:00
Ryan Nowak e104451f79 Make SourceSpan public
Cleansup SourceSpan and makes it public where its used.
2017-01-03 12:46:56 -08:00
Ajay Bhargav Baaskaran eb0a2a1833 [Fixes #915] Added TagHelper preallocated attribute optimization pass 2017-01-03 11:05:57 -08:00
Ryan Nowak 6b075880ce Clean up SourceLocation
This change makes SourceLocation public and moves some of the undesirable
functions off of the class and into the .Legacy namespace.
2017-01-03 10:01:48 -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
Ryan Nowak f45afb6c19 Add a test for using with trailing newline
I couldn't find a test like this, but I've been debugging an issue in this
scenario.
2016-12-30 16:06:18 -08:00