Removed constructors from TagHelperAttributeDesignTimeDescriptor,

TagHelperDesignTimeDescriptor and TagHelperDirectiveDescriptor
This commit is contained in:
Ajay Bhargav Baaskaran 2015-08-13 18:48:49 -07:00
parent e9292a0e30
commit 156f859edc
11 changed files with 369 additions and 243 deletions

View File

@ -41,10 +41,12 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
if (documentationDescriptor != null || outputElementHint != null) if (documentationDescriptor != null || outputElementHint != null)
{ {
return new TagHelperDesignTimeDescriptor( return new TagHelperDesignTimeDescriptor
documentationDescriptor?.Summary, {
documentationDescriptor?.Remarks, Summary = documentationDescriptor?.Summary,
outputElementHint); Remarks = documentationDescriptor?.Remarks,
OutputElementHint = outputElementHint
};
} }
return null; return null;
@ -68,9 +70,11 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
if (documentationDescriptor != null) if (documentationDescriptor != null)
{ {
return new TagHelperAttributeDesignTimeDescriptor( return new TagHelperAttributeDesignTimeDescriptor
documentationDescriptor.Summary, {
documentationDescriptor.Remarks); Summary = documentationDescriptor.Summary,
Remarks = documentationDescriptor.Remarks
};
} }
return null; return null;

View File

@ -68,10 +68,12 @@ namespace Microsoft.AspNet.Razor.Parser.TagHelpers
TagHelperDirectiveType.RemoveTagHelper : TagHelperDirectiveType.RemoveTagHelper :
TagHelperDirectiveType.AddTagHelper; TagHelperDirectiveType.AddTagHelper;
var directiveDescriptor = new TagHelperDirectiveDescriptor( var directiveDescriptor = new TagHelperDirectiveDescriptor
chunkGenerator.LookupText, {
span.Start, DirectiveText = chunkGenerator.LookupText,
directive); Location = span.Start,
DirectiveType = directive
};
_directiveDescriptors.Add(directiveDescriptor); _directiveDescriptors.Add(directiveDescriptor);
} }
@ -79,10 +81,12 @@ namespace Microsoft.AspNet.Razor.Parser.TagHelpers
{ {
var chunkGenerator = (TagHelperPrefixDirectiveChunkGenerator)span.ChunkGenerator; var chunkGenerator = (TagHelperPrefixDirectiveChunkGenerator)span.ChunkGenerator;
var directiveDescriptor = new TagHelperDirectiveDescriptor( var directiveDescriptor = new TagHelperDirectiveDescriptor
chunkGenerator.Prefix, {
span.Start, DirectiveText = chunkGenerator.Prefix,
TagHelperDirectiveType.TagHelperPrefix); Location = span.Start,
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
};
_directiveDescriptors.Add(directiveDescriptor); _directiveDescriptors.Add(directiveDescriptor);
} }

View File

@ -8,25 +8,14 @@ namespace Microsoft.AspNet.Razor.TagHelpers
/// </summary> /// </summary>
public class TagHelperAttributeDesignTimeDescriptor public class TagHelperAttributeDesignTimeDescriptor
{ {
/// <summary>
/// Instantiates a new instance of <see cref="TagHelperDesignTimeDescriptor"/>.
/// </summary>
/// <param name="summary">A summary on how to use a tag helper.</param>
/// <param name="remarks">Remarks on how to use a tag helper.</param>
public TagHelperAttributeDesignTimeDescriptor(string summary, string remarks)
{
Summary = summary;
Remarks = remarks;
}
/// <summary> /// <summary>
/// A summary of how to use a tag helper. /// A summary of how to use a tag helper.
/// </summary> /// </summary>
public string Summary { get; } public string Summary { get; set; }
/// <summary> /// <summary>
/// Remarks about how to use a tag helper. /// Remarks about how to use a tag helper.
/// </summary> /// </summary>
public string Remarks { get; } public string Remarks { get; set; }
} }
} }

View File

@ -8,28 +8,15 @@ namespace Microsoft.AspNet.Razor.TagHelpers
/// </summary> /// </summary>
public class TagHelperDesignTimeDescriptor public class TagHelperDesignTimeDescriptor
{ {
/// <summary>
/// Instantiates a new instance of <see cref="TagHelperDesignTimeDescriptor"/>.
/// </summary>
/// <param name="summary">A summary on how to use a tag helper.</param>
/// <param name="remarks">Remarks on how to use a tag helper.</param>
/// <param name="outputElementHint">The HTML element a tag helper may output.</param>
public TagHelperDesignTimeDescriptor(string summary, string remarks, string outputElementHint)
{
Summary = summary;
Remarks = remarks;
OutputElementHint = outputElementHint;
}
/// <summary> /// <summary>
/// A summary of how to use a tag helper. /// A summary of how to use a tag helper.
/// </summary> /// </summary>
public string Summary { get; } public string Summary { get; set; }
/// <summary> /// <summary>
/// Remarks about how to use a tag helper. /// Remarks about how to use a tag helper.
/// </summary> /// </summary>
public string Remarks { get; } public string Remarks { get; set; }
/// <summary> /// <summary>
/// The HTML element a tag helper may output. /// The HTML element a tag helper may output.
@ -37,6 +24,6 @@ namespace Microsoft.AspNet.Razor.TagHelpers
/// <remarks> /// <remarks>
/// In IDEs supporting IntelliSense, may override the HTML information provided at design time. /// In IDEs supporting IntelliSense, may override the HTML information provided at design time.
/// </remarks> /// </remarks>
public string OutputElementHint { get; } public string OutputElementHint { get; set; }
} }
} }

