Commit Graph

451 Commits

Author SHA1 Message Date
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
Ryan Nowak 0835de17ec Adds stronger verification for spans
This change ensures that spans are contiguous and that all source is part
of a span. This means that a character can't be 'lost' and not a member of
any span.

And guess what? We have a bug like that. So now a few tests are skipped
due to that bug.

Also made some changes to tests that construct invalid spans or spans
without correct locations as their expected input. This allows us to add
the above verification to all parser tests.
2016-12-28 21:56:35 -08:00
Ryan Nowak f191cc62a2 Get rid of locations on Tokens. 2016-12-28 18:22:06 -08:00
N. Taylor Mullen e65c2ef1ef Upgrade to netcoreapp1.1 to fix test failure. 2016-12-28 15:55:16 -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
Pranav K 7657ea41a3 Updating to 4.4 CoreFx packages 2016-12-21 22:43:57 -08:00
Ryan Nowak b8e1fb8011 Add line-mapping support to RazorSourceDocument 2016-12-20 09:06:12 -08:00
Ryan Nowak b473101927 Fix line endings 2016-12-20 08:56:18 -08:00
N. Taylor Mullen 88d99b06b3 Skip Razor.Evolution tests on Linux and Mac.
- Source ranges currently aren't normalized when they're input into the system. Due to how we serialize pieces of the code this breaks cross plat because of newline differences.
- This is a temporary work around to get the build passing cross plat.
2016-12-19 15:03:32 -08:00
Nate McMaster 705a490acb Upgrade to VS 2017 2016-12-16 16:04:22 -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 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 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
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
N. Taylor Mullen 18bb31cee4 Change IntegrationTestBase to properly locate baseline files in net451.
- Net451 tests would have their current directory set to the dll that was located in bin/debug/framework/rid/... when run via `dotnet test`.

#885
2016-12-07 16:29:50 -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
Ryan Nowak 2190dc2096 Add RazorCSharpSourceDocument
Precursor to actual CSharp lowering
2016-12-04 23:30:55 -08:00