Make TagHelperDescriptor public for tooling
This commit is contained in:
parent
6c7d121ce8
commit
59b24fb724
|
|
@ -4,12 +4,12 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
|
||||
namespace Microsoft.AspNetCore.Razor.Evolution
|
||||
{
|
||||
/// <summary>
|
||||
/// A metadata class describing a tag helper attribute.
|
||||
/// </summary>
|
||||
internal class TagHelperAttributeDescriptor
|
||||
public class TagHelperAttributeDescriptor
|
||||
{
|
||||
private string _typeName;
|
||||
private string _name;
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// A metadata class containing information about tag helper use.
|
||||
/// </summary>
|
||||
internal class TagHelperAttributeDesignTimeDescriptor
|
||||
public class TagHelperAttributeDesignTimeDescriptor
|
||||
{
|
||||
/// <summary>
|
||||
/// A summary of how to use a tag helper.
|
||||
|
|
@ -5,12 +5,12 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
|
||||
namespace Microsoft.AspNetCore.Razor.Evolution
|
||||
{
|
||||
/// <summary>
|
||||
/// A metadata class describing a tag helper.
|
||||
/// </summary>
|
||||
internal class TagHelperDescriptor
|
||||
public class TagHelperDescriptor
|
||||
{
|
||||
private string _prefix = string.Empty;
|
||||
private string _tagName;
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// A metadata class containing design time information about a tag helper.
|
||||
/// </summary>
|
||||
internal class TagHelperDesignTimeDescriptor
|
||||
public class TagHelperDesignTimeDescriptor
|
||||
{
|
||||
/// <summary>
|
||||
/// A summary of how to use a tag helper.
|
||||
|
|
@ -5,12 +5,12 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
|
||||
namespace Microsoft.AspNetCore.Razor.Evolution
|
||||
{
|
||||
/// <summary>
|
||||
/// A metadata class describing a required tag helper attribute.
|
||||
/// </summary>
|
||||
internal class TagHelperRequiredAttributeDescriptor
|
||||
public class TagHelperRequiredAttributeDescriptor
|
||||
{
|
||||
/// <summary>
|
||||
/// The HTML attribute name.
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Acceptable <see cref="TagHelperRequiredAttributeDescriptor.Name"/> comparison modes.
|
||||
/// </summary>
|
||||
internal enum TagHelperRequiredAttributeNameComparison
|
||||
public enum TagHelperRequiredAttributeNameComparison
|
||||
{
|
||||
/// <summary>
|
||||
/// HTML attribute name case insensitively matches <see cref="TagHelperRequiredAttributeDescriptor.Name"/>.
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Acceptable <see cref="TagHelperRequiredAttributeDescriptor.Value"/> comparison modes.
|
||||
/// </summary>
|
||||
internal enum TagHelperRequiredAttributeValueComparison
|
||||
public enum TagHelperRequiredAttributeValueComparison
|
||||
{
|
||||
/// <summary>
|
||||
/// HTML attribute value always matches <see cref="TagHelperRequiredAttributeDescriptor.Value"/>.
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The mode in which an element should render.
|
||||
/// </summary>
|
||||
internal enum TagMode
|
||||
public enum TagMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Include both start and end tags.
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The structure the element should be written in.
|
||||
/// </summary>
|
||||
internal enum TagStructure
|
||||
public enum TagStructure
|
||||
{
|
||||
/// <summary>
|
||||
/// If no other tag helper applies to the same element and specifies a <see cref="TagStructure"/>,
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
|
||||
namespace Microsoft.AspNetCore.Razor.Evolution
|
||||
{
|
||||
public class TagHelperRequiredAttributeDescriptorTest
|
||||
{
|
||||
|
|
@ -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<IEnumerable<TagHelperDescriptor>> GetRazorEngineTagHelpersAsync(Workspace workspace, Project project)
|
||||
[Import]
|
||||
public VisualStudioWorkspace Workspace { get; set; }
|
||||
|
||||
public async Task<IEnumerable<TagHelperDescriptor>> 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))
|
||||
{
|
||||
|
|
@ -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<IEnumerable<TagHelperDescriptor>> GetRazorEngineTagHelpersAsync(Workspace workspace, Project project);
|
||||
Task<IEnumerable<TagHelperDescriptor>> GetTagHelpersAsync(Project project);
|
||||
}
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="2.0.0-rc3-61306-01" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.LanguageServices" Version="2.0.0-rc3-61306-01" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.LanguageServices.Razor.RemoteClient" Version="2.0.0-rc3-61306-01" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -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<IRazorEngineAssemblyResolver>();
|
||||
_documentGenerator = componentModel.GetService<IRazorEngineDocumentGenerator>();
|
||||
_directiveResolver = componentModel.GetService<IRazorEngineDirectiveResolver>();
|
||||
_tagHelperResolver = componentModel.GetService<IRazorEngineTagHelperResolver>();
|
||||
_tagHelperResolver = componentModel.GetService<ITagHelperResolver>();
|
||||
|
||||
_workspace = componentModel.GetService<VisualStudioWorkspace>();
|
||||
_workspace.WorkspaceChanged += Workspace_WorkspaceChanged;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue