本文整理汇总了C#中ErrorSink.OnError方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorSink.OnError方法的具体用法?C# ErrorSink.OnError怎么用?C# ErrorSink.OnError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorSink
的用法示例。
在下文中一共展示了ErrorSink.OnError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitCallsOnCompleteWhenAllNodesHaveBeenVisited
public void VisitCallsOnCompleteWhenAllNodesHaveBeenVisited()
{
// Arrange
Mock<ParserVisitor> targetMock = new Mock<ParserVisitor>();
var root = new BlockBuilder() { Type = BlockType.Comment }.Build();
var errorSink = new ErrorSink();
errorSink.OnError(new RazorError("Foo", new SourceLocation(1, 0, 1), length: 3));
errorSink.OnError(new RazorError("Bar", new SourceLocation(2, 0, 2), length: 3));
var results = new ParserResults(root, Enumerable.Empty<TagHelperDescriptor>(), errorSink);
// Act
targetMock.Object.Visit(results);
// Assert
targetMock.Verify(v => v.OnComplete());
}
示例2: Resolve
/// <inheritdoc />
public IEnumerable<Type> Resolve(
string name,
SourceLocation documentLocation,
ErrorSink errorSink)
{
if (errorSink == null)
{
throw new ArgumentNullException(nameof(errorSink));
}
if (string.IsNullOrEmpty(name))
{
var errorLength = name == null ? 1 : Math.Max(name.Length, 1);
errorSink.OnError(
documentLocation,
Resources.TagHelperTypeResolver_TagHelperAssemblyNameCannotBeEmptyOrNull,
errorLength);
return Type.EmptyTypes;
}
var assemblyName = new AssemblyName(name);
IEnumerable<TypeInfo> libraryTypes;
try
{
libraryTypes = GetExportedTypes(assemblyName);
}
catch (Exception ex)
{
errorSink.OnError(
documentLocation,
Resources.FormatTagHelperTypeResolver_CannotResolveTagHelperAssembly(
assemblyName.Name,
ex.Message),
name.Length);
return Type.EmptyTypes;
}
return libraryTypes.Where(IsTagHelper).Select(t => t.AsType());
}
示例3: Compile_ReturnsFailedResultIfParseFails
public void Compile_ReturnsFailedResultIfParseFails()
{
// Arrange
var errorSink = new ErrorSink();
errorSink.OnError(new RazorError("some message", 1, 1, 1, 1));
var generatorResult = new GeneratorResults(
new Block(new BlockBuilder { Type = BlockType.Comment }),
Enumerable.Empty<TagHelperDescriptor>(),
errorSink,
new CodeGeneratorResult("", new LineMapping[0]),
new ChunkTree());
var host = new Mock<IMvcRazorHost>();
host.Setup(h => h.GenerateCode(It.IsAny<string>(), It.IsAny<Stream>()))
.Returns(generatorResult)
.Verifiable();
var fileInfo = new Mock<IFileInfo>();
fileInfo.Setup(f => f.CreateReadStream())
.Returns(Stream.Null);
var compiler = new Mock<ICompilationService>(MockBehavior.Strict);
var relativeFileInfo = new RelativeFileInfo(fileInfo.Object, @"Views\index\home.cshtml");
var razorService = new RazorCompilationService(compiler.Object, host.Object, GetFileProviderAccessor(), NullLoggerFactory.Instance);
// Act
var result = razorService.Compile(relativeFileInfo);
// Assert
Assert.NotNull(result.CompilationFailures);
Assert.Collection(result.CompilationFailures,
failure =>
{
var message = Assert.Single(failure.Messages);
Assert.Equal("some message", message.Message);
});
host.Verify();
}
示例4: VisitSendsErrorsToVisitor
public void VisitSendsErrorsToVisitor()
{
// Arrange
Mock<ParserVisitor> targetMock = new Mock<ParserVisitor>();
var root = new BlockBuilder() { Type = BlockType.Comment }.Build();
var errorSink = new ErrorSink();
List<RazorError> errors = new List<RazorError>
{
new RazorError("Foo", new SourceLocation(1, 0, 1), length: 3),
new RazorError("Bar", new SourceLocation(2, 0, 2), length: 3),
};
foreach (var error in errors)
{
errorSink.OnError(error);
}
var results = new ParserResults(root, Enumerable.Empty<TagHelperDescriptor>(), errorSink);
// Act
targetMock.Object.Visit(results);
// Assert
targetMock.Verify(v => v.VisitError(errors[0]));
targetMock.Verify(v => v.VisitError(errors[1]));
}
示例5: GetTagAttributes
private static IList<KeyValuePair<string, SyntaxTreeNode>> GetTagAttributes(
string tagName,
bool validStructure,
Block tagBlock,
IEnumerable<TagHelperDescriptor> descriptors,
ErrorSink errorSink)
{
// Ignore all but one descriptor per type since this method uses the TagHelperDescriptors only to get the
// contained TagHelperAttributeDescriptor's.
descriptors = descriptors.Distinct(TypeBasedTagHelperDescriptorComparer.Default);
var attributes = new List<KeyValuePair<string, SyntaxTreeNode>>();
// We skip the first child "<tagname" and take everything up to the ending portion of the tag ">" or "/>".
// The -2 accounts for both the start and end tags. If the tag does not have a valid structure then there's
// no end tag to ignore.
var symbolOffset = validStructure ? 2 : 1;
var attributeChildren = tagBlock.Children.Skip(1).Take(tagBlock.Children.Count() - symbolOffset);
foreach (var child in attributeChildren)
{
TryParseResult result;
if (child.IsBlock)
{
result = TryParseBlock(tagName, (Block)child, descriptors, errorSink);
}
else
{
result = TryParseSpan((Span)child, descriptors, errorSink);
}
// Only want to track the attribute if we succeeded in parsing its corresponding Block/Span.
if (result != null)
{
SourceLocation? errorLocation = null;
// Check if it's a bound attribute that is minimized or if it's a bound non-string attribute that
// is null or whitespace.
if ((result.IsBoundAttribute && result.AttributeValueNode == null) ||
(result.IsBoundNonStringAttribute &&
IsNullOrWhitespaceAttributeValue(result.AttributeValueNode)))
{
errorLocation = GetAttributeNameStartLocation(child);
errorSink.OnError(
errorLocation.Value,
RazorResources.FormatRewriterError_EmptyTagHelperBoundAttribute(
result.AttributeName,
tagName,
GetPropertyType(result.AttributeName, descriptors)),
result.AttributeName.Length);
}
// Check if the attribute was a prefix match for a tag helper dictionary property but the
// dictionary key would be the empty string.
if (result.IsMissingDictionaryKey)
{
if (!errorLocation.HasValue)
{
errorLocation = GetAttributeNameStartLocation(child);
}
errorSink.OnError(
errorLocation.Value,
RazorResources.FormatTagHelperBlockRewriter_IndexerAttributeNameMustIncludeKey(
result.AttributeName,
tagName),
result.AttributeName.Length);
}
attributes.Add(
new KeyValuePair<string, SyntaxTreeNode>(result.AttributeName, result.AttributeValueNode));
}
}
return attributes;
}
示例6: TryParseBlock
private static TryParseResult TryParseBlock(
string tagName,
Block block,
IEnumerable<TagHelperDescriptor> descriptors,
ErrorSink errorSink)
{
// TODO: Accept more than just spans: https://github.com/aspnet/Razor/issues/96.
// The first child will only ever NOT be a Span if a user is doing something like:
// <input @checked />
var childSpan = block.Children.First() as Span;
if (childSpan == null || childSpan.Kind != SpanKind.Markup)
{
errorSink.OnError(
block.Start,
RazorResources.FormatTagHelpers_CannotHaveCSharpInTagDeclaration(tagName),
block.Length);
return null;
}
var builder = new BlockBuilder(block);
// If there's only 1 child it means that it's plain text inside of the attribute.
// i.e. <div class="plain text in attribute">
if (builder.Children.Count == 1)
{
return TryParseSpan(childSpan, descriptors, errorSink);
}
var nameSymbols = childSpan
.Symbols
.OfType<HtmlSymbol>()
.SkipWhile(symbol => !HtmlMarkupParser.IsValidAttributeNameSymbol(symbol)) // Skip prefix
.TakeWhile(nameSymbol => HtmlMarkupParser.IsValidAttributeNameSymbol(nameSymbol))
.Select(nameSymbol => nameSymbol.Content);
var name = string.Concat(nameSymbols);
if (string.IsNullOrEmpty(name))
{
errorSink.OnError(
childSpan.Start,
RazorResources.FormatTagHelpers_AttributesMustHaveAName(tagName),
childSpan.Length);
return null;
}
// Have a name now. Able to determine correct isBoundNonStringAttribute value.
var result = CreateTryParseResult(name, descriptors);
// Remove first child i.e. foo="
builder.Children.RemoveAt(0);
// Grabbing last child to check if the attribute value is quoted.
var endNode = block.Children.Last();
if (!endNode.IsBlock)
{
var endSpan = (Span)endNode;
// In some malformed cases e.g. <p bar="false', the last Span (false' in the ex.) may contain more
// than a single HTML symbol. Do not ignore those other symbols.
var symbolCount = endSpan.Symbols.Count();
var endSymbol = symbolCount == 1 ? (HtmlSymbol)endSpan.Symbols.First() : null;
// Checking to see if it's a quoted attribute, if so we should remove end quote
if (endSymbol != null && IsQuote(endSymbol))
{
builder.Children.RemoveAt(builder.Children.Count - 1);
}
}
// We need to rebuild the chunk generators of the builder and its children (this is needed to
// ensure we don't do special attribute chunk generation since this is a tag helper).
block = RebuildChunkGenerators(builder.Build(), result.IsBoundAttribute);
// If there's only 1 child at this point its value could be a simple markup span (treated differently than
// block level elements for attributes).
if (block.Children.Count() == 1)
{
var child = block.Children.First() as Span;
if (child != null)
{
// After pulling apart the block we just have a value span.
var spanBuilder = new SpanBuilder(child);
result.AttributeValueNode =
CreateMarkupAttribute(spanBuilder, result.IsBoundNonStringAttribute);
return result;
}
}
var isFirstSpan = true;
result.AttributeValueNode = ConvertToMarkupAttributeBlock(
block,
(parentBlock, span) =>
{
//.........这里部分代码省略.........
示例7: TryParseSpan
//.........这里部分代码省略.........
.Skip(i) // Skip prefix
.TakeWhile(nameSymbol => HtmlMarkupParser.IsValidAttributeNameSymbol(nameSymbol))
.Select(nameSymbol => nameSymbol.Content);
// Move the indexer past the attribute name symbols.
i += symbolContents.Count() - 1;
name = string.Concat(symbolContents);
attributeValueStartLocation = SourceLocation.Advance(attributeValueStartLocation, name);
}
else if (symbol.Type == HtmlSymbolType.Equals)
{
Debug.Assert(
name != null,
"Name should never be null here. The parser should guarantee an attribute has a name.");
// We've captured all leading whitespace and the attribute name.
// We're now at: " asp-for|='...'" or " asp-for|=..."
// The goal here is to consume the equal sign and the optional single/double-quote.
// The coming symbols will either be a quote or value (in the case that the value is unquoted).
SourceLocation symbolStartLocation;
// Skip the whitespace preceding the start of the attribute value.
do
{
i++; // Start from the symbol after '='.
} while (i < htmlSymbols.Length &&
(htmlSymbols[i].Type == HtmlSymbolType.WhiteSpace ||
htmlSymbols[i].Type == HtmlSymbolType.NewLine));
// Check for attribute start values, aka single or double quote
if (i < htmlSymbols.Length && IsQuote(htmlSymbols[i]))
{
symbolStartLocation = htmlSymbols[i].Start;
// If there's a start quote then there must be an end quote to be valid, skip it.
symbolOffset = 1;
}
else
{
// We are at the symbol after equals. Go back to equals to ensure we don't skip past that symbol.
i--;
symbolStartLocation = symbol.Start;
}
attributeValueStartLocation =
span.Start +
symbolStartLocation +
new SourceLocation(absoluteIndex: 1, lineIndex: 0, characterIndex: 1);
afterEquals = true;
}
else if (symbol.Type == HtmlSymbolType.WhiteSpace)
{
// We're at the start of the attribute, this branch may be hit on the first iterations of
// the loop since the parser separates attributes with their spaces included as symbols.
// We're at: "| asp-for='...'" or "| asp-for=..."
// Note: This will not be hit even for situations like asp-for ="..." because the core Razor
// parser currently does not know how to handle attributes in that format. This will be addressed
// by https://github.com/aspnet/Razor/issues/123.
attributeValueStartLocation = SourceLocation.Advance(attributeValueStartLocation, symbol.Content);
}
}
// After all symbols have been added we need to set the builders start position so we do not indirectly
// modify each symbol's Start location.
builder.Start = attributeValueStartLocation;
if (name == null)
{
// We couldn't find a name, if the original span content was whitespace it ultimately means the tag
// that owns this "attribute" is malformed and is expecting a user to type a new attribute.
// ex: <myTH class="btn"| |
if (!string.IsNullOrWhiteSpace(span.Content))
{
errorSink.OnError(
span.Start,
RazorResources.TagHelperBlockRewriter_TagHelperAttributeListMustBeWellFormed,
span.Content.Length);
}
return null;
}
var result = CreateTryParseResult(name, descriptors);
// If we're not after an equal then we should treat the value as if it were a minimized attribute.
Span attributeValue = null;
if (afterEquals)
{
attributeValue = CreateMarkupAttribute(builder, result.IsBoundNonStringAttribute);
}
result.AttributeValueNode = attributeValue;
return result;
}
示例8: TryParseBlock
private static TryParseResult TryParseBlock(
string tagName,
Block block,
IEnumerable<TagHelperDescriptor> descriptors,
ErrorSink errorSink)
{
// TODO: Accept more than just spans: https://github.com/aspnet/Razor/issues/96.
// The first child will only ever NOT be a Span if a user is doing something like:
// <input @checked />
var childSpan = block.Children.First() as Span;
if (childSpan == null || childSpan.Kind != SpanKind.Markup)
{
errorSink.OnError(block.Children.First().Start,
RazorResources.FormatTagHelpers_CannotHaveCSharpInTagDeclaration(tagName));
return null;
}
var builder = new BlockBuilder(block);
// If there's only 1 child it means that it's plain text inside of the attribute.
// i.e. <div class="plain text in attribute">
if (builder.Children.Count == 1)
{
return TryParseSpan(childSpan, descriptors, errorSink);
}
var textSymbol = childSpan.Symbols.FirstHtmlSymbolAs(HtmlSymbolType.Text);
var name = textSymbol != null ? textSymbol.Content : null;
if (name == null)
{
errorSink.OnError(childSpan.Start, RazorResources.FormatTagHelpers_AttributesMustHaveAName(tagName));
return null;
}
// Have a name now. Able to determine correct isBoundNonStringAttribute value.
var result = CreateTryParseResult(name, descriptors);
// Remove first child i.e. foo="
builder.Children.RemoveAt(0);
// Grabbing last child to check if the attribute value is quoted.
var endNode = block.Children.Last();
if (!endNode.IsBlock)
{
var endSpan = (Span)endNode;
// In some malformed cases e.g. <p bar="false', the last Span (false' in the ex.) may contain more
// than a single HTML symbol. Do not ignore those other symbols.
var symbolCount = endSpan.Symbols.Count();
var endSymbol = symbolCount == 1 ? (HtmlSymbol)endSpan.Symbols.First() : null;
// Checking to see if it's a quoted attribute, if so we should remove end quote
if (endSymbol != null && IsQuote(endSymbol))
{
builder.Children.RemoveAt(builder.Children.Count - 1);
}
}
// We need to rebuild the chunk generators of the builder and its children (this is needed to
// ensure we don't do special attribute chunk generation since this is a tag helper).
block = RebuildChunkGenerators(builder.Build());
// If there's only 1 child at this point its value could be a simple markup span (treated differently than
// block level elements for attributes).
if (block.Children.Count() == 1)
{
var child = block.Children.First() as Span;
if (child != null)
{
// After pulling apart the block we just have a value span.
var spanBuilder = new SpanBuilder(child);
result.AttributeValueNode =
CreateMarkupAttribute(spanBuilder, result.IsBoundNonStringAttribute);
return result;
}
}
result.AttributeValueNode = ConvertToMarkupAttributeBlock(block, result.IsBoundNonStringAttribute);
return result;
}
示例9: ToIndexerAttributeDescriptor
private static TagHelperAttributeDescriptor ToIndexerAttributeDescriptor(
PropertyInfo property,
HtmlAttributeNameAttribute attributeNameAttribute,
Type parentType,
ErrorSink errorSink,
string defaultPrefix,
bool designTime,
out bool isInvalid)
{
isInvalid = false;
var hasPublicSetter = property.SetMethod?.IsPublic == true;
var dictionaryTypeArguments = ClosedGenericMatcher.ExtractGenericInterface(
property.PropertyType,
typeof(IDictionary<,>))
?.GenericTypeArguments;
if (dictionaryTypeArguments?[0] != typeof(string))
{
if (attributeNameAttribute?.DictionaryAttributePrefix != null)
{
// DictionaryAttributePrefix is not supported unless associated with an
// IDictionary<string, TValue> property.
isInvalid = true;
errorSink.OnError(
SourceLocation.Zero,
Resources.FormatTagHelperDescriptorFactory_InvalidAttributePrefixNotNull(
parentType.FullName,
property.Name,
nameof(HtmlAttributeNameAttribute),
nameof(HtmlAttributeNameAttribute.DictionaryAttributePrefix),
"IDictionary<string, TValue>"));
}
else if (attributeNameAttribute != null && !hasPublicSetter)
{
// Associated an HtmlAttributeNameAttribute with a non-dictionary property that lacks a public
// setter.
isInvalid = true;
errorSink.OnError(
SourceLocation.Zero,
Resources.FormatTagHelperDescriptorFactory_InvalidAttributeNameAttribute(
parentType.FullName,
property.Name,
nameof(HtmlAttributeNameAttribute),
"IDictionary<string, TValue>"));
}
return null;
}
else if (!hasPublicSetter &&
attributeNameAttribute != null &&
!attributeNameAttribute.DictionaryAttributePrefixSet)
{
// Must set DictionaryAttributePrefix when using HtmlAttributeNameAttribute with a dictionary property
// that lacks a public setter.
isInvalid = true;
errorSink.OnError(
SourceLocation.Zero,
Resources.FormatTagHelperDescriptorFactory_InvalidAttributePrefixNull(
parentType.FullName,
property.Name,
nameof(HtmlAttributeNameAttribute),
nameof(HtmlAttributeNameAttribute.DictionaryAttributePrefix),
"IDictionary<string, TValue>"));
return null;
}
// Potential prefix case. Use default prefix (based on name)?
var useDefault = attributeNameAttribute == null || !attributeNameAttribute.DictionaryAttributePrefixSet;
var prefix = useDefault ? defaultPrefix : attributeNameAttribute.DictionaryAttributePrefix;
if (prefix == null)
{
// DictionaryAttributePrefix explicitly set to null. Ignore.
return null;
}
return ToAttributeDescriptor(
property,
attributeName: prefix,
typeName: dictionaryTypeArguments[1].FullName,
isIndexer: true,
designTime: designTime);
}
示例10: ValidateTagHelperAttributeNameOrPrefix
private static bool ValidateTagHelperAttributeNameOrPrefix(
string attributeNameOrPrefix,
Type parentType,
string propertyName,
ErrorSink errorSink,
string nameOrPrefix)
{
if (string.IsNullOrEmpty(attributeNameOrPrefix))
{
// ValidateTagHelperAttributeDescriptor validates Name is non-null and non-empty. The empty string is
// valid for DictionaryAttributePrefix and null is impossible at this point because it means "don't
// create a descriptor". (Empty DictionaryAttributePrefix is a corner case which would bind every
// attribute of a target element. Likely not particularly useful but unclear what minimum length
// should be required and what scenarios a minimum length would break.)
return true;
}
if (string.IsNullOrWhiteSpace(attributeNameOrPrefix))
{
// Provide a single error if the entire name is whitespace, not an error per character.
errorSink.OnError(
SourceLocation.Zero,
Resources.FormatTagHelperDescriptorFactory_InvalidAttributeNameOrPrefixWhitespace(
parentType.FullName,
propertyName,
nameOrPrefix));
return false;
}
// data-* attributes are explicitly not implemented by user agents and are not intended for use on
// the server; therefore it's invalid for TagHelpers to bind to them.
if (attributeNameOrPrefix.StartsWith(DataDashPrefix, StringComparison.OrdinalIgnoreCase))
{
errorSink.OnError(
SourceLocation.Zero,
Resources.FormatTagHelperDescriptorFactory_InvalidAttributeNameOrPrefixStart(
parentType.FullName,
propertyName,
nameOrPrefix,
attributeNameOrPrefix,
DataDashPrefix));
return false;
}
var isValid = true;
foreach (var character in attributeNameOrPrefix)
{
if (char.IsWhiteSpace(character) || InvalidNonWhitespaceNameCharacters.Contains(character))
{
errorSink.OnError(
SourceLocation.Zero,
Resources.FormatTagHelperDescriptorFactory_InvalidAttributeNameOrPrefixCharacter(
parentType.FullName,
propertyName,
nameOrPrefix,
attributeNameOrPrefix,
character));
isValid = false;
}
}
return isValid;
}
示例11: GetLookupInfo
private static LookupInfo GetLookupInfo(TagHelperDirectiveDescriptor directiveDescriptor,
ErrorSink errorSink)
{
var lookupText = directiveDescriptor.DirectiveText;
var lookupStrings = lookupText?.Split(new[] { ',' });
// Ensure that we have valid lookupStrings to work with. Valid formats are:
// "assemblyName"
// "typeName, assemblyName"
if (lookupStrings == null ||
lookupStrings.Any(string.IsNullOrWhiteSpace) ||
lookupStrings.Length != 2)
{
errorSink.OnError(
directiveDescriptor.Location,
Resources.FormatTagHelperDescriptorResolver_InvalidTagHelperLookupText(lookupText));
return null;
}
return new LookupInfo
{
TypePattern = lookupStrings[0].Trim(),
AssemblyName = lookupStrings[1].Trim()
};
}
示例12: GetTagHelperDescriptors
/// <inheritdoc />
protected override IEnumerable<TagHelperDescriptor> GetTagHelperDescriptors(
Block documentRoot,
ErrorSink errorSink)
{
if (documentRoot == null)
{
throw new ArgumentNullException(nameof(documentRoot));
}
if (errorSink == null)
{
throw new ArgumentNullException(nameof(errorSink));
}
var visitor = new ViewImportsTagHelperDirectiveSpanVisitor(
TagHelperDescriptorResolver,
_viewImportsDirectiveDescriptors,
errorSink);
var descriptors = visitor.GetDescriptors(documentRoot);
foreach (var descriptor in descriptors)
{
foreach (var attributeDescriptor in descriptor.Attributes)
{
if (attributeDescriptor.IsIndexer &&
string.Equals(
attributeDescriptor.TypeName,
_modelExpressionTypeName,
StringComparison.Ordinal))
{
errorSink.OnError(
SourceLocation.Undefined,
Resources.FormatMvcRazorParser_InvalidPropertyType(
descriptor.TypeName,
attributeDescriptor.Name,
_modelExpressionTypeName),
length: 0);
}
}
}
return descriptors;
}
示例13: EnsureValidPrefix
private static bool EnsureValidPrefix(
string prefix,
SourceLocation directiveLocation,
ErrorSink errorSink)
{
foreach (var character in prefix)
{
// Prefixes are correlated with tag names, tag names cannot have whitespace.
if (char.IsWhiteSpace(character) ||
TagHelperDescriptorFactory.InvalidNonWhitespaceNameCharacters.Contains(character))
{
errorSink.OnError(
directiveLocation,
Resources.FormatTagHelperDescriptorResolver_InvalidTagHelperPrefixValue(
SyntaxConstants.CSharp.TagHelperPrefixKeyword,
character,
prefix),
prefix.Length);
return false;
}
}
return true;
}
示例14: ValidateDescriptors
private static void ValidateDescriptors(
IEnumerable<TagHelperDescriptor> descriptors,
string tagName,
Block tagBlock,
ErrorSink errorSink)
{
// Ensure that all descriptors associated with this tag have appropriate TagStructures. Cannot have
// multiple descriptors that expect different TagStructures (other than TagStructure.Unspecified).
TagHelperDescriptor baseDescriptor = null;
foreach (var descriptor in descriptors)
{
if (descriptor.TagStructure != TagStructure.Unspecified)
{
// Can't have a set of TagHelpers that expect different structures.
if (baseDescriptor != null && baseDescriptor.TagStructure != descriptor.TagStructure)
{
errorSink.OnError(
tagBlock.Start,
RazorResources.FormatTagHelperParseTreeRewriter_InconsistentTagStructure(
baseDescriptor.TypeName,
descriptor.TypeName,
tagName,
nameof(TagHelperDescriptor.TagStructure)),
tagBlock.Length);
}
baseDescriptor = descriptor;
}
}
}
示例15: OnAllowedChildrenTagError
private static void OnAllowedChildrenTagError(
TagHelperBlockTracker tracker,
string tagName,
Block tagBlock,
ErrorSink errorSink)
{
var allowedChildrenString = string.Join(", ", tracker.AllowedChildren);
var errorMessage = RazorResources.FormatTagHelperParseTreeRewriter_InvalidNestedTag(
tagName,
tracker.TagName,
allowedChildrenString);
var errorStart = GetTagDeclarationErrorStart(tagBlock);
errorSink.OnError(errorStart, errorMessage, tagName.Length);
}