Commit Graph

34 Commits

Author SHA1 Message Date
Ryan Nowak bafe1b27ff Add line numbers for design time directives
Addresses a blocking issue for FAR of types when used in user-code in a
directive. The FAR infrastructure is skipping over the directive code
because it's mapped to `#hidden`. As you can see in the code, the token
provided by the user is already included in the projection mappings.

I think we didn't do this before because we didn't expect this code to
need line numbers - it's not really debuggable, and design-time codegen
doesn't happen when you build the project.

I think it's OK for now that we don't line-map (or include) directives
based on view imports. If you trigger FAR on an `@inject ...` in an
import for instance, you'll find the reference for the view import file.
That seems pretty good, and the only cases I can really imagine it being
broken would be for go-to-definition (within a Razor view). Lets revisit
in the future based on feedback.
2018-10-18 13:46:24 -07:00
Ajay Bhargav Baaskaran 7f6b05149d Generate deterministic unique ids for tag helpers 2018-07-17 14:01:42 -07:00
Ajay Bhargav Baaskaran f8dc5c4702 Obsoleted IRazorEngineBuilder APIs 2018-04-13 12:35:53 -07:00
Pranav K 7ff56dadf4 CodeGen RouteTemplate as a RazorCompiledItemAttribute 2018-03-19 12:37:04 -07:00
Ryan Nowak 82579b6333 Get rid of RazorConfiguration.DesignTime
This change makes it so that we no longer create 'design time' engines.
The choice of design time or runtime is made when we initiate a code
generation operation.

Options instances are now created as part of the CodeDocument
initialization. Our existing code can still be created using a
RazorEngine so our passes that initialize the options still support the
old code path.
2018-02-13 16:21:18 -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 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
N. Taylor Mullen 63aceea121 Change TagHelperBlockRewriter's error usage to use RazorDiagnosticFactory.
- Changed `DefaultRazorDiagnostic` to expose a little more information for tests. This info is only available when casted to the `DefaultRazorDiagnostic` type and only available internally.
- Changed parameter order of a `DefaultTagHelperTargetExtension` diagnostic.
- Updated baselines of files in `Razor.Language.Test`.
- Added a new convenience constructor on `SourceSpan`. The ctor is equivalent to calling the class with a SourceLocation.

#1827
2017-12-22 09:38:31 -08:00
N. Taylor Mullen 926dae0d88 Move DefaultTagHelperTargetExtension errors to use RazorDiagnosticFactory.
- Added tests validating these errors because we didn't have any before.

#1827
2017-12-19 15:28:24 -08: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
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
Ajay Bhargav Baaskaran 31e9710186 Added unit test for DefaultTagHelperOptimizationPass 2017-07-31 17:12:20 -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
Ryan Nowak 7408bcd025 Rewrite of code rendering context 2017-07-05 15:32:54 -07:00
Ryan Nowak 8a9bf9c71a Rewrite of code rendering context 2017-07-03 16:29:34 -07:00
Ryan Nowak 35889cba81 Add properties to the body node that it needs
Removes a usage of TagRenderingContext
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
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
Ryan Nowak e3b3e20738 Move some stuff to .Extensions
Moved design time directives and tag helper attribute preallocation to
.Extensions.

Just mechanical namespace changes here.
2017-06-21 20:26:31 -07:00
Ryan Nowak 21e26ad4aa Rename RazorIRNode
Get rid of references to 'IR'
2017-06-21 12:55:16 -07:00
Ryan Nowak 062d7561ae Make section an extension node 2017-06-20 19:20:46 -07:00
Ajay Bhargav Baaskaran 3892a6fede Removed ChecksumIRNode 2017-06-16 11:14:54 -07:00
Ryan Nowak 22d52f2a3c Split the functions/section/inherits directives 2017-06-13 18:05:34 -07:00
Ajay Bhargav Baaskaran f099232ca4 Moved scope writer logic to BasicWriter 2017-06-09 12:10:00 -07:00
Ryan Nowak e391ac7a3c Split options into ParserOptions and CodeGenerationOptions 2017-05-18 10:22:39 -07:00
Ryan Nowak 811ea019a5 Fixes #1245 - Make TemplateCodeExtension public
This removes the hardcoding of an MVC type from Razor.
2017-05-17 20:25:06 -07:00