Commit Graph

842 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 ce689b0449 Fixed DebuggerDisplay in DefaultTagHelperContent
- Also refactored it in few other places
2017-08-01 12:13:55 -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
N. Taylor Mullen 8fac9141d8 Revert Roslyn dev dependency increase.
- This is needed for the Razor editor to work inside of VS. Once a version of VS is published that supports 2.6 + then we can undo this change.
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 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
Pranav K c812f9d885 Update to RoslynDev 2.6.0-* packages 2017-07-12 14:06:43 -07:00
Mike Harder 01fe818dcd Update dependencies to match Visual Studio 15.3 (#1534) 2017-07-11 16:34:32 -07:00
N. Taylor Mullen 99ff9d44a3 Update repo to utilize ApiCheck.
- Re-enabled api check for `Microsoft.AspNetCore.Razor` and `Microsoft.AspNetCore.Razor.Runtime`. This resulted in me adding known breaking changes for the packages.
- Added empty baseline files for `Microsoft.AspNetCore.Razor.Language`, `Microsoft.AspNetCore.Mvc.Razor.Extensions` and `Microsoft.CodeAnalysis.Razor`.
- Disabled ApiCheck for `Microsoft.CodeAnalysis.Razor.Workspaces`, `Microsoft.CodeAnalysis.Remote.Razor`, `RazorPageGenerator` and `Microsoft.VisualStudio.LanguageServices.Razor` to prevent ApiCheck warnings about missing baselines.

#1107
2017-07-07 15:59:36 -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 02160a04d9 Make ViewComponentTagHelperMetadata static.
#1521
2017-07-06 17:17:41 -07:00
Ajay Bhargav Baaskaran 6fdd4d653c Made InvalidNonWhitespaceHtmlCharacters internal 2017-07-06 17:12:46 -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 d891fae4a9 Rename ThrowForMissingEngineDependency.
- Rename `RazorEngineFeatureBase.ThrowForMissingEngineDependency` to `ThrowForMissingFeatureDependency`
- Rename `RazorEnginePhaseBase.ThrowForMissingEngineDependency` to `ThrowForMissingFeatureDependency`

#1510
2017-07-06 16:50:11 -07:00
N. Taylor Mullen bba508c7c6 Change TagHelperDescriptor APIs to use IReadOnlyList.
- Change `TagHelperDescriptor.AllowedChildTags` to be `IReadOnlyList`.
- Change `TagHelperDescriptor.BoundAttributes` to be `IReadOnlyList`.
- Change `TagHelperDescriptor.TagMatchingRules` to be `IReadOnlyList`.
- Change `TagMatchingRuleDescriptor.Attributes` to be `IReadOnlyList`.

#1510
2017-07-06 16:01:46 -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
Ryan Brandenburg 17f97397e6 TreatWarningsAsErrors 2017-07-06 12:33:35 -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 647ce7515d Remove explicit scope managment 2017-07-05 15:47:46 -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
N. Taylor Mullen 8090216dbe Make RequiredAttributeDescriptor IEquatable.
- All the other descriptors are already `IEquatable` this should be as well.
- Moved the required attribute descriptor comparer from Legacy => Language. It wasn't in the Legacy folder to begin with so this made sense given that it's already internal.

#1495
2017-07-03 11:23:51 -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 7c7bb627b9 Moved typename and propertyname to extension methods 2017-06-29 16:47:53 -07:00
Ajay Bhargav Baaskaran 36fbb532cd Merge branch 'ajbaaska/th-node' into dev 2017-06-29 12:06:14 -07:00
Ajay Bhargav Baaskaran bcf790b9d5 Added convenience properties to TagHelperIntermediateNode 2017-06-29 12:05:42 -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