Commit Graph

441 Commits

Author SHA1 Message Date
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
Ryan Nowak 9cefcdd450 Add legacy dependencies of C# lowering 2016-12-04 23:30:34 -08:00
Ryan Nowak 03549bb542 Add end-to-end support for extensible directives
This change adds a way to actually configure the RazorEngine to use
extensible directives (previously buried behind legacy API). As part of
this feature adds the RazorParserOptions class to encapsulate anything
else that becomes a parser options (ahem taghelpers).

Now we have a pattern for this when we get there.

Options are propagated as part of the RazorSyntaxTree for
testability/sanity and this was actually responsible for the bulk of the
changes.

Also added some extension methods for adding directives to the
IRazorEngineBuilder and an end to end integration test.
2016-12-03 18:44:54 -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 518378f499 Add extensible directive abstractions
- Based generic directive implementation off of descriptors.
- Added parsing logic to consume descriptors and parse content that's expected.
- Added parsing errors to automagically detect unexpected directive pieces.
- Updated visitor implementations to understand the directive bits.
- Added a builder abstraction to easily create descriptors. Had to maintain the ability to manually construct a descriptor to enable convenient serialization/deserialization.
- Added tests/comparers to verify correctness of parsing.

#853
2016-11-23 19:56:40 -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
N. Taylor Mullen aa58ea6907 Change IR implementations to not hold all information in children.
- Added conditional attribute test.
- Reacted to Html optimization pass in tests.
- Removed directive IR bits since they'll be handled by the extensible directive system.

#844
2016-11-22 11:54:13 -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 d0e1b810c4 Fix test case so it works cross plat.
- This just happened to be working on Windows. Newlines!
2016-11-21 14:52:52 -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
N. Taylor Mullen 26a1cf3cff Port existing TagHelper infrastructure.
- Modified how tests are run to reflect our new test infrastructure.
- Added TagHelper assertion bits.
- Moved all classes to the Evolution.Legacy namespace.
- Copied Test.Sources bits to the Evolution.Test project.

#845
2016-11-21 11:01:10 -08:00