本文整理汇总了C#中RazorError类的典型用法代码示例。如果您正苦于以下问题:C# RazorError类的具体用法?C# RazorError怎么用?C# RazorError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RazorError类属于命名空间,在下文中一共展示了RazorError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitError
public override void VisitError(RazorError err) {
base.VisitError(err);
if (_errorList == null) {
_errorList = new List<RazorError>();
}
_errorList.Add(err);
}
示例2: RazorPadRazorError
public RazorPadRazorError(RazorError error)
{
if (error == null)
return;
Column = error.Location.CharacterIndex;
Line = error.Location.LineIndex;
Message = error.Message;
}
示例3: VisitError
public override void VisitError(RazorError err)
{
err.ThrowIfNull("err");
if (_throwExceptionOnParserError)
{
throw new TemplateParsingException(err);
}
}
示例4: ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket
public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket(
string implicitExpresison,
string expectedImplicitExpression,
AcceptedCharacters acceptedCharacters,
RazorError[] expectedErrors)
{
// Act & Assert
ImplicitExpressionTest(
implicitExpresison,
expectedImplicitExpression,
acceptedCharacters,
expectedErrors);
}
示例5: ToDiagnostic_ConvertsRazorErrorLocation_ToSourceLineMappings
public void ToDiagnostic_ConvertsRazorErrorLocation_ToSourceLineMappings()
{
// Arrange
var sourceLocation = new SourceLocation(absoluteIndex: 30, lineIndex: 10, characterIndex: 1);
var error = new RazorError("some message", sourceLocation, length: 5);
// Act
var diagnostics = error.ToDiagnostics("/some-path");
// Assert
var span = diagnostics.Location.GetMappedLineSpan();
Assert.Equal("/some-path", span.Path);
Assert.Equal(10, span.StartLinePosition.Line);
Assert.Equal(1, span.StartLinePosition.Character);
Assert.Equal(10, span.EndLinePosition.Line);
Assert.Equal(6, span.EndLinePosition.Character);
}
示例6: ToDiagnostic_SucceedsWhenRazorErrorLocationIsZeroOrUndefined
public void ToDiagnostic_SucceedsWhenRazorErrorLocationIsZeroOrUndefined(
SourceLocation location,
int length)
{
// Arrange
var error = new RazorError("some message", location, length);
// Act
var diagnostics = error.ToDiagnostics("/some-path");
// Assert
var span = diagnostics.Location.GetMappedLineSpan();
Assert.Equal("/some-path", span.Path);
Assert.Equal(0, span.StartLinePosition.Line);
Assert.Equal(0, span.StartLinePosition.Character);
Assert.Equal(0, span.EndLinePosition.Line);
Assert.Equal(0, span.EndLinePosition.Character);
}
示例7: RazorError_CanBeSerialized
public void RazorError_CanBeSerialized()
{
// Arrange
var error = new RazorError(
message: "Testing",
location: new SourceLocation(absoluteIndex: 1, lineIndex: 2, characterIndex: 3),
length: 456);
var expectedSerializedError =
$"{{\"{nameof(RazorError.Message)}\":\"Testing\",\"{nameof(RazorError.Location)}\":{{\"" +
$"{nameof(SourceLocation.AbsoluteIndex)}\":1,\"{nameof(SourceLocation.LineIndex)}\":2,\"" +
$"{nameof(SourceLocation.CharacterIndex)}\":3}},\"{nameof(RazorError.Length)}\":456}}";
// Act
var serializedError = JsonConvert.SerializeObject(error);
// Assert
Assert.Equal(expectedSerializedError, serializedError, StringComparer.Ordinal);
}
示例8: RazorError_CanBeDeserialized
public void RazorError_CanBeDeserialized()
{
// Arrange
var error = new RazorError(
message: "Testing",
location: new SourceLocation("somepath", absoluteIndex: 1, lineIndex: 2, characterIndex: 3),
length: 456);
var serializedError = JsonConvert.SerializeObject(error);
// Act
var deserializedError = JsonConvert.DeserializeObject<RazorError>(serializedError);
// Assert
Assert.Equal("Testing", deserializedError.Message, StringComparer.Ordinal);
Assert.Equal(1, deserializedError.Location.AbsoluteIndex);
Assert.Equal(2, deserializedError.Location.LineIndex);
Assert.Equal(3, deserializedError.Location.CharacterIndex);
Assert.Equal(456, deserializedError.Length);
}
示例9: VisitError
public override void VisitError(RazorError err) {
Visitor1.VisitError(err);
Visitor2.VisitError(err);
}
示例10: ExceptionFilterErrors
public void ExceptionFilterErrors(
string document,
StatementBlock expectedStatement,
RazorError[] expectedErrors)
{
// Act & Assert
ParseBlockTest(document, expectedStatement, expectedErrors);
}
示例11: OnError
public void OnError(RazorError error)
{
EnusreNotTerminated();
AssertOnOwnerTask();
_errorSink.OnError(error);
}
示例12: Rewrite_CreatesErrorForWithoutEndTagTagStructureForEndTags
public void Rewrite_CreatesErrorForWithoutEndTagTagStructureForEndTags()
{
// Arrange
var factory = CreateDefaultSpanFactory();
var blockFactory = new BlockFactory(factory);
var expectedError = new RazorError(
RazorResources.FormatTagHelperParseTreeRewriter_EndTagTagHelperMustNotHaveAnEndTag(
"input",
"InputTagHelper",
TagStructure.WithoutEndTag),
absoluteIndex: 2,
lineIndex: 0,
columnIndex: 2,
length: 5);
var documentContent = "</input>";
var expectedOutput = new MarkupBlock(blockFactory.MarkupTagBlock("</input>"));
var descriptors = new TagHelperDescriptor[]
{
new TagHelperDescriptor
{
TagName = "input",
TypeName = "InputTagHelper",
AssemblyName = "SomeAssembly",
TagStructure = TagStructure.WithoutEndTag
}
};
var descriptorProvider = new TagHelperDescriptorProvider(descriptors);
// Act & Assert
EvaluateData(descriptorProvider, documentContent, expectedOutput, expectedErrors: new[] { expectedError });
}
示例13: Rewrite_RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly
public void Rewrite_RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly(
string documentContent,
MarkupBlock expectedOutput,
RazorError[] expectedErrors)
{
// Arrange
var descriptors = new TagHelperDescriptor[]
{
new TagHelperDescriptor(
tagName: "p",
typeName: "pTagHelper",
assemblyName: "SomeAssembly",
attributes: new TagHelperAttributeDescriptor[0],
requiredAttributes: new[] { "class" })
};
var descriptorProvider = new TagHelperDescriptorProvider(descriptors);
// Act & Assert
EvaluateData(descriptorProvider, documentContent, expectedOutput, expectedErrors);
}
示例14: OnError
/// <summary>
/// Tracks the given <paramref name="error"/>.
/// </summary>
/// <param name="error">The <see cref="RazorError"/> to track.</param>
public void OnError(RazorError error)
{
_errors.Add(error);
}
示例15: CreateExceptionFromParserError
private static HttpParseException CreateExceptionFromParserError(RazorError error, string virtualPath)
{
return new HttpParseException(error.Message + Environment.NewLine, null, virtualPath, null, error.Location.LineIndex + 1);
}