View File

@ -10,42 +10,19 @@ namespace Microsoft.AspNet.Razor.TagHelpers
/// </summary> /// </summary>
public class TagHelperDirectiveDescriptor public class TagHelperDirectiveDescriptor
{ {
// Internal for testing purposes.
internal TagHelperDirectiveDescriptor(string directiveText,
TagHelperDirectiveType directiveType)
: this(directiveText, SourceLocation.Zero, directiveType)
{
}
/// <summary>
/// Instantiates a new instance of <see cref="TagHelperDirectiveDescriptor"/>.
/// </summary>
/// <param name="directiveText">A <see cref="string"/> used to understand tag helper
/// <see cref="System.Type"/>s.</param>
/// <param name="location">The <see cref="SourceLocation"/> of the directive.</param>
/// <param name="directiveType">The <see cref="TagHelperDirectiveType"/> of this directive.</param>
public TagHelperDirectiveDescriptor([NotNull] string directiveText,
SourceLocation location,
TagHelperDirectiveType directiveType)
{
DirectiveText = directiveText;
Location = location;
DirectiveType = directiveType;
}
/// <summary> /// <summary>
/// A <see cref="string"/> used to find tag helper <see cref="System.Type"/>s. /// A <see cref="string"/> used to find tag helper <see cref="System.Type"/>s.
/// </summary> /// </summary>
public string DirectiveText { get; } public string DirectiveText { get; [param: NotNull] set; }
/// <summary>
/// The <see cref="TagHelperDirectiveType"/> of this directive.
/// </summary>
public TagHelperDirectiveType DirectiveType { get; }
/// <summary> /// <summary>
/// The <see cref="SourceLocation"/> of the directive. /// The <see cref="SourceLocation"/> of the directive.
/// </summary> /// </summary>
public SourceLocation Location { get; } public SourceLocation Location { get; set; } = SourceLocation.Zero;
/// <summary>
/// The <see cref="TagHelperDirectiveType"/> of this directive.
/// </summary>
public TagHelperDirectiveType DirectiveType { get; set; }
} }
} }

View File

@ -545,7 +545,6 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Arrange // Arrange
var tagHelperContent = new DefaultTagHelperContent(); var tagHelperContent = new DefaultTagHelperContent();
var expected = "First Second Third"; var expected = "First Second Third";
var i = 0;
// Act // Act
tagHelperContent.SetContent("First ").AppendFormat("{0} Third", "Second"); tagHelperContent.SetContent("First ").AppendFormat("{0} Third", "Second");
@ -560,7 +559,6 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Arrange // Arrange
var tagHelperContent = new DefaultTagHelperContent(); var tagHelperContent = new DefaultTagHelperContent();
var expected = "First Second Third Fourth"; var expected = "First Second Third Fourth";
var i = 0;
// Act // Act
tagHelperContent tagHelperContent

View File

@ -138,10 +138,10 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
attributes: Enumerable.Empty<TagHelperAttributeDescriptor>(), attributes: Enumerable.Empty<TagHelperAttributeDescriptor>(),
requiredAttributes: Enumerable.Empty<string>(), requiredAttributes: Enumerable.Empty<string>(),
tagStructure: default(TagStructure), tagStructure: default(TagStructure),
designTimeDescriptor: new TagHelperDesignTimeDescriptor( designTimeDescriptor: new TagHelperDesignTimeDescriptor
summary: null, {
remarks: null, OutputElementHint = "strong"
outputElementHint: "strong")) })
} }
}, },
{ {
@ -156,10 +156,10 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
attributes: Enumerable.Empty<TagHelperAttributeDescriptor>(), attributes: Enumerable.Empty<TagHelperAttributeDescriptor>(),
requiredAttributes: Enumerable.Empty<string>(), requiredAttributes: Enumerable.Empty<string>(),
tagStructure: default(TagStructure), tagStructure: default(TagStructure),
designTimeDescriptor: new TagHelperDesignTimeDescriptor( designTimeDescriptor: new TagHelperDesignTimeDescriptor
summary: null, {
remarks: null, OutputElementHint = "div"
outputElementHint: "div")), }),
new TagHelperDescriptor( new TagHelperDescriptor(
prefix: string.Empty, prefix: string.Empty,
tagName: "p", tagName: "p",
@ -168,10 +168,10 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
attributes: Enumerable.Empty<TagHelperAttributeDescriptor>(), attributes: Enumerable.Empty<TagHelperAttributeDescriptor>(),
requiredAttributes: Enumerable.Empty<string>(), requiredAttributes: Enumerable.Empty<string>(),
tagStructure: default(TagStructure), tagStructure: default(TagStructure),
designTimeDescriptor: new TagHelperDesignTimeDescriptor( designTimeDescriptor: new TagHelperDesignTimeDescriptor
summary: null, {
remarks: null, OutputElementHint = "div"
outputElementHint: "div")) })
} }
} }
}; };

