diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperAttributeDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperAttributeDescriptor.cs similarity index 98% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperAttributeDescriptor.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/TagHelperAttributeDescriptor.cs index 2b724482ae..3f9a8aef88 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperAttributeDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperAttributeDescriptor.cs @@ -4,12 +4,12 @@ using System; using System.Reflection; -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { /// /// A metadata class describing a tag helper attribute. /// - internal class TagHelperAttributeDescriptor + public class TagHelperAttributeDescriptor { private string _typeName; private string _name; diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperAttributeDesignTimeDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperAttributeDesignTimeDescriptor.cs similarity index 83% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperAttributeDesignTimeDescriptor.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/TagHelperAttributeDesignTimeDescriptor.cs index 93f6a12f7d..dfadeda0b0 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperAttributeDesignTimeDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperAttributeDesignTimeDescriptor.cs @@ -1,12 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { /// /// A metadata class containing information about tag helper use. /// - internal class TagHelperAttributeDesignTimeDescriptor + public class TagHelperAttributeDesignTimeDescriptor { /// /// A summary of how to use a tag helper. diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDescriptor.cs similarity index 98% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperDescriptor.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDescriptor.cs index b81feb67a9..0f6fb23e08 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDescriptor.cs @@ -5,12 +5,12 @@ using System; using System.Collections.Generic; using System.Linq; -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { /// /// A metadata class describing a tag helper. /// - internal class TagHelperDescriptor + public class TagHelperDescriptor { private string _prefix = string.Empty; private string _tagName; diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperDesignTimeDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDesignTimeDescriptor.cs similarity index 89% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperDesignTimeDescriptor.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDesignTimeDescriptor.cs index b5c120189f..49d781d5bc 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperDesignTimeDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDesignTimeDescriptor.cs @@ -1,12 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { /// /// A metadata class containing design time information about a tag helper. /// - internal class TagHelperDesignTimeDescriptor + public class TagHelperDesignTimeDescriptor { /// /// A summary of how to use a tag helper. diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperRequiredAttributeDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperRequiredAttributeDescriptor.cs similarity index 96% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperRequiredAttributeDescriptor.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/TagHelperRequiredAttributeDescriptor.cs index fc6c46298d..9b4b144cd6 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperRequiredAttributeDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperRequiredAttributeDescriptor.cs @@ -5,12 +5,12 @@ using System; using System.Diagnostics; using System.Linq; -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { /// /// A metadata class describing a required tag helper attribute. /// - internal class TagHelperRequiredAttributeDescriptor + public class TagHelperRequiredAttributeDescriptor { /// /// The HTML attribute name. diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperRequiredAttributeNameComparison.cs b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperRequiredAttributeNameComparison.cs similarity index 85% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperRequiredAttributeNameComparison.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/TagHelperRequiredAttributeNameComparison.cs index 22c7eb36df..7e413e1381 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperRequiredAttributeNameComparison.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperRequiredAttributeNameComparison.cs @@ -1,12 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { /// /// Acceptable comparison modes. /// - internal enum TagHelperRequiredAttributeNameComparison + public enum TagHelperRequiredAttributeNameComparison { /// /// HTML attribute name case insensitively matches . diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperRequiredAttributeValueComparison.cs b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperRequiredAttributeValueComparison.cs similarity index 90% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperRequiredAttributeValueComparison.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/TagHelperRequiredAttributeValueComparison.cs index 80d25ce4a6..2d4bc41289 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperRequiredAttributeValueComparison.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperRequiredAttributeValueComparison.cs @@ -1,12 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { /// /// Acceptable comparison modes. /// - internal enum TagHelperRequiredAttributeValueComparison + public enum TagHelperRequiredAttributeValueComparison { /// /// HTML attribute value always matches . diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagMode.cs b/src/Microsoft.AspNetCore.Razor.Evolution/TagMode.cs similarity index 87% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagMode.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/TagMode.cs index 1fe181a7c4..1fa0239067 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagMode.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/TagMode.cs @@ -1,12 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { /// /// The mode in which an element should render. /// - internal enum TagMode + public enum TagMode { /// /// Include both start and end tags. diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagStructure.cs b/src/Microsoft.AspNetCore.Razor.Evolution/TagStructure.cs similarity index 91% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagStructure.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/TagStructure.cs index 3a5b297d88..f801d53a5f 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagStructure.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/TagStructure.cs @@ -1,12 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { /// /// The structure the element should be written in. /// - internal enum TagStructure + public enum TagStructure { /// /// If no other tag helper applies to the same element and specifies a , diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperResolver.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperResolver.cs index 2531f5c586..770ef2b6a3 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperResolver.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/DefaultTagHelperResolver.cs @@ -1,10 +1,11 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNetCore.Razor.Evolution.Legacy; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNetCore.Razor.Evolution; +using Microsoft.AspNetCore.Razor.Evolution.Legacy; namespace Microsoft.CodeAnalysis.Razor { @@ -30,8 +31,7 @@ namespace Microsoft.CodeAnalysis.Razor foreach (var reference in compilation.References) { - var assembly = compilation.GetAssemblyOrModuleSymbol(reference) as IAssemblySymbol; - if (assembly != null) + if (compilation.GetAssemblyOrModuleSymbol(reference) is IAssemblySymbol assembly) { visitor.Visit(assembly.GlobalNamespace); } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs index 77bf153a40..2819c263ed 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/TagHelperResolver.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host; -using Microsoft.AspNetCore.Razor.Evolution.Legacy; +using Microsoft.AspNetCore.Razor.Evolution; namespace Microsoft.CodeAnalysis.Razor { diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/TagHelperDescriptorTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TagHelperDescriptorTest.cs similarity index 99% rename from test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/TagHelperDescriptorTest.cs rename to test/Microsoft.AspNetCore.Razor.Evolution.Test/TagHelperDescriptorTest.cs index 5a94ff7bce..53389a9abf 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/TagHelperDescriptorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TagHelperDescriptorTest.cs @@ -3,10 +3,11 @@ using System; using System.Collections.Generic; +using Microsoft.AspNetCore.Razor.Evolution.Legacy; using Newtonsoft.Json; using Xunit; -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { public class TagHelperDescriptorTest { diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/TagHelperRequiredAttributeDescriptorTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TagHelperRequiredAttributeDescriptorTest.cs similarity index 99% rename from test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/TagHelperRequiredAttributeDescriptorTest.cs rename to test/Microsoft.AspNetCore.Razor.Evolution.Test/TagHelperRequiredAttributeDescriptorTest.cs index 1f3ff7e052..921fe662f2 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/Legacy/TagHelperRequiredAttributeDescriptorTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TagHelperRequiredAttributeDescriptorTest.cs @@ -1,6 +1,6 @@ using Xunit; -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { public class TagHelperRequiredAttributeDescriptorTest { diff --git a/tooling/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorEngineTagHelperResolver.cs b/tooling/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolver.cs similarity index 52% rename from tooling/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorEngineTagHelperResolver.cs rename to tooling/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolver.cs index f7ab63bd1d..e4268d984b 100644 --- a/tooling/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorEngineTagHelperResolver.cs +++ b/tooling/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTagHelperResolver.cs @@ -1,24 +1,30 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Composition; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Evolution.Legacy; +using Microsoft.AspNetCore.Razor.Evolution; using Microsoft.CodeAnalysis; -using System.Composition; namespace Microsoft.VisualStudio.LanguageServices.Razor { - [Export(typeof(IRazorEngineTagHelperResolver))] - internal class DefaultRazorEngineTagHelperResolver : IRazorEngineTagHelperResolver + [Export(typeof(ITagHelperResolver))] + internal class DefaultTagHelperResolver : ITagHelperResolver { - public async Task> GetRazorEngineTagHelpersAsync(Workspace workspace, Project project) + [Import] + public VisualStudioWorkspace Workspace { get; set; } + + public async Task> GetTagHelpersAsync(Project project) { - var client = await RazorLanguageServiceClientFactory.CreateAsync(workspace, CancellationToken.None); + var client = await RazorLanguageServiceClientFactory.CreateAsync(Workspace, CancellationToken.None); + if (client == null) + { + // The OOP host is turned off, so let's do this in process. + var resolver = new CodeAnalysis.Razor.DefaultTagHelperResolver(); + return await resolver.GetTagHelpersAsync(project, CancellationToken.None).ConfigureAwait(false); + } using (var session = await client.CreateSessionAsync(project.Solution)) { diff --git a/tooling/Microsoft.VisualStudio.LanguageServices.Razor/IRazorEngineTagHelperResolver.cs b/tooling/Microsoft.VisualStudio.LanguageServices.Razor/ITagHelperResolver.cs similarity index 60% rename from tooling/Microsoft.VisualStudio.LanguageServices.Razor/IRazorEngineTagHelperResolver.cs rename to tooling/Microsoft.VisualStudio.LanguageServices.Razor/ITagHelperResolver.cs index 621a5a5116..18dfc759af 100644 --- a/tooling/Microsoft.VisualStudio.LanguageServices.Razor/IRazorEngineTagHelperResolver.cs +++ b/tooling/Microsoft.VisualStudio.LanguageServices.Razor/ITagHelperResolver.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.Evolution.Legacy; +using Microsoft.AspNetCore.Razor.Evolution; using Microsoft.CodeAnalysis; namespace Microsoft.VisualStudio.LanguageServices.Razor { - internal interface IRazorEngineTagHelperResolver + public interface ITagHelperResolver { - Task> GetRazorEngineTagHelpersAsync(Workspace workspace, Project project); + Task> GetTagHelpersAsync(Project project); } } diff --git a/tooling/Microsoft.VisualStudio.LanguageServices.Razor/Microsoft.VisualStudio.LanguageServices.Razor.csproj b/tooling/Microsoft.VisualStudio.LanguageServices.Razor/Microsoft.VisualStudio.LanguageServices.Razor.csproj index 9f08eb0701..54f392f893 100644 --- a/tooling/Microsoft.VisualStudio.LanguageServices.Razor/Microsoft.VisualStudio.LanguageServices.Razor.csproj +++ b/tooling/Microsoft.VisualStudio.LanguageServices.Razor/Microsoft.VisualStudio.LanguageServices.Razor.csproj @@ -21,6 +21,7 @@ + diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindow.cs b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindow.cs index 6afd31f9c8..f8aa260d51 100644 --- a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindow.cs +++ b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindow.cs @@ -17,7 +17,7 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo private IRazorEngineAssemblyResolver _assemblyResolver; private IRazorEngineDocumentGenerator _documentGenerator; private IRazorEngineDirectiveResolver _directiveResolver; - private IRazorEngineTagHelperResolver _tagHelperResolver; + private ITagHelperResolver _tagHelperResolver; private VisualStudioWorkspace _workspace; public RazorInfoToolWindow() : base(null) @@ -35,7 +35,7 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo _assemblyResolver = componentModel.GetService(); _documentGenerator = componentModel.GetService(); _directiveResolver = componentModel.GetService(); - _tagHelperResolver = componentModel.GetService(); + _tagHelperResolver = componentModel.GetService(); _workspace = componentModel.GetService(); _workspace.WorkspaceChanged += Workspace_WorkspaceChanged; diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoViewModel.cs b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoViewModel.cs index 1a6ae571ac..93ea7c5b6c 100644 --- a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoViewModel.cs +++ b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoViewModel.cs @@ -22,7 +22,7 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo private readonly IRazorEngineAssemblyResolver _assemblyResolver; private readonly IRazorEngineDirectiveResolver _directiveResolver; private readonly IRazorEngineDocumentGenerator _documentGenerator; - private readonly IRazorEngineTagHelperResolver _tagHelperResolver; + private readonly ITagHelperResolver _tagHelperResolver; private readonly IServiceProvider _services; private readonly Workspace _workspace; @@ -39,7 +39,7 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo Workspace workspace, IRazorEngineAssemblyResolver assemblyResolver, IRazorEngineDirectiveResolver directiveResolver, - IRazorEngineTagHelperResolver tagHelperResolver, + ITagHelperResolver tagHelperResolver, IRazorEngineDocumentGenerator documentGenerator) { _services = services; @@ -166,7 +166,7 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo var assemblies = await _assemblyResolver.GetRazorEngineAssembliesAsync(project); var directives = await _directiveResolver.GetRazorEngineDirectivesAsync(_workspace, project); - var tagHelpers = await _tagHelperResolver.GetRazorEngineTagHelpersAsync(_workspace, project); + var tagHelpers = await _tagHelperResolver.GetTagHelpersAsync(project); var files = GetCshtmlDocuments(project); diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/TagHelperViewModel.cs b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/TagHelperViewModel.cs index 122b4e6ad2..5fc71dc68b 100644 --- a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/TagHelperViewModel.cs +++ b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/TagHelperViewModel.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNetCore.Razor.Evolution.Legacy; +using Microsoft.AspNetCore.Razor.Evolution; namespace Microsoft.VisualStudio.RazorExtension.RazorInfo {