• 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

91.67
/src/Reader.cs
1
using System;
2
using System.Collections;
3
using System.Collections.Generic;
4

5
namespace Dec
6
{
7
    internal abstract class ReaderFileDec
8
    {
9
        public struct ReaderDec
10
        {
11
            public Type type;
12
            public string name;
13

14
            // this is a factory because we need to be able to generate lots of it with different paths
15
            // this is not a good solution
16
            // this needs to go away along with the whole polymorphic ReaderNode system
17
            public Func<Path, ReaderNodeParseable> nodeFactory;
18
            public Context context;
19

20
            public bool? abstrct;
21
            public string parent;
22
        }
23

24
        // this is a little awkward because it mutates state and should not be called twice. we should fix that
25
        public abstract List<ReaderDec> ParseDecs();
26
    }
27

28
    internal abstract class ReaderFileRecorder
29
    {
30
        public struct ReaderRef
31
        {
32
            public Type type;
33
            public string id;
34

35
            public ReaderNodeParseable node;
36
        }
37

38
        // this is a little awkward because it mutates state and should not be called twice. we should fix that
39
        public abstract List<ReaderRef> ParseRefs();
40
        public abstract ReaderNodeParseable ParseNode();
41
    }
42

43
    internal abstract class ReaderNode
44
    {
45
        public virtual bool AllowAsThis { get => true; }
678✔
46
        public abstract Recorder.Purpose Intent { get; }
47
        public abstract Recorder.IUserSettings UserSettings { get; }
48

49
        public abstract Context GetContext(); // note: this function must be really fast!
50

51
        public abstract ReaderNode GetChildNamed(string name);
52
        public abstract string[] GetAllChildren();
53

54
        public abstract int[] GetArrayDimensions(int rank);
55

56
        public abstract object ParseElement(Type type, object model, ReaderGlobals readerGlobals, Recorder.Settings recorderSettings);
57
    }
58

59
    internal abstract class ReaderNodeParseable : ReaderNode
60
    {
61
        public enum Metadata
62
        {
63
            Null,
64
            Ref,
65
            Class,
66
            Mode,
67
        }
68

69
        public override object ParseElement(Type type, object model, ReaderGlobals readerGlobals, Recorder.Settings recorderSettings)
70
        {
926,814✔
71
            return Serialization.ParseElement(new List<ReaderNodeParseable>() { this }, type, model, readerGlobals, recorderSettings);
926,814✔
72
        }
926,814✔
73

74
        public abstract string GetMetadata(Metadata metadata);
75
        public abstract string GetMetadataUnrecognized();
76
        public abstract string GetText();
77

78
        public abstract bool HasChildren();
79

80
        public abstract void ParseList(IList list, Type referencedType, ReaderGlobals readerGlobals, Recorder.Settings recorderSettings);
81
        public abstract void ParseArray(Array array, Type referencedType, ReaderGlobals readerGlobals, Recorder.Settings recorderSettings, int startOffset);
82
        public abstract void ParseDictionary(IDictionary dict, Type referencedKeyType, Type referencedValueType, ReaderGlobals readerGlobals, Recorder.Settings recorderSettings, bool permitPatch);
83
        public abstract void ParseHashset(object hashset, Type referencedType, ReaderGlobals readerGlobals, Recorder.Settings recorderSettings, bool permitPatch);
84
        public abstract void ParseStack(object hashset, Type referencedType, ReaderGlobals readerGlobals, Recorder.Settings recorderSettings);
85
        public abstract void ParseQueue(object hashset, Type referencedType, ReaderGlobals readerGlobals, Recorder.Settings recorderSettings);
86
        public abstract void ParseTuple(object[] parameters, Type referencedType, IList<string> parameterNames, ReaderGlobals readerGlobals, Recorder.Settings recorderSettings);
87
        public abstract void ParseReflection(object obj, ReaderGlobals readerGlobals, Recorder.Settings recorderSettings);
88
    }
89

90
    internal static class ReaderNodeExtension
91
    {
92
        public static string ToLowerString(this ReaderNodeParseable.Metadata metadata)
93
        {
24,856,962✔
94
            // Hardcode lowercase versions of all the enum names for performance.
95
            switch (metadata)
24,856,962✔
96
            {
97
                case ReaderNodeParseable.Metadata.Null: return "null";
5,744,382✔
98
                case ReaderNodeParseable.Metadata.Ref: return "ref";
5,745,060✔
99
                case ReaderNodeParseable.Metadata.Class: return "class";
5,744,382✔
100
                case ReaderNodeParseable.Metadata.Mode: return "mode";
7,623,138✔
101
                default: Dbg.Err($"Unknown attribute type {metadata}"); return "UNKNOWN";
×
102
            }
103
        }
24,856,962✔
104
    }
105
}
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