Moved location of and modified CaseSensitiveTagHelperAttributeComparer

Addresses Mvc https://github.com/aspnet/Mvc/issues/5323
This commit is contained in:
Jass Bagga 2016-11-01 14:47:13 -07:00 committed by GitHub
parent 9741bdad3d
commit 77ed9f22fc
20 changed files with 45 additions and 24 deletions

View File

@ -13,7 +13,7 @@
// Don't run any rules for packages the ADX team creates but doesn't ship.
],
"packages": {
"Microsoft.AspNetCore.Razor.Test.Sources": { },
"Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources": { },
"RazorPageGenerator": { }
}
},

View File

@ -1,13 +1,15 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.IO;
using Microsoft.AspNetCore.Html;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Razor.TagHelpers
namespace Microsoft.AspNetCore.Razor.TagHelpers.Testing
{
public class CaseSensitiveTagHelperAttributeComparer : IEqualityComparer<TagHelperAttribute>
internal class CaseSensitiveTagHelperAttributeComparer : IEqualityComparer<TagHelperAttribute>
{
public readonly static CaseSensitiveTagHelperAttributeComparer Default =
new CaseSensitiveTagHelperAttributeComparer();
@ -27,16 +29,32 @@ namespace Microsoft.AspNetCore.Razor.TagHelpers
return attributeX != null &&
string.Equals(attributeX.Name, attributeY.Name, StringComparison.Ordinal) &&
attributeX.ValueStyle == attributeY.ValueStyle &&
(attributeX.ValueStyle == HtmlAttributeValueStyle.Minimized || Equals(attributeX.Value, attributeY.Value));
(attributeX.ValueStyle == HtmlAttributeValueStyle.Minimized ||
string.Equals(GetString(attributeX.Value), GetString(attributeY.Value)));
}
public int GetHashCode(TagHelperAttribute attribute)
{
var combiner = HashCodeCombiner.Start();
combiner.Add(attribute.Name, StringComparer.Ordinal);
combiner.Add(attribute.GetHashCode());
var hashCodeCombiner = HashCodeCombiner.Start();
hashCodeCombiner.Add(attribute.GetHashCode());
hashCodeCombiner.Add(attribute.Name, StringComparer.Ordinal);
return combiner.CombinedHash;
return hashCodeCombiner.CombinedHash;
}
private string GetString(object value)
{
var htmlContent = value as IHtmlContent;
if (htmlContent != null)
{
using (var writer = new StringWriter())
{
htmlContent.WriteTo(writer, NullHtmlEncoder.Default);
return writer.ToString();
}
}
return value?.ToString() ?? string.Empty;
}
}
}

View File

@ -2,13 +2,12 @@
// 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 Microsoft.AspNetCore.Razor.Compilation.TagHelpers;
using Microsoft.Extensions.Internal;
using Xunit;
namespace Microsoft.AspNetCore.Razor.Test.Internal
namespace Microsoft.AspNetCore.Razor.TagHelpers.Testing
{
internal class CaseSensitiveTagHelperDescriptorComparer : TagHelperDescriptorComparer
{

View File

@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Razor.Compilation.TagHelpers;
using Microsoft.Extensions.Internal;
using Xunit;
namespace Microsoft.AspNetCore.Razor.Test.Internal
namespace Microsoft.AspNetCore.Razor.TagHelpers.Testing
{
internal class CaseSensitiveTagHelperRequiredAttributeDescriptorComparer : TagHelperRequiredAttributeDescriptorComparer
{

View File

@ -6,7 +6,7 @@
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>e3a2a305-634d-4ba6-95db-aa06d6c442b0</ProjectGuid>
<ProjectGuid>f247c7b7-0d29-4aed-b948-ee5c420b0dd3</ProjectGuid>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>

View File

@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Razor.Compilation.TagHelpers;
using Microsoft.Extensions.Internal;
using Xunit;
namespace Microsoft.AspNetCore.Razor.Test.Internal
namespace Microsoft.AspNetCore.Razor.TagHelpers.Testing
{
internal class TagHelperAttributeDescriptorComparer : IEqualityComparer<TagHelperAttributeDescriptor>
{

View File

@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Razor.Compilation.TagHelpers;
using Microsoft.Extensions.Internal;
using Xunit;
namespace Microsoft.AspNetCore.Razor.Test.Internal
namespace Microsoft.AspNetCore.Razor.TagHelpers.Testing
{
internal class TagHelperAttributeDesignTimeDescriptorComparer :
IEqualityComparer<TagHelperAttributeDesignTimeDescriptor>

View File

@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Razor.Compilation.TagHelpers;
using Microsoft.Extensions.Internal;
using Xunit;
namespace Microsoft.AspNetCore.Razor.Test.Internal
namespace Microsoft.AspNetCore.Razor.TagHelpers.Testing
{
internal class TagHelperDesignTimeDescriptorComparer : IEqualityComparer<TagHelperDesignTimeDescriptor>
{

View File

@ -7,7 +7,7 @@ using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Razor.Compilation.TagHelpers;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.AspNetCore.Razor.Test.Internal;
using Microsoft.AspNetCore.Razor.TagHelpers.Testing;
using Xunit;
namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers

View File

@ -8,7 +8,7 @@ using System.Reflection;
using Microsoft.AspNetCore.Razor.Compilation.TagHelpers;
using Microsoft.AspNetCore.Razor.Parser;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.AspNetCore.Razor.Test.Internal;
using Microsoft.AspNetCore.Razor.TagHelpers.Testing;
using Xunit;
namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers

View File

@ -6,7 +6,7 @@ using System.IO;
using System.Reflection;
using Microsoft.AspNetCore.Razor.Compilation.TagHelpers;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.AspNetCore.Razor.Test.Internal;
using Microsoft.AspNetCore.Razor.TagHelpers.Testing;
using Microsoft.AspNetCore.Testing;
using Moq;
using Xunit;

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.AspNetCore.Razor.TagHelpers.Testing;
using Microsoft.Extensions.WebEncoders.Testing;
using Xunit;

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Razor.TagHelpers.Testing;
using Xunit;
namespace Microsoft.AspNetCore.Razor.TagHelpers

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Razor.TagHelpers.Testing;
using Xunit;
namespace Microsoft.AspNetCore.Razor.TagHelpers

View File

@ -4,11 +4,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Razor.Runtime.TagHelpers;
using Microsoft.AspNetCore.Razor.TagHelpers.Testing;
using Microsoft.Extensions.WebEncoders.Testing;
using Xunit;

View File

@ -7,7 +7,7 @@
"dependencies": {
"dotnet-test-xunit": "2.2.0-*",
"Microsoft.AspNetCore.Razor.Runtime": "1.1.0-*",
"Microsoft.AspNetCore.Razor.Test.Sources": {
"Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources": {
"version": "1.1.0-*",
"type": "build"
},

View File

@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Razor.Test.Internal;
using Microsoft.AspNetCore.Razor.TagHelpers.Testing;
using Xunit;
namespace Microsoft.AspNetCore.Razor.Compilation.TagHelpers

View File

@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.AspNetCore.Razor.Test.Internal;
using Microsoft.AspNetCore.Razor.TagHelpers.Testing;
using Newtonsoft.Json;
using Xunit;

View File

@ -3,7 +3,8 @@
"dependencies": {
"dotnet-test-xunit": "2.2.0-*",
"Microsoft.AspNetCore.Razor": "1.1.0-*",
"Microsoft.AspNetCore.Razor.Test.Sources": {
"Microsoft.AspNetCore.Razor.Runtime": "1.1.0-*",
"Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources": {
"version": "1.1.0-*",
"type": "build"
},