当前位置: 首页>>代码示例>>C#>>正文


C# RazorError类代码示例

本文整理汇总了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);
 }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:7,代码来源:SyntaxTreeBuilderVisitor.cs

示例2: RazorPadRazorError

        public RazorPadRazorError(RazorError error)
        {
            if (error == null)
                return;

            Column = error.Location.CharacterIndex;
            Line = error.Location.LineIndex;
            Message = error.Message;
        }
开发者ID:RazorPad,项目名称:RazorPad,代码行数:9,代码来源:RazorPadRazorError.cs

示例3: VisitError

        public override void VisitError(RazorError err)
        {
            err.ThrowIfNull("err");

            if (_throwExceptionOnParserError)
            {
                throw new TemplateParsingException(err);
            }
        }
开发者ID:nathan-alden,项目名称:junior-route,代码行数:9,代码来源:CSharpCodeGenerator.cs

示例4: ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket

 public void ParseBlockMethodParsesNullConditionalOperatorImplicitExpression_Bracket(
     string implicitExpresison,
     string expectedImplicitExpression,
     AcceptedCharacters acceptedCharacters,
     RazorError[] expectedErrors)
 {
     // Act & Assert
     ImplicitExpressionTest(
         implicitExpresison,
         expectedImplicitExpression,
         acceptedCharacters,
         expectedErrors);
 }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:13,代码来源:CSharpImplicitExpressionTest.cs

示例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);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:17,代码来源:RazorErrorExtensionsTest.cs

示例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);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:18,代码来源:RazorErrorExtensionsTest.cs

示例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);
        }
开发者ID:billwaddyjr,项目名称:Razor,代码行数:18,代码来源:RazorErrorTest.cs

示例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);
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:19,代码来源:RazorErrorTest.cs

示例9: VisitError

 public override void VisitError(RazorError err) {
     Visitor1.VisitError(err);
     Visitor2.VisitError(err);
 }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:4,代码来源:AggregateVisitor.cs

示例10: ExceptionFilterErrors

 public void ExceptionFilterErrors(
     string document,
     StatementBlock expectedStatement,
     RazorError[] expectedErrors)
 {
     // Act & Assert
     ParseBlockTest(document, expectedStatement, expectedErrors);
 }
开发者ID:huoxudong125,项目名称:Razor,代码行数:8,代码来源:CSharpStatementTest.cs

示例11: OnError

        public void OnError(RazorError error)
        {
            EnusreNotTerminated();
            AssertOnOwnerTask();

            _errorSink.OnError(error);
        }
开发者ID:leloulight,项目名称:Razor,代码行数:7,代码来源:ParserContext.cs

示例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 });
        }
开发者ID:cjqian,项目名称:Razor,代码行数:31,代码来源:TagHelperParseTreeRewriterTest.cs

示例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);
        }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:20,代码来源:TagHelperParseTreeRewriterTest.cs

示例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);
 }
开发者ID:huoxudong125,项目名称:Razor,代码行数:8,代码来源:ErrorSink.cs

示例15: CreateExceptionFromParserError

 private static HttpParseException CreateExceptionFromParserError(RazorError error, string virtualPath)
 {
     return new HttpParseException(error.Message + Environment.NewLine, null, virtualPath, null, error.Location.LineIndex + 1);
 }
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:4,代码来源:RazorTemplateGenerator.cs


注:本文中的RazorError类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。