示例#1
0
        public InspectionsModel(IEnumerable <InspectionInfo> inspections, string ignoreModuleExampleCode)
        {
            Inspections = inspections;
            var formatter = new FormattedCodeBlockBuilder();

            IgnoreModuleAnnotationExample = formatter.Format(ignoreModuleExampleCode);
        }
示例#2
0
        private QuickFixCodeExample[] ParseExamples(XElement node)
        {
            var formatter    = new FormattedCodeBlockBuilder();
            var exampleNodes = node.Elements("example");
            var result       = exampleNodes?
                               .Select(e => new QuickFixCodeExample(
                                           e.Element("before")?.Elements("module")?.Select(m =>
                                                                                           new FormattedCodeExampleModule(
                                                                                               formatter.Format(m.Nodes().OfType <XCData>().Single().Value),
                                                                                               m.GetAttribute("name")?.Value,
                                                                                               m.GetAttribute("type")?.Value))
                                           .Concat(e.Element("before")?.Nodes().OfType <XCData>().Take(1).Select(x =>
                                                                                                                 new FormattedCodeExampleModule(formatter.Format(x.Value))))
                                           ,
                                           e.Element("after")?.Elements("module")?.Select(m =>
                                                                                          new FormattedCodeExampleModule(
                                                                                              formatter.Format(m.Nodes().OfType <XCData>().Single().Value),
                                                                                              m.GetAttribute("name")?.Value,
                                                                                              m.GetAttribute("type")?.Value))
                                           .Concat(e.Element("after")?.Nodes().OfType <XCData>().Take(1).Select(x =>
                                                                                                                new FormattedCodeExampleModule(formatter.Format(x.Value))))
                                           )).ToArray();

            return(result);
        }
示例#3
0
        private InspectionCodeExample[] ParseExamples(XElement node)
        {
            var formatter = new FormattedCodeBlockBuilder();

            return(node.Elements("example")
                   .Select(e => new InspectionCodeExample(
                               e.GetAttribute("hasresult")?.Value.Equals("true", StringComparison.InvariantCultureIgnoreCase),
                               e.Elements("module").Select(m =>
                                                           new InspectionCodeExampleModule(
                                                               formatter.Format(m.Nodes().OfType <XCData>().Single().Value),
                                                               m.GetAttribute("name")?.Value,
                                                               m.GetAttribute("type")?.Value))
                               .Concat(e.Nodes().OfType <XCData>().Select(x =>
                                                                          new InspectionCodeExampleModule(formatter.Format(x.Value))).Take(1))
                               )).ToArray());
        }
        public void IndentsWithNonBreakingSpaces()
        {
            var code     = @"
Public Sub DoSomething()
Dim foo As Long
foo = 12 ' assignment is redundant
foo = 34
End Sub
";
            var expected = @"
<span class=""keyword"">Public</span> <span class=""keyword"">Sub</span> DoSomething()<br/>
&nbsp;&nbsp;&nbsp;&nbsp;<span class=""keyword""Dim</span> foo <span class=""keyword"">As</span> <span class=""keyword"">Long</span><br/>
&nbsp;&nbsp;&nbsp;&nbsp;foo = 12 <span class=""comment""' assignment is redundant</span></br>
&nbsp;&nbsp;&nbsp;&nbsp;foo = 34<<br/>
<span class=""keyword"">End Sub</span><br/>
".Replace("\n", string.Empty);

            var builder = new FormattedCodeBlockBuilder();
            var result  = builder.Format(code);

            Assert.AreEqual(expected, result);
        }