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

zorbathut / dec / 11691562073

05 Nov 2024 07:56PM UTC coverage: 90.637% (+0.2%) from 90.487%
11691562073

push

github

zorbathut
Rename StartData to more descriptive names.

4656 of 5137 relevant lines covered (90.64%)

191886.43 hits per line

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

87.5
/src/Writer.cs
1
using System;
2
using System.Collections;
3

4
namespace Dec
5
{
6
    internal abstract class WriterNode
7
    {
8
        private Recorder.Settings settings;
9
        private Path path;
10

11
        public WriterNode(Recorder.Settings settings, Path path)
1,476,864✔
12
        {
1,476,864✔
13
            this.settings = settings;
1,476,864✔
14
            this.path = path;
1,476,864✔
15
        }
1,476,864✔
16

17
        public Recorder.Settings RecorderSettings { get => settings; }
2,563,014✔
18
        public abstract bool AllowReflection { get; }
19
        public virtual bool AllowAsThis { get => true; }
265✔
20
        public virtual bool AllowCloning { get => false; }
488,991✔
21
        public abstract Recorder.IUserSettings UserSettings { get; }
22

23
        public Path Path { get => path; }
1,451,064✔
24

25
        // I'm not real happy with the existence of this function; it's kind of a hack so that a shared Converter that writes a string or an int can avoid errors
26
        public void MakeRecorderContextChild()
27
        {
520✔
28
            settings = settings.CreateChild();
520✔
29
        }
520✔
30

31
        public abstract WriterNode CreateRecorderChild(string label, Recorder.Settings settings);
32
        public abstract WriterNode CreateReflectionChild(System.Reflection.FieldInfo field, Recorder.Settings settings);
33

34
        public abstract void WritePrimitive(object value);
35
        public abstract void WriteEnum(object value);
36
        public abstract void WriteString(string value);
37
        public abstract void WriteType(Type value);
38
        public abstract void WriteDec(Dec value);
39
        public abstract void WriteExplicitNull();
40
        public abstract bool WriteReference(object value);
41
        public abstract void WriteArray(Array value);
42
        public abstract void WriteList(IList value);
43
        public abstract void WriteDictionary(IDictionary value);
44
        public abstract void WriteHashSet(IEnumerable value);
45
        public abstract void WriteQueue(IEnumerable value);
46
        public abstract void WriteStack(IEnumerable value);
47
        public abstract void WriteTuple(object value, System.Runtime.CompilerServices.TupleElementNamesAttribute names);
48
        public abstract void WriteValueTuple(object value, System.Runtime.CompilerServices.TupleElementNamesAttribute names);
49
        public abstract void WriteRecord(IRecordable value);
50
        public abstract void WriteConvertible(Converter converter, object value);
51
        public virtual void WriteCloneCopy(object value) { Dbg.Err("Internal error, attempting to clone an object without being in clone mode"); }
×
52
        public virtual void WriteError() { }  // "this should be a thing, but it isn't, sorry"
80✔
53

54
        public abstract void TagClass(Type type);
55

56
        // general behavior that polymorphics should not reimplement (so far at least?)
57
        protected bool flaggedAsClass = false;
1,476,864✔
58
        protected bool flaggedAsThis = false;
1,476,864✔
59

60
        // attempts to flag as self, posts error if it can't
61
        public bool FlagAsThis()
62
        {
315✔
63
            if (flaggedAsClass)
315✔
64
            {
20✔
65
                Dbg.Err("RecordAsThis() called on a node that was already polymorphic; this does not work, RecordAsThis() can be used only if every class involved in the This() chain is of expected type");
20✔
66
                return false;
20✔
67
            }
68

69
            flaggedAsThis = true;
295✔
70
            return true;
295✔
71
        }
315✔
72
        protected bool FlagAsClass()
73
        {
1,086✔
74
            if (flaggedAsThis)
1,086✔
75
            {
×
76
                Dbg.Err("Polymorphic Record() detected after a RecordAsThis(); this does not work, RecordAsThis() can be used only if every class involved in the This() chain is of expected type");
×
77
                return false;
×
78
            }
79

80
            flaggedAsClass = true;
1,086✔
81
            return true;
1,086✔
82
        }
1,086✔
83
    }
84
}
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