View File

@ -82,14 +82,18 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
defaultAssemblyLookups, defaultAssemblyLookups,
new[] new[]
{ {
new TagHelperDirectiveDescriptor( new TagHelperDirectiveDescriptor
"th:", {
directiveLocation1, DirectiveText = "th:",
TagHelperDirectiveType.TagHelperPrefix), Location = directiveLocation1,
new TagHelperDirectiveDescriptor( DirectiveType = TagHelperDirectiveType.TagHelperPrefix
"different", },
directiveLocation2, new TagHelperDirectiveDescriptor
TagHelperDirectiveType.TagHelperPrefix) {
DirectiveText = "different",
Location = directiveLocation2,
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
}
}, },
new TagHelperDescriptor[0], new TagHelperDescriptor[0],
new[] new[]
@ -103,18 +107,24 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
defaultAssemblyLookups, defaultAssemblyLookups,
new[] new[]
{ {
new TagHelperDirectiveDescriptor( new TagHelperDirectiveDescriptor
"th:", {
directiveLocation1, DirectiveText = "th:",
TagHelperDirectiveType.TagHelperPrefix), Location = directiveLocation1,
new TagHelperDirectiveDescriptor( DirectiveType = TagHelperDirectiveType.TagHelperPrefix
"different", },
directiveLocation2, new TagHelperDirectiveDescriptor
TagHelperDirectiveType.TagHelperPrefix), {
new TagHelperDirectiveDescriptor( DirectiveText = "different",
"*Plain*, " + assemblyA, Location = directiveLocation2,
directiveLocation1, DirectiveType = TagHelperDirectiveType.TagHelperPrefix
TagHelperDirectiveType.AddTagHelper), },
new TagHelperDirectiveDescriptor
{
DirectiveText = "*Plain*, " + assemblyA,
Location = directiveLocation1,
DirectiveType = TagHelperDirectiveType.AddTagHelper
}
}, },
new[] { CreatePrefixedValidPlainDescriptor("th:") }, new[] { CreatePrefixedValidPlainDescriptor("th:") },
new[] new[]
@ -128,22 +138,30 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
defaultAssemblyLookups, defaultAssemblyLookups,
new[] new[]
{ {
new TagHelperDirectiveDescriptor( new TagHelperDirectiveDescriptor
"th:", {
directiveLocation1, DirectiveText = "th:",
TagHelperDirectiveType.TagHelperPrefix), Location = directiveLocation1,
new TagHelperDirectiveDescriptor( DirectiveType = TagHelperDirectiveType.TagHelperPrefix
"different", },
directiveLocation2, new TagHelperDirectiveDescriptor
TagHelperDirectiveType.TagHelperPrefix), {
new TagHelperDirectiveDescriptor( DirectiveText = "different",
"*Plain*, " + assemblyA, Location = directiveLocation2,
directiveLocation1, DirectiveType = TagHelperDirectiveType.TagHelperPrefix
TagHelperDirectiveType.AddTagHelper), },
new TagHelperDirectiveDescriptor( new TagHelperDirectiveDescriptor
"*String*, " + assemblyB, {
directiveLocation1, DirectiveText = "*Plain*, " + assemblyA,
TagHelperDirectiveType.AddTagHelper), Location = directiveLocation1,
DirectiveType = TagHelperDirectiveType.AddTagHelper
},
new TagHelperDirectiveDescriptor
{
DirectiveText = "*String*, " + assemblyB,
Location = directiveLocation1,
DirectiveType = TagHelperDirectiveType.AddTagHelper
}
}, },
new[] { CreatePrefixedValidPlainDescriptor("th:"), CreatePrefixedStringDescriptor("th:") }, new[] { CreatePrefixedValidPlainDescriptor("th:"), CreatePrefixedStringDescriptor("th:") },
new[] new[]
@ -157,10 +175,12 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
defaultAssemblyLookups, defaultAssemblyLookups,
new[] new[]
{ {
new TagHelperDirectiveDescriptor( new TagHelperDirectiveDescriptor
"th ", {
directiveLocation1, DirectiveText = "th ",
TagHelperDirectiveType.TagHelperPrefix), Location = directiveLocation1,
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
},
}, },
new TagHelperDescriptor[0], new TagHelperDescriptor[0],
new[] new[]
@ -178,10 +198,12 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
defaultAssemblyLookups, defaultAssemblyLookups,
new[] new[]
{ {
new TagHelperDirectiveDescriptor( new TagHelperDirectiveDescriptor
"th\t", {
directiveLocation1, DirectiveText = "th\t",
TagHelperDirectiveType.TagHelperPrefix), Location = directiveLocation1,
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
}
}, },
new TagHelperDescriptor[0], new TagHelperDescriptor[0],
new[] new[]
@ -199,10 +221,12 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
defaultAssemblyLookups, defaultAssemblyLookups,
new[] new[]
{ {
new TagHelperDirectiveDescriptor( new TagHelperDirectiveDescriptor
"th" + Environment.NewLine, {
directiveLocation1, DirectiveText = "th" + Environment.NewLine,
TagHelperDirectiveType.TagHelperPrefix), Location = directiveLocation1,
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
}
}, },
new TagHelperDescriptor[0], new TagHelperDescriptor[0],
new[] new[]
@ -220,10 +244,12 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
defaultAssemblyLookups, defaultAssemblyLookups,
new[] new[]
{ {
new TagHelperDirectiveDescriptor( new TagHelperDirectiveDescriptor
" th ", {
directiveLocation1, DirectiveText = " th ",
TagHelperDirectiveType.TagHelperPrefix), Location = directiveLocation1,
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
}
}, },
new TagHelperDescriptor[0], new TagHelperDescriptor[0],
new[] new[]
@ -241,10 +267,12 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
defaultAssemblyLookups, defaultAssemblyLookups,
new[] new[]
{ {
new TagHelperDirectiveDescriptor( new TagHelperDirectiveDescriptor
"@", {
directiveLocation1, DirectiveText = "@",
TagHelperDirectiveType.TagHelperPrefix), Location = directiveLocation1,
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
}
}, },
new TagHelperDescriptor[0], new TagHelperDescriptor[0],
new[] new[]
@ -262,10 +290,12 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
defaultAssemblyLookups, defaultAssemblyLookups,
new[] new[]
{ {
new TagHelperDirectiveDescriptor( new TagHelperDirectiveDescriptor
"t@h", {
directiveLocation1, DirectiveText = "t@h",
TagHelperDirectiveType.TagHelperPrefix), Location = directiveLocation1,
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
}
}, },
new TagHelperDescriptor[0], new TagHelperDescriptor[0],
new[] new[]
@ -283,10 +313,12 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
defaultAssemblyLookups, defaultAssemblyLookups,
new[] new[]
{ {
new TagHelperDirectiveDescriptor( new TagHelperDirectiveDescriptor
"!", {
directiveLocation1, DirectiveText = "!",
TagHelperDirectiveType.TagHelperPrefix), Location = directiveLocation1,
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
}
}, },
new TagHelperDescriptor[0], new TagHelperDescriptor[0],
new[] new[]
@ -304,10 +336,12 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
defaultAssemblyLookups, defaultAssemblyLookups,
new[] new[]
{ {
new TagHelperDirectiveDescriptor( new TagHelperDirectiveDescriptor
"!th", {
directiveLocation1, DirectiveText = "!th",
TagHelperDirectiveType.TagHelperPrefix), Location = directiveLocation1,
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
}
}, },
new TagHelperDescriptor[0], new TagHelperDescriptor[0],
new[] new[]
@ -1341,7 +1375,15 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
"format is: \"typeName, assemblyName\".", "format is: \"typeName, assemblyName\".",
lookupText); lookupText);
var resolutionContext = new TagHelperDescriptorResolutionContext( var resolutionContext = new TagHelperDescriptorResolutionContext(
new[] { new TagHelperDirectiveDescriptor(lookupText, documentLocation, directiveType) }, new[]
{
new TagHelperDirectiveDescriptor
{
DirectiveText = lookupText,
Location = documentLocation,
DirectiveType = directiveType
}
},
errorSink); errorSink);
// Act // Act
@ -1367,7 +1409,15 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
var expectedError = new Exception("A custom exception"); var expectedError = new Exception("A custom exception");
var tagHelperDescriptorResolver = new ThrowingTagHelperDescriptorResolver(expectedError); var tagHelperDescriptorResolver = new ThrowingTagHelperDescriptorResolver(expectedError);
var resolutionContext = new TagHelperDescriptorResolutionContext( var resolutionContext = new TagHelperDescriptorResolutionContext(
new[] { new TagHelperDirectiveDescriptor("A custom, lookup text", documentLocation, directiveType) }, new[]
{
new TagHelperDirectiveDescriptor
{
DirectiveText = "A custom, lookup text",
Location = documentLocation,
DirectiveType = directiveType
}
},
errorSink); errorSink);
@ -1431,7 +1481,12 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
string directiveText, string directiveText,
TagHelperDirectiveType directiveType) TagHelperDirectiveType directiveType)
{ {
return new TagHelperDirectiveDescriptor(directiveText, SourceLocation.Zero, directiveType); return new TagHelperDirectiveDescriptor
{
DirectiveText = directiveText,
Location = SourceLocation.Zero,
DirectiveType = directiveType
};
} }
private class TestTagHelperDescriptorResolver : TagHelperDescriptorResolver private class TestTagHelperDescriptorResolver : TagHelperDescriptorResolver

