Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
Moved all invalid TagHelper utilities out of `Microsoft.AspNet.Razo…
Browse files Browse the repository at this point in the history
…r.TagHelpers`.

- Required adding a new using statement to generated code. Regened output files.
- Fixed broken documentation.

#578
  • Loading branch information
NTaylorMullen committed Oct 20, 2015
1 parent c0ebd43 commit 466bff1
Show file tree
Hide file tree
Showing 75 changed files with 393 additions and 340 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal;
using Microsoft.CodeAnalysis;

namespace Microsoft.AspNet.Razor.Runtime.Precompilation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal;
using Microsoft.CodeAnalysis;

namespace Microsoft.AspNet.Razor.Runtime.Precompilation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal;
using Microsoft.CodeAnalysis;

namespace Microsoft.AspNet.Razor.Runtime.Precompilation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;

namespace Microsoft.AspNet.Razor.Runtime
namespace Microsoft.AspNet.Razor.Runtime.Internal
{
internal static class Constants
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Text;
using System.Xml.Linq;

namespace Microsoft.AspNet.Razor.Runtime
namespace Microsoft.AspNet.Razor.Runtime.Internal
{
/// <summary>
/// Extracts summary and remarks XML documentation from an XML documentation file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
using System.IO;
using System.Text;
using Microsoft.AspNet.Html.Abstractions;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.Extensions.Internal;
using Microsoft.Extensions.WebEncoders;

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// Default concrete <see cref="TagHelperContent"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// Metadata common to types and properties.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// Contains property metadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// Contains type metadata.
Expand All @@ -27,9 +27,9 @@ public interface ITypeInfo : IMemberInfo, IEquatable<ITypeInfo>
/// Gets <see cref="IPropertyInfo"/>s for all properties of the current type excluding indexers.
/// </summary>
/// <remarks>
/// Indexers in this context refer to the CLR notion of an indexer (<c>this [string name]</c>
/// and does not overlap with the semantics of
/// <see cref="Razor.Compilation.TagHelperAttributeDescriptor.IsIndexer"/>.
/// Indexers in this context refer to the CLR notion of an indexer (<c>this [string name]</c>
/// and does not overlap with the semantics of
/// <see cref="Razor.Compilation.TagHelpers.TagHelperAttributeDescriptor.IsIndexer"/>.
/// </remarks>
IEnumerable<IPropertyInfo> Properties { get; }

Expand Down Expand Up @@ -62,7 +62,7 @@ public interface ITypeInfo : IMemberInfo, IEquatable<ITypeInfo>
/// parameters if the type implements <see cref="IDictionary{TKey, TValue}"/>, otherwise <c>null</c>.
/// </returns>
/// <remarks>
/// For open generic types, <see cref="ITypeInfo" /> for generic type parameters is <c>null</c>.
/// For open generic types, <see cref="ITypeInfo" /> for generic type parameters is <c>null</c>.
/// </remarks>
ITypeInfo[] GetGenericDictionaryParameters();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.AspNet.Razor.TagHelpers;

namespace Microsoft.AspNet.Razor.Runtime
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// <see cref="IPropertyInfo"/> adapter for <see cref="PropertyInfo"/> instances.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using Microsoft.AspNet.Razor.Runtime;
using Microsoft.AspNet.Razor.Runtime.Internal;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.Extensions.Internal;

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// <see cref="ITypeInfo"/> adapter for <see cref="System.Reflection.TypeInfo"/> instances.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
using System.Reflection;
using System.Text.RegularExpressions;
using Microsoft.AspNet.Razor.Compilation.TagHelpers;
using Microsoft.AspNet.Razor.Runtime;
using Microsoft.AspNet.Razor.Runtime.Internal;
using Microsoft.AspNet.Razor.TagHelpers;

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// Factory for <see cref="TagHelperDescriptor"/>s from <see cref="ITypeInfo"/>s.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Compilation.TagHelpers;
using Microsoft.AspNet.Razor.Runtime;
using Microsoft.AspNet.Razor.Parser;

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// Used to resolve <see cref="TagHelperDescriptor"/>s.
Expand Down Expand Up @@ -117,16 +115,16 @@ public IEnumerable<TagHelperDescriptor> Resolve(TagHelperDescriptorResolutionCon
}

/// <summary>
/// Resolves all <see cref="TagHelperDescriptor"/>s for <see cref="ITagHelper"/>s from the given
/// <paramref name="assemblyName"/>.
/// Resolves all <see cref="TagHelperDescriptor"/>s for <see cref="Razor.TagHelpers.ITagHelper"/>s from the
/// given <paramref name="assemblyName"/>.
/// </summary>
/// <param name="assemblyName">
/// The name of the assembly to resolve <see cref="TagHelperDescriptor"/>s from.
/// </param>
/// <param name="documentLocation">The <see cref="SourceLocation"/> of the directive.</param>
/// <param name="errorSink">Used to record errors found when resolving <see cref="TagHelperDescriptor"/>s
/// within the given <paramref name="assemblyName"/>.</param>
/// <returns><see cref="TagHelperDescriptor"/>s for <see cref="ITagHelper"/>s from the given
/// <returns><see cref="TagHelperDescriptor"/>s for <see cref="Razor.TagHelpers.ITagHelper"/>s from the given
/// <paramref name="assemblyName"/>.</returns>
// This is meant to be overridden by tooling to enable assembly level caching.
protected virtual IEnumerable<TagHelperDescriptor> ResolveDescriptorsInAssembly(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
using System.Linq;
using System.Reflection;
using Microsoft.AspNet.Razor.Compilation.TagHelpers;
using Microsoft.AspNet.Razor.Runtime;
using Microsoft.AspNet.Razor.Runtime.Internal;
using Microsoft.AspNet.Razor.TagHelpers;

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// Factory for providing <see cref="TagHelperDesignTimeDescriptor"/>s from <see cref="Type"/>s and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNet.Razor.TagHelpers;

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// Class used to store information about a <see cref="ITagHelper"/>'s execution lifetime.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Razor.TagHelpers;

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// A class used to run <see cref="ITagHelper"/>s.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNet.Razor.Runtime;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.Extensions.Internal;

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// Class that manages <see cref="TagHelperExecutionContext"/> scopes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.AspNet.Razor.Runtime;
using Microsoft.AspNet.Razor.TagHelpers;

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
/// <summary>
/// Class that locates valid <see cref="ITagHelper"/>s within an assembly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal;

namespace Microsoft.AspNet.Razor.TagHelpers
{
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.AspNet.Razor/Chunks/AddTagHelperChunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
namespace Microsoft.AspNet.Razor.Chunks
{
/// <summary>
/// A <see cref="Chunk"/> used to look up <see cref="Compilation.TagHelperDescriptor"/>s.
/// A <see cref="Chunk"/> used to look up <see cref="Compilation.TagHelpers.TagHelperDescriptor"/>s.
/// </summary>
public class AddTagHelperChunk : Chunk
{
/// <summary>
/// Text used to look up <see cref="Compilation.TagHelperDescriptor"/>s.
/// Text used to look up <see cref="Compilation.TagHelpers.TagHelperDescriptor"/>s.
/// </summary>
public string LookupText { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class AddOrRemoveTagHelperChunkGenerator : SpanChunkGenerator
/// Instantiates a new <see cref="AddOrRemoveTagHelperChunkGenerator"/>.
/// </summary>
/// <param name="lookupText">
/// Text used to look up <see cref="Compilation.TagHelperDescriptor"/>s that should be added or removed.
/// Text used to look up <see cref="Compilation.TagHelpers.TagHelperDescriptor"/>s that should be added or removed.
/// </param>
public AddOrRemoveTagHelperChunkGenerator(bool removeTagHelperDescriptors, string lookupText)
{
Expand All @@ -24,13 +24,13 @@ public AddOrRemoveTagHelperChunkGenerator(bool removeTagHelperDescriptors, strin
}

/// <summary>
/// Gets the text used to look up <see cref="Compilation.TagHelperDescriptor"/>s that should be added to or
/// Gets the text used to look up <see cref="Compilation.TagHelpers.TagHelperDescriptor"/>s that should be added to or
/// removed from the Razor page.
/// </summary>
public string LookupText { get; }

/// <summary>
/// Whether we want to remove <see cref="Compilation.TagHelperDescriptor"/>s from the Razor page.
/// Whether we want to remove <see cref="Compilation.TagHelpers.TagHelperDescriptor"/>s from the Razor page.
/// </summary>
/// <remarks>If <c>true</c> <see cref="GenerateChunk"/> generates <see cref="AddTagHelperChunk"/>s,
/// <see cref="RemoveTagHelperChunk"/>s otherwise.</remarks>
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.AspNet.Razor/Chunks/RemoveTagHelperChunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
namespace Microsoft.AspNet.Razor.Chunks
{
/// <summary>
/// A <see cref="Chunk"/> used to look up <see cref="Compilation.TagHelperDescriptor"/>s that should be ignored
/// A <see cref="Chunk"/> used to look up <see cref="Compilation.TagHelpers.TagHelperDescriptor"/>s that should be ignored
/// within the Razor page.
/// </summary>
public class RemoveTagHelperChunk : Chunk
{
/// <summary>
/// Text used to look up <see cref="Compilation.TagHelperDescriptor"/>s that should be ignored within the Razor
/// Text used to look up <see cref="Compilation.TagHelpers.TagHelperDescriptor"/>s that should be ignored within the Razor
/// page.
/// </summary>
public string LookupText { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ namespace Microsoft.AspNet.Razor.CodeGenerators.Visitors
{
public class CSharpUsingVisitor : CodeVisitor<CSharpCodeWriter>
{
private const string TagHelpersRuntimeNamespace = "Microsoft.AspNet.Razor.TagHelpers";
private static readonly string[] TagHelpersRuntimeNamespaces = new[]
{
"Microsoft.AspNet.Razor.TagHelpers",
"Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal"
};

private bool _foundTagHelpers;

Expand Down Expand Up @@ -93,11 +97,15 @@ protected override void Visit(TagHelperChunk chunk)
{
_foundTagHelpers = true;

if (!ImportedUsings.Contains(TagHelpersRuntimeNamespace))
foreach (var tagHelperRuntimeNamespace in TagHelpersRuntimeNamespaces)
{
// If we find TagHelpers then we need to add the TagHelper runtime namespace to our list of usings.
Writer.WriteUsing(TagHelpersRuntimeNamespace);
ImportedUsings.Add(TagHelpersRuntimeNamespace);
if (!ImportedUsings.Contains(tagHelperRuntimeNamespace))
{
// If we find TagHelpers then we need to add the TagHelper runtime namespaces to our list of
// usings.
Writer.WriteUsing(tagHelperRuntimeNamespace);
ImportedUsings.Add(tagHelperRuntimeNamespace);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.AspNet.Razor.Compilation.TagHelpers;
using Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal;
using Microsoft.AspNet.Razor.Test.Internal;
using Xunit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.AspNet.Testing;
using Microsoft.CodeAnalysis.CSharp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// 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.Globalization;
using System.IO;
using Microsoft.AspNet.Testing;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.Extensions.WebEncoders.Testing;
using Xunit;

namespace Microsoft.AspNet.Razor.TagHelpers
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers.Internal
{
public class DefaultTagHelperContentTest
{
Expand Down Expand Up @@ -102,7 +101,7 @@ public void CanAppendFormatContent()
"HtmlEncode[[First]] HtmlEncode[[Second]] HtmlEncode[[Third]] HtmlEncode[[Fourth]]!",
tagHelperContent.GetContent(new CommonTestEncoder()));
}

[Fact]
public void CanAppendFormat_WithCulture()
{
Expand Down Expand Up @@ -173,7 +172,7 @@ public void IsModified_TrueAfterSetContent()
Assert.True(tagHelperContent.IsModified);
}


[Fact]
public void IsModified_TrueAfterAppend()
{
Expand Down
Loading

0 comments on commit 466bff1

Please sign in to comment.