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

alunacjones / LSL.VariableReplacer / 51

18 Apr 2025 11:11AM UTC coverage: 98.696% (-0.9%) from 99.556%
51

Pull #11

appveyor

Alun Jones
null check
Pull Request #11: Feature/partials

227 of 230 relevant lines covered (98.7%)

60.25 hits per line

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

83.33
/LSL.VariableReplacer/VariablesFromObjectConfiguration.cs
1
using System;
2

3
namespace LSL.VariableReplacer;
4

5
/// <summary>
6
/// Optional configuration options
7
/// when generating variables from an object
8
/// </summary>
9
public sealed class VariablesFromObjectConfiguration
10
{
11
    internal string PropertyPathSeparator { get; private set; } = ".";
15✔
12
    internal Func<PropertyFilterContext, bool> PropertyFilter { get; private set; }
30✔
13
    internal string Prefix { get; private set; } = string.Empty;
25✔
14
    internal Func<Type, bool> PrimitiveTypeChecker { get; private set; } = type => 
×
15
        type.IsValueType ||
34✔
16
        type.IsPrimitive ||
34✔
17
        type == typeof(string) ||
34✔
18
        Convert.GetTypeCode(type) != TypeCode.Object;
34✔
19

20
    /// <summary>
21
    /// Register a property filter
22
    /// </summary>
23
    /// <param name="propertyFilter"></param>
24
    /// <returns></returns>
25
    public VariablesFromObjectConfiguration WithPropertyFilter(Func<PropertyFilterContext, bool> propertyFilter) => 
26
        this.ReturnThis(() => PropertyFilter = Guard.IsNotNull(propertyFilter, nameof(propertyFilter)));
4✔
27

28
    /// <summary>
29
    /// Set the property path separator
30
    /// </summary>
31
    /// <param name="propertyPathSeparator"></param>
32
    /// <returns></returns>
33
    public VariablesFromObjectConfiguration WithPropertyPathSeparator(string propertyPathSeparator) => 
34
        this.ReturnThis(() => PropertyPathSeparator = Guard.IsNotNull(propertyPathSeparator, nameof(propertyPathSeparator)));
6✔
35

36
    /// <summary>
37
    /// Sets a prefix to apply to all generated variables
38
    /// </summary>
39
    /// <param name="prefix"></param>
40
    /// <returns></returns>
41
    public VariablesFromObjectConfiguration WithPrefix(string prefix) =>
42
        this.ReturnThis(() => Prefix = Guard.IsNotNull(prefix, nameof(prefix)));
2✔
43

44
    /// <summary>
45
    /// Allows for a different implementation of the primitive type checking
46
    /// lambda if the default doesn't cover all scenarios.
47
    /// </summary>
48
    /// <remarks>
49
    /// The default implementation performs the following:
50
    /// <c>type.IsValueType || type.IsPrimitive || type == typeof(string) || Convert.GetTypeCode(type) != TypeCode.Object</c>
51
    /// </remarks>
52
    /// <param name="primitiveTypeChecker"></param>
53
    /// <returns></returns>
54
    public VariablesFromObjectConfiguration WithPrimitiveTypeChecker(Func<Type, bool> primitiveTypeChecker) =>
55
        this.ReturnThis(() => PrimitiveTypeChecker = Guard.IsNotNull(primitiveTypeChecker, nameof(primitiveTypeChecker)));        
×
56
}
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

© 2025 Coveralls, Inc