View File

@ -51,17 +51,17 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
{ typeof(InheritedOutputElementHintTagHelper), null }, { typeof(InheritedOutputElementHintTagHelper), null },
{ {
typeof(OutputElementHintTagHelper), typeof(OutputElementHintTagHelper),
new TagHelperDesignTimeDescriptor( new TagHelperDesignTimeDescriptor
summary: null, {
remarks: null, OutputElementHint = "hinted-value"
outputElementHint: "hinted-value") }
}, },
{ {
typeof(OverriddenOutputElementHintTagHelper), typeof(OverriddenOutputElementHintTagHelper),
new TagHelperDesignTimeDescriptor( new TagHelperDesignTimeDescriptor
summary: null, {
remarks: null, OutputElementHint = "overridden"
outputElementHint: "overridden") }
}, },
}; };
} }
@ -90,10 +90,10 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
var nonExistentCodeBase = defaultCodeBase.Replace("TestFiles", "TestFile"); var nonExistentCodeBase = defaultCodeBase.Replace("TestFiles", "TestFile");
var invalidLocation = defaultLocation + '\0'; var invalidLocation = defaultLocation + '\0';
var invalidCodeBase = defaultCodeBase + '\0'; var invalidCodeBase = defaultCodeBase + '\0';
var onlyHint = new TagHelperDesignTimeDescriptor( var onlyHint = new TagHelperDesignTimeDescriptor
summary: null, {
remarks: null, OutputElementHint = "p"
outputElementHint: "p"); };
// tagHelperType, expectedDesignTimeDescriptor // tagHelperType, expectedDesignTimeDescriptor
return new TheoryData<Type, TagHelperDesignTimeDescriptor> return new TheoryData<Type, TagHelperDesignTimeDescriptor>
@ -101,18 +101,30 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
{ CreateDocumentationTagHelperType(location: null, codeBase: null), onlyHint }, { CreateDocumentationTagHelperType(location: null, codeBase: null), onlyHint },
{ {
CreateDocumentationTagHelperType(defaultLocation, codeBase: null), CreateDocumentationTagHelperType(defaultLocation, codeBase: null),
new TagHelperDesignTimeDescriptor( new TagHelperDesignTimeDescriptor
TypeSummary, {
TypeRemarks, Summary = TypeSummary,
outputElementHint: "p") Remarks = TypeRemarks,
OutputElementHint = "p"
}
}, },
{ {
CreateDocumentationTagHelperType(location: null, codeBase: defaultCodeBase), CreateDocumentationTagHelperType(location: null, codeBase: defaultCodeBase),
new TagHelperDesignTimeDescriptor(TypeSummary, TypeRemarks, outputElementHint: "p") new TagHelperDesignTimeDescriptor
{
Summary = TypeSummary,
Remarks = TypeRemarks,
OutputElementHint = "p"
}
}, },
{ {
CreateDocumentationTagHelperType(defaultLocation, defaultCodeBase), CreateDocumentationTagHelperType(defaultLocation, defaultCodeBase),
new TagHelperDesignTimeDescriptor(TypeSummary, TypeRemarks, outputElementHint: "p") new TagHelperDesignTimeDescriptor
{
Summary = TypeSummary,
Remarks = TypeRemarks,
OutputElementHint = "p"
}
}, },
{ CreateType<SingleAttributeTagHelper>(defaultLocation, defaultCodeBase), null }, { CreateType<SingleAttributeTagHelper>(defaultLocation, defaultCodeBase), null },
{ CreateDocumentationTagHelperType(nonExistentLocation, codeBase: null), onlyHint }, { CreateDocumentationTagHelperType(nonExistentLocation, codeBase: null), onlyHint },
@ -145,42 +157,52 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
{ {
{ {
CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null), CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null),
new TagHelperDesignTimeDescriptor( new TagHelperDesignTimeDescriptor
summary: "en-GB: " + TypeSummary, {
remarks: "en-GB: " + TypeRemarks, Summary = "en-GB: " + TypeSummary,
outputElementHint: "p"), Remarks = "en-GB: " + TypeRemarks,
OutputElementHint = "p"
},
"en-GB" "en-GB"
}, },
{ {
CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null), CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null),
new TagHelperDesignTimeDescriptor( new TagHelperDesignTimeDescriptor
summary: "en: " + TypeSummary, {
remarks: "en: " + TypeRemarks, Summary = "en: " + TypeSummary,
outputElementHint: "p"), Remarks = "en: " + TypeRemarks,
OutputElementHint = "p"
},
"en-US" "en-US"
}, },
{ {
CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null), CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null),
new TagHelperDesignTimeDescriptor( new TagHelperDesignTimeDescriptor
summary: "fr-FR: " + TypeSummary, {
remarks: "fr-FR: " + TypeRemarks, Summary = "fr-FR: " + TypeSummary,
outputElementHint: "p"), Remarks = "fr-FR: " + TypeRemarks,
OutputElementHint = "p"
},
"fr-FR" "fr-FR"
}, },
{ {
CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null), CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null),
new TagHelperDesignTimeDescriptor( new TagHelperDesignTimeDescriptor
summary: "fr: " + TypeSummary, {
remarks: "fr: " + TypeRemarks, Summary = "fr: " + TypeSummary,
outputElementHint: "p"), Remarks = "fr: " + TypeRemarks,
OutputElementHint = "p"
},
"fr-BE" "fr-BE"
}, },
{ {
CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null), CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null),
new TagHelperDesignTimeDescriptor( new TagHelperDesignTimeDescriptor
summary: "nl-BE: " + TypeSummary, {
remarks: "nl-BE: " + TypeRemarks, Summary = "nl-BE: " + TypeSummary,
outputElementHint: "p"), Remarks = "nl-BE: " + TypeRemarks,
OutputElementHint = "p"
},
"nl-BE" "nl-BE"
} }
}; };
@ -244,53 +266,77 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
{ {
CreateDocumentationTagHelperType(defaultLocation, codeBase: null), CreateDocumentationTagHelperType(defaultLocation, codeBase: null),
nameof(DocumentedTagHelper.SummaryProperty), nameof(DocumentedTagHelper.SummaryProperty),
new TagHelperAttributeDesignTimeDescriptor(PropertySummary, remarks: null) new TagHelperAttributeDesignTimeDescriptor
{
Summary = PropertySummary
}
}, },
{ {
CreateDocumentationTagHelperType(defaultLocation, codeBase: null), CreateDocumentationTagHelperType(defaultLocation, codeBase: null),
nameof(DocumentedTagHelper.RemarksProperty), nameof(DocumentedTagHelper.RemarksProperty),
new TagHelperAttributeDesignTimeDescriptor(summary: null, remarks: PropertyRemarks) new TagHelperAttributeDesignTimeDescriptor
{
Remarks = PropertyRemarks
}
}, },
{ {
CreateDocumentationTagHelperType(defaultLocation, codeBase: null), CreateDocumentationTagHelperType(defaultLocation, codeBase: null),
nameof(DocumentedTagHelper.RemarksAndSummaryProperty), nameof(DocumentedTagHelper.RemarksAndSummaryProperty),
new TagHelperAttributeDesignTimeDescriptor( new TagHelperAttributeDesignTimeDescriptor
PropertyWithSummaryAndRemarks_Summary, {
PropertyWithSummaryAndRemarks_Remarks) Summary = PropertyWithSummaryAndRemarks_Summary,
Remarks = PropertyWithSummaryAndRemarks_Remarks
}
}, },
{ {
CreateDocumentationTagHelperType(location: null, codeBase: defaultCodeBase), CreateDocumentationTagHelperType(location: null, codeBase: defaultCodeBase),
nameof(DocumentedTagHelper.SummaryProperty), nameof(DocumentedTagHelper.SummaryProperty),
new TagHelperAttributeDesignTimeDescriptor(PropertySummary, remarks: null) new TagHelperAttributeDesignTimeDescriptor
{
Summary = PropertySummary
}
}, },
{ {
CreateDocumentationTagHelperType(location: null, codeBase: defaultCodeBase), CreateDocumentationTagHelperType(location: null, codeBase: defaultCodeBase),
nameof(DocumentedTagHelper.RemarksProperty), nameof(DocumentedTagHelper.RemarksProperty),
new TagHelperAttributeDesignTimeDescriptor(summary: null, remarks: PropertyRemarks) new TagHelperAttributeDesignTimeDescriptor
{
Remarks = PropertyRemarks
}
}, },
{ {
CreateDocumentationTagHelperType(location: null, codeBase: defaultCodeBase), CreateDocumentationTagHelperType(location: null, codeBase: defaultCodeBase),
nameof(DocumentedTagHelper.RemarksAndSummaryProperty), nameof(DocumentedTagHelper.RemarksAndSummaryProperty),
new TagHelperAttributeDesignTimeDescriptor( new TagHelperAttributeDesignTimeDescriptor
PropertyWithSummaryAndRemarks_Summary, {
PropertyWithSummaryAndRemarks_Remarks) Summary = PropertyWithSummaryAndRemarks_Summary,
Remarks = PropertyWithSummaryAndRemarks_Remarks
}
}, },
{ {
CreateDocumentationTagHelperType(defaultLocation, defaultCodeBase), CreateDocumentationTagHelperType(defaultLocation, defaultCodeBase),
nameof(DocumentedTagHelper.SummaryProperty), nameof(DocumentedTagHelper.SummaryProperty),
new TagHelperAttributeDesignTimeDescriptor(PropertySummary, remarks: null) new TagHelperAttributeDesignTimeDescriptor
{
Summary = PropertySummary
}
}, },
{ {
CreateDocumentationTagHelperType(defaultLocation, defaultCodeBase), CreateDocumentationTagHelperType(defaultLocation, defaultCodeBase),
nameof(DocumentedTagHelper.RemarksProperty), nameof(DocumentedTagHelper.RemarksProperty),
new TagHelperAttributeDesignTimeDescriptor(summary: null, remarks: PropertyRemarks) new TagHelperAttributeDesignTimeDescriptor
{
Remarks = PropertyRemarks
}
}, },
{ {
CreateDocumentationTagHelperType(defaultLocation, defaultCodeBase), CreateDocumentationTagHelperType(defaultLocation, defaultCodeBase),
nameof(DocumentedTagHelper.RemarksAndSummaryProperty), nameof(DocumentedTagHelper.RemarksAndSummaryProperty),
new TagHelperAttributeDesignTimeDescriptor( new TagHelperAttributeDesignTimeDescriptor
PropertyWithSummaryAndRemarks_Summary, {
PropertyWithSummaryAndRemarks_Remarks) Summary = PropertyWithSummaryAndRemarks_Summary,
Remarks = PropertyWithSummaryAndRemarks_Remarks
}
}, },
{ {
CreateDocumentationTagHelperType(nonExistentLocation, codeBase: null), CreateDocumentationTagHelperType(nonExistentLocation, codeBase: null),
@ -348,37 +394,47 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
{ {
{ {
CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null), CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null),
new TagHelperAttributeDesignTimeDescriptor( new TagHelperAttributeDesignTimeDescriptor
summary: "en-GB: " + PropertyWithSummaryAndRemarks_Summary, {
remarks: "en-GB: " + PropertyWithSummaryAndRemarks_Remarks), Summary = "en-GB: " + PropertyWithSummaryAndRemarks_Summary,
Remarks = "en-GB: " + PropertyWithSummaryAndRemarks_Remarks
},
"en-GB" "en-GB"
}, },
{ {
CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null), CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null),
new TagHelperAttributeDesignTimeDescriptor( new TagHelperAttributeDesignTimeDescriptor
summary: "en: " + PropertyWithSummaryAndRemarks_Summary, {
remarks: "en: " + PropertyWithSummaryAndRemarks_Remarks), Summary = "en: " + PropertyWithSummaryAndRemarks_Summary,
Remarks = "en: " + PropertyWithSummaryAndRemarks_Remarks
},
"en-US" "en-US"
}, },
{ {
CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null), CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null),
new TagHelperAttributeDesignTimeDescriptor( new TagHelperAttributeDesignTimeDescriptor
summary: "fr-FR: " + PropertyWithSummaryAndRemarks_Summary, {
remarks: "fr-FR: " + PropertyWithSummaryAndRemarks_Remarks), Summary = "fr-FR: " + PropertyWithSummaryAndRemarks_Summary,
Remarks = "fr-FR: " + PropertyWithSummaryAndRemarks_Remarks
},
"fr-FR" "fr-FR"
}, },
{ {
CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null), CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null),
new TagHelperAttributeDesignTimeDescriptor( new TagHelperAttributeDesignTimeDescriptor
summary: "fr: " + PropertyWithSummaryAndRemarks_Summary, {
remarks: "fr: " + PropertyWithSummaryAndRemarks_Remarks), Summary = "fr: " + PropertyWithSummaryAndRemarks_Summary,
Remarks = "fr: " + PropertyWithSummaryAndRemarks_Remarks
},
"fr-BE" "fr-BE"
}, },
{ {
CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null), CreateDocumentationTagHelperType(LocalizedDocumentedAssemblyLocation, codeBase: null),
new TagHelperAttributeDesignTimeDescriptor( new TagHelperAttributeDesignTimeDescriptor
summary: "nl-BE: " + PropertyWithSummaryAndRemarks_Summary, {
remarks: "nl-BE: " + PropertyWithSummaryAndRemarks_Remarks), Summary = "nl-BE: " + PropertyWithSummaryAndRemarks_Summary,
Remarks = "nl-BE: " + PropertyWithSummaryAndRemarks_Remarks
},
"nl-BE" "nl-BE"
} }
}; };

