• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zorbathut / dec / 11709205202

06 Nov 2024 05:57PM UTC coverage: 90.198% (-0.4%) from 90.637%
11709205202

push

github

zorbathut
Added the ability to reference class objects contained within Decs.

4748 of 5264 relevant lines covered (90.2%)

194623.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/src/WriterXmlCompose.cs
1

2

3
using System;
4
using System.Xml.Linq;
5

6
namespace Dec
7
{
8
    internal class WriterXmlCompose : WriterXml
9
    {
10
        public override bool AllowReflection { get => true; }
37,106✔
11
        public override bool AllowDecPath { get => false; }
225,282✔
12
        public override Recorder.IUserSettings UserSettings { get; }
20✔
13

14
        private XDocument doc;
15
        private XElement decs;
16

17
        public WriterXmlCompose(Recorder.IUserSettings userSettings)
4,045✔
18
        {
4,045✔
19
            this.UserSettings = userSettings;
4,045✔
20

21
            doc = new XDocument();
4,045✔
22

23
            decs = new XElement("Decs");
4,045✔
24
            doc.Add(decs);
4,045✔
25
        }
4,045✔
26

27
        public override bool RegisterReference(object referenced, XElement element, Recorder.Settings recSettings, Path path)
28
        {
41,286✔
29
            // We never register references in Compose mode.
30
            return false;
41,286✔
31
        }
41,286✔
32

33
        public WriterNode StartDec(Type type, string decName)
34
        {
14,780✔
35
            string typeName;
36
            Type overrideClass = null;
14,780✔
37
            if (type.IsGenericType)
14,780✔
38
            {
10✔
39
                // okay, this just got more complicated
40
                // we need to find a dec subclass that doesn't have any generics, then attach an attribute
41
                // this is . . . not great design, honestly, I'm not sure I like this format right now
42
                // but, fine, it's ugly but it will work
43
                Type baseType = type.BaseType;
10✔
44
                while (baseType.IsGenericType)
10✔
45
                {
×
46
                    baseType = baseType.BaseType;
×
47
                }
×
48

49
                typeName = baseType.ComposeDecFormatted();
10✔
50
                overrideClass = type;
10✔
51
            }
10✔
52
            else
53
            {
14,770✔
54
                typeName = type.ComposeDecFormatted();
14,770✔
55
            }
14,770✔
56

57
            var nodeXml = WriterNodeXml.StartDec(this, decs, typeName, decName);
14,780✔
58

59
            if (overrideClass != null)
14,780✔
60
            {
10✔
61
                nodeXml.TagClass(overrideClass);
10✔
62
            }
10✔
63

64
            return nodeXml;
14,780✔
65
        }
14,780✔
66

67
        public string Finish(bool pretty)
68
        {
4,045✔
69
            DequeuePendingWrites();
4,045✔
70

71
            return doc.ToString(pretty ? SaveOptions.None : SaveOptions.DisableFormatting);
4,045✔
72
        }
4,045✔
73
    }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc