Commit Graph

746 Commits

Author SHA1 Message Date
N. Taylor Mullen aa980fc67c Roslyn-ize our tooling contracts.
- Added `ILanguageServiceFactory` types for all serviceable contracts.
- Maintained binary compatibility by copy/pasting existing services into a Legacy folder.
- Added a Workspaces.Test project since their implementations moved.
- Updated binary incompatible version of `RazorSyntaxFactsService` to not depend on VisualStudio. Added an extension type to the VS.LanguageServices.Razor project to enable easy-access from VisualStudio.

Below on refers to the binary incompatible copies.
Core services that were **entirely** moved from VisualStudio.Razor => Razor.Workspaces are as follows:
- `RazorSyntaxFactsService`, this included mutating the API to not depend on VisualStudio and moving some primitive types such as `AcceptedCharacters`.
- `TagHelperCompletionService`
- `TagHelperFactsService`
These all have a `ServiceLayer` of `Editor`.

Bits that were partially moved:
- `RazorTemplateEngineFactoryService`. The Default implementation and its corresponding factory still live in VisualStudio.Razor. This way Razor.Workspaces can get by without a reference to Mvc.Razor.Extensions.
- `ITagHelperResolver` used to exist in VisualStudio.Razor. Removed the type and replaced its usage with the already-existing `TagHelperResolver` type in Razor.Workspaces. Both contracts were nearly identical.
These all have a `ServiceLayer` of `Default`.

#1260
2017-08-02 16:58:44 -07:00
Ajay Bhargav Baaskaran 31e9710186 Added unit test for DefaultTagHelperOptimizationPass 2017-07-31 17:12:20 -07:00
Ajay Bhargav Baaskaran ee64ee7e1a Removed warning in ViewImports integration test 2017-07-28 16:59:35 -07:00
Mike Harder 35c8da94bf Temporarily disable package downgrade warnings (#1576)
- Revert when RoslynDevVersion >= RoslynVersion
2017-07-20 13:13:04 -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
N. Taylor Mullen 006b4651da Change product code to work with editor expectations.
- Descriptor providers should not be pushing `null` descriptors into the overall list of `TagHelperDescriptor`s; this causes null refs on the editor side of things at design time.
- Expose `FilePath` on `RazorEditorParser` for the editor. The editor currenlty uses the `RazorEditorParser` as a place to hold some state about the Razor document.
2017-07-19 09:56:51 -07:00
Ryan Nowak 8bbfecb0da Merge branch 'rel/2.0.0' into dev 2017-07-17 13:17:03 -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
N. Taylor Mullen 2a69b50a64 Change Razor.Test.Common to not act like an executable.
- There's no need for this test library to have a conditional TFM because it's never run under the desktop TFM when crossplat.
2017-07-13 14:58:27 -07:00
N. Taylor Mullen f8d43853f8 Re-introduce RazorEditorParser.
- Revived `RazorEditorParser`.
- Made `PartialParseResult` internal and renamed it to `PartialParseResultInternal`. This fell in line with other syntax tree types.
- Moved the `RazorEditorParser` implementation away from `TextChange` and `ITextBuffer`. Instead it now relies on `SourceChange` and the VS contract `ITextSnapshot`.
- Added `RazorEditorParserTest` to ensure the changes in implementation did not impact previous functionality.
- Removed some obvious tests that unnecessarily re-tested behavior that was already verified.
- Updated tests.
- Moved several Language.Test types to the common test project so they could be reused.

#1259
2017-07-12 17:01:16 -07:00
Ajay Bhargav Baaskaran b70815e317 Made `RazorCodeGenerationOptionsBuilder.DesignTime` getter only
- Made RazorCodeGenerationOptions consistent with RazorParserOptions
2017-07-07 14:41:53 -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 267b3fab0a Made IntermediateNodeWalker.Ancestors indexable 2017-07-06 19:24:25 -07:00
Ajay Bhargav Baaskaran 49eab41726 Made CodeTargetBuilder an abstract class 2017-07-06 19:01:28 -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
N. Taylor Mullen 45fad171a6 Reduce public surface area of some APIs.
- Change `DefaultRazorEngineBuilder.DesignTime` to be getter only
- Make `DocumentClassifierPassBase.TargetExtensions` private.

#1510
2017-07-06 16:50:11 -07:00
N. Taylor Mullen c34a99e188 Update the TagHelperBinding API to use IReadOnlyList.
- Changed `Attributes` to return `IReadOnlyList<KeyValuePair<string, string>>`.
- Changed `GetBoundRules` to return `IReadOnlyList<TagMatchingRuleDescriptor>`.
- Updated tests to react to new signature.

#1510
2017-07-06 15:42:24 -07:00
N. Taylor Mullen cb40da4e0f Rename ParseOnlyLeadingDirectives.
- Was renamed to `ParseLeadingDirectives`.

#1510
2017-07-06 14:34:15 -07:00
N. Taylor Mullen b68290ddb7 Make `RazorParserOptions` creation more like RazorEngine
- Removed verbose `Create` methods in favor of the `RazorParserOptionsBuilder`. This is similar to how the `RazorEngine` functions.
- Added a `CreateDesignTime` method.
- Updated existing tests to use new Create syntax.

#1510
2017-07-06 14:33:33 -07:00
N. Taylor Mullen 87a5435036 Make `RazorParserOptions.DesignTime` getter only.
- Renamed `IRazorParserOptionsFeature` to `IConfigureRazorParserOptionsFeature`, the original interface was re-purposed to get the options rather than configure them.
- This involved re-designing how we set design time on the `RazorParserOptions` object. The indicator of `DesignTime` is now configured at the RazorEngine level via a parser options provider feature.
- Moved options construction from the phase into an `IRazorParserOptionsFeature` type.

#1510
2017-07-06 14:33:05 -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
Ryan Nowak 7408bcd025 Rewrite of code rendering context 2017-07-05 15:32:54 -07:00
Ryan Nowak 8dfba25d59 Streamline collections
Makes our collections sealed instead of abstract.

Only the IntermediateNodeCollection needs to have a read only variant.
2017-07-05 13:46:37 -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 35889cba81 Add properties to the body node that it needs
Removes a usage of TagRenderingContext
2017-07-03 16:29:34 -07:00
Ryan Brandenburg ddef61485b DiagnosticSource to 4.4.1 2017-07-03 15:09:38 -07:00
N. Taylor Mullen 4654997201 Add AllowedChildTagDescriptor.
- Changed the `AllowedChildTags` collection on `TagHelperDescriptor` to have a custom object type to represent child tags.
- Created comparers and builders to work with the child tag descriptor.
- Removed the validation methods on `TagHelperDescriptorBuilder` since there's no longer any bits to validate (they're contained within the sub-properties).
- Unit tested the `DisplayName`.