View File

@ -24,7 +24,12 @@ namespace Microsoft.AspNet.Razor.TagHelpers
attributes: Enumerable.Empty<TagHelperAttributeDescriptor>(), attributes: Enumerable.Empty<TagHelperAttributeDescriptor>(),
requiredAttributes: new[] { "required attribute one", "required attribute two" }, requiredAttributes: new[] { "required attribute one", "required attribute two" },
tagStructure: TagStructure.Unspecified, tagStructure: TagStructure.Unspecified,
designTimeDescriptor: new TagHelperDesignTimeDescriptor("usage summary", "usage remarks", "some-tag")); designTimeDescriptor: new TagHelperDesignTimeDescriptor
{
Summary = "usage summary",
Remarks = "usage remarks",
OutputElementHint = "some-tag"
});
var expectedSerializedDescriptor = var expectedSerializedDescriptor =
$"{{\"{ nameof(TagHelperDescriptor.Prefix) }\":\"prefix:\"," + $"{{\"{ nameof(TagHelperDescriptor.Prefix) }\":\"prefix:\"," +
@ -188,7 +193,12 @@ namespace Microsoft.AspNet.Razor.TagHelpers
attributes: Enumerable.Empty<TagHelperAttributeDescriptor>(), attributes: Enumerable.Empty<TagHelperAttributeDescriptor>(),
requiredAttributes: new[] { "required attribute one", "required attribute two" }, requiredAttributes: new[] { "required attribute one", "required attribute two" },
tagStructure: TagStructure.WithoutEndTag, tagStructure: TagStructure.WithoutEndTag,
designTimeDescriptor: new TagHelperDesignTimeDescriptor("usage summary", "usage remarks", "some-tag")); designTimeDescriptor: new TagHelperDesignTimeDescriptor
{
Summary = "usage summary",
Remarks = "usage remarks",
OutputElementHint = "some-tag"
});
// Act // Act
var descriptor = JsonConvert.DeserializeObject<TagHelperDescriptor>(serializedDescriptor); var descriptor = JsonConvert.DeserializeObject<TagHelperDescriptor>(serializedDescriptor);

