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

xaviersolau / GeneratorTools / 14023481222

23 Mar 2025 10:12PM UTC coverage: 86.508% (+0.05%) from 86.456%
14023481222

push

github

xaviersolau
Bump to version 1.0.0-alpha.44

3815 of 4410 relevant lines covered (86.51%)

10671.66 hits per line

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

90.91
/src/libs/SoloX.GeneratorTools.Core.CSharp/Model/Impl/Loader/Parser/ParserEnumDeclarationLoader.cs
1
// ----------------------------------------------------------------------
2
// <copyright file="ParserEnumDeclarationLoader.cs" company="Xavier Solau">
3
// Copyright © 2021 Xavier Solau.
4
// Licensed under the MIT license.
5
// See LICENSE file in the project root for full license information.
6
// </copyright>
7
// ----------------------------------------------------------------------
8

9
using Microsoft.CodeAnalysis;
10
using SoloX.GeneratorTools.Core.CSharp.Exceptions;
11
using SoloX.GeneratorTools.Core.CSharp.Model.Resolver;
12
using SoloX.GeneratorTools.Core.CSharp.Model.Use.Impl.Walker;
13
using SoloX.GeneratorTools.Core.CSharp.Model.Use;
14
using SoloX.GeneratorTools.Core.Utils;
15
using System.Collections.Generic;
16
using System.Linq;
17
using SoloX.GeneratorTools.Core.CSharp.Model.Impl.Walker;
18
using System;
19

20
namespace SoloX.GeneratorTools.Core.CSharp.Model.Impl.Loader.Parser
21
{
22
    internal class ParserEnumDeclarationLoader : AEnumDeclarationLoader
23
    {
24
        private readonly IGeneratorLogger<ParserEnumDeclarationLoader> logger;
25

26
        public ParserEnumDeclarationLoader(IGeneratorLogger<ParserEnumDeclarationLoader> logger)
122✔
27
        {
28
            this.logger = logger;
122✔
29
        }
122✔
30

31
        internal override void Load(EnumDeclaration declaration, IDeclarationResolver resolver)
32
        {
33
            var baseListSyntax = declaration.SyntaxNodeProvider.SyntaxNode.BaseList;
4✔
34

35
            if (baseListSyntax != null)
4✔
36
            {
37
                var baseWalker = new DeclarationUseWalker(resolver, null);
1✔
38
                var uses = new List<IDeclarationUse<SyntaxNode>>();
1✔
39

40
                foreach (var node in baseListSyntax.ChildNodes())
4✔
41
                {
42
                    var use = baseWalker.Visit(node);
1✔
43

44
                    if (use == null)
1✔
45
                    {
46
                        throw new ParserException("Unable to load Declaration use.", node);
×
47
                    }
48

49
                    uses.Add(use);
1✔
50
                }
51

52
                if (uses.Count != 1)
1✔
53
                {
54
                    this.logger.LogError($"Expected only one type as extension for {declaration.FullName}.");
×
55
                }
56

57
                declaration.UnderlyingType = uses.Single();
1✔
58
            }
59
            LoadAttributes(declaration, resolver);
4✔
60
        }
4✔
61

62
        private static void LoadAttributes(EnumDeclaration declaration, IDeclarationResolver resolver)
63
        {
64
            var attributeList = new List<IAttributeUse>();
4✔
65
            var attributesWalker = new AttributesWalker(resolver, null, attributeList);
4✔
66

67
            attributesWalker.Visit(declaration.SyntaxNodeProvider.SyntaxNode);
4✔
68

69
            declaration.Attributes = attributeList.Count > 0 ? attributeList.ToArray() : Array.Empty<IAttributeUse>();
4✔
70
        }
4✔
71
    }
72
}
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