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

JaCraig / Mecha / 19320675031

13 Nov 2025 04:35AM UTC coverage: 81.73% (-0.6%) from 82.353%
19320675031

push

github

JaCraig
feat(project): update dependencies and target frameworks

Update project dependencies and target frameworks to ensure compatibility with the latest versions and improve maintainability.

- Add BOM to `Mecha.Core.Tests.csproj` file.
- Update `TargetFrameworks` in `Mecha.Core.Tests.csproj` to `net9.0` and `net8.0`.
- Upgrade `Microsoft.CodeAnalysis.NetAnalyzers` to `10.0.100`.
- Upgrade `FileCurator` to `5.1.7`.
- Upgrade `System.Text.Json` to `10.0.0`.

754 of 1060 branches covered (71.13%)

Branch coverage included in aggregate %.

1344 of 1507 relevant lines covered (89.18%)

5151122.47 hits per line

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

85.29
/Mecha.Core/Generator/DefaultGenerators/SliceGenerator.cs
1
/*
2
Copyright 2021 James Craig
3

4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7

8
http://www.apache.org/licenses/LICENSE-2.0
9

10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16

17
using Fast.Activator;
18
using Mecha.Core.Generator.DefaultGenerators.Utils;
19
using Mecha.Core.Generator.Interfaces;
20
using System.Reflection;
21

22
namespace Mecha.Core.Generator.DefaultGenerators
23
{
24
    /// <summary>
25
    /// Slice generator
26
    /// </summary>
27
    /// <seealso cref="IGenerator"/>
28
    public class SliceGenerator : IGenerator
29
    {
30
        /// <summary>
31
        /// Gets the order.
32
        /// </summary>
33
        /// <value>The order.</value>
34
        public int Order => 1;
3✔
35

36
        /// <summary>
37
        /// Determines whether this instance can generate the specified parameter.
38
        /// </summary>
39
        /// <param name="parameter">The parameter.</param>
40
        /// <returns>
41
        /// <c>true</c> if this instance can generate the specified parameter; otherwise, <c>false</c>.
42
        /// </returns>
43
        public bool CanGenerate(ParameterInfo? parameter)
44
        {
45
            return parameter?.HasDefaultValue == false
15,864,140!
46
                && (SliceValueLookup.Slice?.ContainsKey(parameter.ParameterType.GetHashCode()) ?? false);
15,864,140✔
47
        }
48

49
        /// <summary>
50
        /// Generates the next object of the specified parameter type.
51
        /// </summary>
52
        /// <param name="parameter">The parameter.</param>
53
        /// <param name="min">The minimum.</param>
54
        /// <param name="max">The maximum.</param>
55
        /// <returns>The next object.</returns>
56
        public ParameterValue? Next(ParameterInfo? parameter, object? min, object? max)
57
        {
58
            if (parameter is null || !CanGenerate(parameter))
62,484✔
59
                return new("Slice Generator", null);
2✔
60
            try
61
            {
62
                min ??= max;
62,482✔
63
                max ??= min;
62,482✔
64
                if (min is null)
62,482✔
65
                    return new("Slice Generator", FastActivator.CreateInstance(parameter.ParameterType));
39✔
66
                var Key = parameter.ParameterType.GetHashCode();
62,443✔
67
                return new("Slice Generator", SliceValueLookup.Slice?[Key](min!, max!) ?? false);
62,443!
68
            }
69
            catch
×
70
            {
71
                return new("Slice Generator", FastActivator.CreateInstance(parameter.ParameterType));
×
72
            }
73
        }
62,482✔
74
    }
75
}
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