Commit Graph

126 Commits

Author SHA1 Message Date
N. Taylor Mullen 771a7e35a4 Add MVC support for RazorProjectEngine.
- Make `RazorProjectEngine` call paths for all feature registrations.
- Add `DefaultMvcImportFeature` for latest and 1.X MVC.
- Ported `AddTargetExtension` and `AddDirective` to `RazorProjectEngineBuilderExtensions`.
- Added tests and a test file system project type.
- Moved obsolete `IRazorEngineBuilder` methods to the bottom of each file. Will actually obsolete the methods once `RazorProjectEngine` is working end-to-end.

#1828
2018-01-25 12:26:11 -08:00
Ryan Nowak 16324c3126 Add an Identifier by default
Using the MVC view engine convention for identifiers seems to make the
most sense, and we already use that convention for RazorProject so I
guess we're stuck with it.
2018-01-06 18:43:01 -08:00
Ryan Nowak b93bab9c04 Remove Get/SetRelativePath 2018-01-05 21:52:59 -08:00
Ryan Nowak 186e5733c0
Add metadata to Razor (#1894)
* Add metadata to Razor

This PR introduces standard metadata to Razor. This change begins to
formalize the contract between generated code produced by Razor and
runtimes that want to load and interact with this code.

This is a step on making MVC a 'plugin' to Razor rather than the only
possible implementation. Since we're doing MSBuild work - this is the
right time to designate the current interaction between Razor and MVC as
'legacy' and move forward.

Additionally, we need the source thumbprinting to make re-compilation of
Razor a thing.

-----

Also I noticed that our source document doesn't expose the hash
algorithm by name. We really should have this, so I added it and
hardened the code that deals with checksums in c# generation.
2018-01-02 13:30:50 -08:00
Pranav K 3ae601e4df
Prevent type name collisions when file hierarchy + namespace is identical (#1881)
* Prevent type name collisions when file hierarchy + namespace is identical
2018-01-02 09:41:10 -08:00
Ajay Bhargav Baaskaran 808f539297 Moved CSharpCodeParser out of LegacyRazorDiagnostic 2017-12-19 15:59:37 -08:00
Pranav K 82247fbb09 Update samples and tests to target netcoreapp2.1 2017-11-14 09:45:28 -08:00
Nate McMaster 4d737af167 Pin tool and package versions to make builds more repeatable
Part of aspnet/Universe#575
2017-11-01 18:12:08 -07:00
Ajay Bhargav Baaskaran 4b68a48f1d Fix: Broken intellisense for extensible directives 2017-08-29 14:47:52 -07:00
Nate McMaster 471722eba1 Use PackageLineup to manage PackageReference versions
This uses a feature of KoreBuild which will select PackageReference
versions based on a lineup file. This helps unify versions between repos
and helps us ensure we are consistent across multiple components.
2017-08-25 15:44:05 -07:00
Nate McMaster 4cadee2762 Use Directory.Build.props/targets (#1641) 2017-08-23 12:24:57 -07:00
N. Taylor Mullen 6e42c8d0e4 Made section 1.X compatibility only apply at design time.
#1637
2017-08-22 20:47:01 -07:00
N. Taylor Mullen 5104e8c806 Make 2.0 codegen compatible with 1.0 projects until multi-targeting is complete.
#1637
2017-08-22 17:29:33 -07:00
N. Taylor Mullen db805eb3e3 Fix ModelExpression's in section directive blocks.
- Changed `SectionDirectivePass` to move non-token body nodes from the original `DirectiveIntermediateNode` to the `SectionIntermediateNode`. By doing this there's no longer dual references of `SectionIntermediateNode` bodies.
- Added MVC tests for current and 1_X extensions.

#1614
2017-08-16 10:25:53 -07:00
Ajay Bhargav Baaskaran 655a693e4a Make ViewComponentTagHelper use extension intermediate nodes 2017-08-11 12:01:21 -07:00
Ajay Bhargav Baaskaran 4fcad1548e Added support for multitargeting
- Added 1_X src project for multitargeting

- Added 1_X test project for multitargeting

- Added 1_X test MvcShim for multitargeting

- Make section directive generate the correct code the appropriate version

- Added another sln
2017-08-04 15:39:18 -07:00
N. Taylor Mullen 127784e058 Fix clean machine/testing for Mvc.Extensions. 2017-08-03 10:40:16 -07:00
Ajay Bhargav Baaskaran ee64ee7e1a Removed warning in ViewImports integration test 2017-07-28 16:59:35 -07:00
N. Taylor Mullen 184ab74e68 Don't render view attributes when in design time.
- This is a temporary work around that's needed until we have multi-targeting support in https://github.com/aspnet/Razor/issues/1535.
2017-07-19 09:56:51 -07:00
Ryan Nowak 59d3fb433b Fix #1555
Revert validation that file-scoped directives appear before HTML or
code.
2017-07-17 11:24:58 -07:00
Ryan Nowak 9c0a8a5c96 Rename properties on taghelper nodes 2017-07-07 11:32:05 -07:00
Ryan Nowak ff40124594 Convert most of CodeWriter into extensions
We don't really want to ship what we have as a contract. As an emergency
measure we are making it into internal extension methods so we can have
a do-over in 2.1.
2017-07-07 10:55:33 -07:00
Ajay Bhargav Baaskaran d6e892b30c Adjusted verbosity of some property names and made
TagHelperIntermediateNode.TagHelpers and IList
2017-07-06 18:05:36 -07:00
Ajay Bhargav Baaskaran 11c5293862 Unnest IntermediateToken.TokenKind 2017-07-06 11:15:36 -07:00
N. Taylor Mullen afa61e7080 Rename LineMapping => SourceMapping.
- Also removed the == and `!=` operators for `SourceMapping`.

#1510
2017-07-06 10:34:19 -07:00
N. Taylor Mullen a78202e937 Have `@page` understand malformed directives.
- The `@page` directive will now look for malformed directives and treat a view as a Razor page based on the existence of the malformed directive.
- Updated the `PageDirective` type to contain a reference to its responsible directive node.
- Added unit tests to validate malformed directives were picked up accordingly.
- Updated code generation test baselines to reflect the new malformed directive understanding.

#1448
2017-07-05 16:57:51 -07:00
N. Taylor Mullen d36838ed88 Handle imported @page directives.
- Prior to this imported `@page` directives would flow through the Razor system without error. This resulted in inconsistent behavior between MVC and Razor. Now, imported `@page` directives result in diagnostics on the page directive node.
- Added two tests to verify that we still treat views with imported page directives as Razor pages BUT we also log a diagnostic on the page directive node.
- Renamed the `ViewComponentDiagnosticFactory` class to `RazorExtensionsDiagnosticFactory` so it can be used for more than just view component diagnostics. This way we can ensure that our diagnostics don't end up overlapping.

#1503
2017-07-03 17:11:17 -07:00
Ryan Nowak 8a9bf9c71a Rewrite of code rendering context 2017-07-03 16:29:34 -07:00
Ryan Nowak 112cbc0bb6 Check for warnrings in tests taht compile
This fixes and issue that snuck through and broke MVC as well as
preventing this from happening in the future.
2017-07-01 11:52:41 -07:00
Ryan Nowak 7aeb228063 Redesign tag helper codegen 2017-06-30 17:34:01 -07:00
N. Taylor Mullen 2a6f0e4dc9 Productionize the csharp rendering context APIs.
- Rename `CSharpRenderingContext` => `CodeRenderingContext`.
- Rename `CSharpCodeWriter` => `CodeWriter`
- Rename `BasicWriter` => `IntermediateNodeWriter`
- Rename `...BasicWriter` => `...NodeWriter`
- Made `CodeRenderingContext` a public abstract API. Left temporary TagHelper pieces in the class since these will be removed soon.
- Moved several `CodeRenderingContext` methods into extension methods. These make use of the Items collection.
- Moved the reporting of missing code target extensions into the `ExtensionIntermediateNode`. This is the integration point of `CodeTarget`s and `CodeRenderingContext`s; therefore, it made more sense existing there.
- Left SetRenderChildren/SetRenderNode as extension methods due to how they're wired up. Aka, to create a `CodeTarget` you need a `CodeRenderingContext`... To Create a `DocumentWriter` you need a `CodeTarget`... To set the render methods on the context you need a `DocumentWriter`.
- Updated tests to utilize the new code renering constructs.
- Moved code generation testability features from `CSharpLoweringPhase` to the `CodeRenderingContext.Items`.

#1043
2017-06-30 16:35:53 -07:00
Ajay Bhargav Baaskaran 9c031e6fb5 Moved all TagHelperDescriptor related builders to have getter setter
instead of methods

More polish to the tag helper descriptor builders.
- Expose underlying builders as getter only list
- Added AsDictionary() extension method to BoundAttributeDescriptorBuilder
- Expose diagnostics as RazorDiagnosticCollection
- Got rid of Require** prefix in TagMatchingRuleBuilder
- Workaround issue aspnet/Razor#1492 by copying the test descriptor
  extensions
2017-06-30 14:08:05 -07:00
Ajay Bhargav Baaskaran ff433f72b8 Run DesignTimeDirectivePass later in the phase 2017-06-29 10:51:45 -07:00
Pranav K 0a283cdfdb Revert "Remove skipped test"
This reverts commit 35fec2b8d7d1a3fd5918738cf01ed4543f4da9ae.
2017-06-29 10:39:07 -07:00
Pranav K fbe57e2569 Remove skipped test 2017-06-29 10:39:07 -07:00
Ryan Brandenburg 511c7db541 Remove NetStandard.Library.NETFramework and Update Moq 2017-06-29 10:17:45 -07:00
Ryan Nowak 853b458893 This is a different take on Taylor's builders.
This makes it possible to use another 'kind' of tag helpers, which isn't
possible today.

This also further decouples the tag helper api surface from the default
implementation.

VCTH now have their own 'kind'.

Also improved generation of display names and error messages where it
was coupled to the type name.
2017-06-28 17:37:52 -07:00
N. Taylor Mullen dd10b0b086 Update test node writer to write malformed directives.
- Updated baselines.

#1456
2017-06-28 16:34:56 -07:00
N. Taylor Mullen c67e790b3b Update inject directive to utilize DirectiveUsage.
- The `@inject` directive must now occur prior to any markup or code due to its `DirectiveUsage.FileScopedMultipleOccurring` usage.

#1377
2017-06-26 20:29:06 -07:00
Ajay Bhargav Baaskaran d73ecf8b36 Suppress warnings for auto generated code 2017-06-26 17:35:11 -07:00
N. Taylor Mullen 7a04e35da5 Update built-in directives to use DirectiveUsage.
- Updated integration code gen and IR bits to reflect new directive usage.
- Updated existing unit tests that happened to test directives in code blocks to now test what happens when they exist at the document level. Being inside of a code block is now invalid and we have separate tests for that scenario.

#1376
2017-06-22 11:42:37 -07:00
Ryan Nowak 7a234ca513 Rename UsingStatement>UsingDirective 2017-06-21 19:54:40 -07:00
Ryan Nowak a580c8fdf1 Get rid of AccessModifiers 2017-06-21 19:10:57 -07:00
Ryan Nowak a40ca857c5 Rename HtmlAttributeValueStyle>AttributeStructure 2017-06-21 18:56:37 -07:00
Ryan Nowak 21e26ad4aa Rename RazorIRNode
Get rid of references to 'IR'
2017-06-21 12:55:16 -07:00
N. Taylor Mullen 132c8c7a7e Implement consistent error story for directives.
- Added error case that enforces whitespace in between directive tokens.
- Upon encountering invalid directive tokens/states we bail out of parsing and log an appropriate error.
- Raised directive parse errors to the IR layer. This is slightly hacky given the parsers limitations; we swap out the error sink temporarily to capture all directive parser errors and then shove the errors collected onto the directives chunk generator.
- Added a `MalformedDiretiveIRNode` and corresponding pass to represent directives that are in an invalid state. Chose to not take the path of using the default `DirectiveIRNode.Diagnostics` member to enable users who are extending directives to only ever have to work with "valid" directives. If they want to work with malformed directives they can search the IR document for their malformed counterpart and handle it separately.
- Updated existing test expectations
- Removed some existing tests that were no longer valid (we don't call into user code if a directive is malformed).

#1173
2017-06-19 21:14:06 -07:00
Ajay Bhargav Baaskaran 3892a6fede Removed ChecksumIRNode 2017-06-16 11:14:54 -07:00
Ryan Nowak 8599870648 Revert "Revert "Update Roslyn Version to support C# 7.1""
This reverts commit 48285f63c6.
2017-06-14 11:56:56 -07:00
Ryan Nowak 22d52f2a3c Split the functions/section/inherits directives 2017-06-13 18:05:34 -07:00
Ryan Nowak 6860806213 Make usage of FileName and FilePath consistent
FileName => "Foo.cshtml"
FilePath => "/Bar/Baz/Foo.cshtml"
2017-06-12 16:15:26 -07:00