View File

@ -58,10 +58,26 @@ namespace Microsoft.AspNet.Razor.TagHelpers
Factory.Code("\"four\"").AsTagHelperPrefixDirective("four")); Factory.Code("\"four\"").AsTagHelperPrefixDirective("four"));
var expectedDescriptors = new TagHelperDirectiveDescriptor[] var expectedDescriptors = new TagHelperDirectiveDescriptor[]
{ {
new TagHelperDirectiveDescriptor("one", TagHelperDirectiveType.AddTagHelper), new TagHelperDirectiveDescriptor
new TagHelperDirectiveDescriptor("two", TagHelperDirectiveType.RemoveTagHelper), {
new TagHelperDirectiveDescriptor("three", TagHelperDirectiveType.RemoveTagHelper), DirectiveText = "one",
new TagHelperDirectiveDescriptor("four", TagHelperDirectiveType.TagHelperPrefix), DirectiveType = TagHelperDirectiveType.AddTagHelper
},
new TagHelperDirectiveDescriptor
{
DirectiveText = "two",
DirectiveType = TagHelperDirectiveType.RemoveTagHelper
},
new TagHelperDirectiveDescriptor
{
DirectiveText = "three",
DirectiveType = TagHelperDirectiveType.RemoveTagHelper
},
new TagHelperDirectiveDescriptor
{
DirectiveText = "four",
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
}
}; };
// Act // Act
@ -81,14 +97,34 @@ namespace Microsoft.AspNet.Razor.TagHelpers
var resolver = new TestTagHelperDescriptorResolver(); var resolver = new TestTagHelperDescriptorResolver();
var expectedInitialDirectiveDescriptors = new TagHelperDirectiveDescriptor[] var expectedInitialDirectiveDescriptors = new TagHelperDirectiveDescriptor[]
{ {
new TagHelperDirectiveDescriptor("one", TagHelperDirectiveType.AddTagHelper), new TagHelperDirectiveDescriptor
new TagHelperDirectiveDescriptor("two", TagHelperDirectiveType.RemoveTagHelper), {
new TagHelperDirectiveDescriptor("three", TagHelperDirectiveType.RemoveTagHelper), DirectiveText = "one",
new TagHelperDirectiveDescriptor("four", TagHelperDirectiveType.TagHelperPrefix), DirectiveType = TagHelperDirectiveType.AddTagHelper
},
new TagHelperDirectiveDescriptor
{
DirectiveText = "two",
DirectiveType = TagHelperDirectiveType.RemoveTagHelper
},
new TagHelperDirectiveDescriptor
{
DirectiveText = "three",
DirectiveType = TagHelperDirectiveType.RemoveTagHelper
},
new TagHelperDirectiveDescriptor
{
DirectiveText = "four",
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
}
}; };
var expectedEndDirectiveDescriptors = new TagHelperDirectiveDescriptor[] var expectedEndDirectiveDescriptors = new TagHelperDirectiveDescriptor[]
{ {
new TagHelperDirectiveDescriptor("custom", TagHelperDirectiveType.AddTagHelper) new TagHelperDirectiveDescriptor
{
DirectiveText = "custom",
DirectiveType = TagHelperDirectiveType.AddTagHelper
}
}; };
var tagHelperDirectiveSpanVisitor = new CustomTagHelperDirectiveSpanVisitor( var tagHelperDirectiveSpanVisitor = new CustomTagHelperDirectiveSpanVisitor(
resolver, resolver,
@ -131,7 +167,11 @@ namespace Microsoft.AspNet.Razor.TagHelpers
.Accepts(AcceptedCharacters.None), .Accepts(AcceptedCharacters.None),
Factory.Code("\"something\"").AsTagHelperPrefixDirective("something"))); Factory.Code("\"something\"").AsTagHelperPrefixDirective("something")));
var expectedDirectiveDescriptor = var expectedDirectiveDescriptor =
new TagHelperDirectiveDescriptor("something", TagHelperDirectiveType.TagHelperPrefix); new TagHelperDirectiveDescriptor
{
DirectiveText = "something",
DirectiveType = TagHelperDirectiveType.TagHelperPrefix
};
// Act // Act
tagHelperDirectiveSpanVisitor.GetDescriptors(document); tagHelperDirectiveSpanVisitor.GetDescriptors(document);
@ -157,8 +197,11 @@ namespace Microsoft.AspNet.Razor.TagHelpers
.Accepts(AcceptedCharacters.None), .Accepts(AcceptedCharacters.None),
Factory.Code("\"something\"").AsAddTagHelper("something")) Factory.Code("\"something\"").AsAddTagHelper("something"))
); );
var expectedRegistration = var expectedRegistration = new TagHelperDirectiveDescriptor
new TagHelperDirectiveDescriptor("something", TagHelperDirectiveType.AddTagHelper); {
DirectiveText = "something",
DirectiveType = TagHelperDirectiveType.AddTagHelper
};
// Act // Act
tagHelperDirectiveSpanVisitor.GetDescriptors(document); tagHelperDirectiveSpanVisitor.GetDescriptors(document);
@ -181,8 +224,11 @@ namespace Microsoft.AspNet.Razor.TagHelpers
.Accepts(AcceptedCharacters.None), .Accepts(AcceptedCharacters.None),
Factory.Code("\"something\"").AsRemoveTagHelper("something")) Factory.Code("\"something\"").AsRemoveTagHelper("something"))
); );
var expectedRegistration = var expectedRegistration = new TagHelperDirectiveDescriptor
new TagHelperDirectiveDescriptor("something", TagHelperDirectiveType.RemoveTagHelper); {
DirectiveText = "something",
DirectiveType = TagHelperDirectiveType.RemoveTagHelper
};
// Act // Act
tagHelperDirectiveSpanVisitor.GetDescriptors(document); tagHelperDirectiveSpanVisitor.GetDescriptors(document);