#1493
2017-07-03 11:04:10 -07:00
Ryan Nowak a7cc63d6e1 Simplification of IntermediateNode 2017-07-03 10:41:15 -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
Ryan Brandenburg f5c55727a4 Remove AssetTargetFallback 2017-06-30 14:42:00 -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 34e3c249e4 Remove Test.Common dependency from LanguageServices.Razor.Test 2017-06-30 10:42:24 -07:00
Ajay Bhargav Baaskaran 7c7bb627b9 Moved typename and propertyname to extension methods 2017-06-29 16:47:53 -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 05cc4123a7 Add duplicate directive error for th prefix.
- Regenerated diagnostics for integration tests.
- Added a duplicate directive unit test.
- Added a new RazorDiagnostic entry in the factory.

#942
2017-06-28 16:12:02 -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
N. Taylor Mullen c2c95ec175 Add file scoped multiple occurring extensible directives.
- Updated existing singly occurring tests that verified that the directives must occur prior to any content to be theories that tested the joint "file scoped" behavior of the usage.
- Added tests that validate `FileScopedMultipleOccurring` can have duplicate directives without erroring.

#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 09ac126ecf Make single line single file scoped directives automatically import.
- Added an inner pass inside of the intermediate lowering phase to determine which directives get flowed to the final document. There were many ways to accomplish this but in order to keep the last wins mechanic for non-auto imported directives I had to let the directives get created and then removed based on if they were inherited.
- Added error case if a user attempts to import a block directive with a `FileScopedSinglyOccurring` directive usage.
- Added test cases that validate directives are properly inherited at the intermediate lowering phase.
- Updated a few tests that had incorrect assumptions.
- Left the default directive passes alone in regards to determining the "imported" directive to enable users to add their own model, inherits, etc. directives that take precedence.
- Normalized the passes in the intermediate lowering phase to handle directives identically (we don't conditionally lower anymore).

#1376
2017-06-26 16:36:54 -07:00