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

zorbathut / dec / 15122828327

19 May 2025 08:44PM UTC coverage: 90.096% (-0.2%) from 90.272%
15122828327

push

github

zorbathut
Added Intent property to Recorder to indicate Serialization/Cloning/Checksum purpose.

5076 of 5634 relevant lines covered (90.1%)

221085.88 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,809,762✔
12
        {
1,809,762✔
13
            this.settings = settings;
1,809,762✔
14
            this.path = path;
1,809,762✔
15
        }
1,809,762✔
16

17
        public Recorder.Settings RecorderSettings { get => settings; }
3,125,738✔
18
        public abstract bool AllowReflection { get; }
19
        public abstract bool AllowDecPath { get; }
20
        public virtual bool AllowAsThis { get => true; }
342✔
21
        public virtual bool AllowCloning { get => false; }
587,378✔
22
        public abstract Recorder.Purpose Intent { get; }
23
        public abstract Recorder.IUserSettings UserSettings { get; }
24

25
        public Path Path { get => path; }
2,734,622✔
26

27
        // 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
28
        public void MakeRecorderContextChild()
29
        {
624✔
30
            settings = settings.CreateChild();
624✔
31
        }
624✔
32

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

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

57
        public abstract void TagClass(Type type);
58

59
        // general behavior that polymorphics should not reimplement (so far at least?)
60
        protected bool flaggedAsClass = false;
1,809,762✔
61
        protected bool flaggedAsThis = false;
1,809,762✔
62

63
        // attempts to flag as self, posts error if it can't
64
        public bool FlagAsThis()
65
        {
510✔
66
            if (flaggedAsClass)
510✔
67
            {
24✔
68
                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");
24✔
69
                return false;
24✔
70
            }
71

72
            flaggedAsThis = true;
486✔
73
            return true;
486✔
74
        }
510✔
75
        protected bool FlagAsClass()
76
        {
1,544✔
77
            if (flaggedAsThis)
1,544✔
78
            {
×
79
                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");
×
80
                return false;
×
81
            }
82

83
            flaggedAsClass = true;
1,544✔
84
            return true;
1,544✔
85
        }
1,544✔
86
    }
87
}
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