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

NetFabric / NetFabric.Hyperlinq.Analyzer / 6482674575

11 Oct 2023 12:45PM UTC coverage: 80.314% (+0.9%) from 79.368%
6482674575

Pull #75

github

aalmada
Fix build
Pull Request #75: Add IsIndexable

501 of 644 branches covered (0.0%)

Branch coverage included in aggregate %.

110 of 110 new or added lines in 13 files covered. (100.0%)

882 of 1078 relevant lines covered (81.82%)

20.07 hits per line

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

72.34
/NetFabric.Hyperlinq.Analyzer/Utils/FieldDeclarationSyntaxExtensions.cs
1
using Microsoft.CodeAnalysis;
2
using Microsoft.CodeAnalysis.CSharp;
3
using Microsoft.CodeAnalysis.CSharp.Syntax;
4
using Microsoft.CodeAnalysis.Diagnostics;
5
using NetFabric.CodeAnalysis;
6
using System.Diagnostics.CodeAnalysis;
7
using System.Linq;
8

9
namespace NetFabric.Hyperlinq.Analyzer
10
{
11
    static class FieldDeclarationSyntaxExtensions
12
    {
13
        public static bool IsPublic(this FieldDeclarationSyntax fieldDeclarationSyntax)
14
        {
15
            if (!fieldDeclarationSyntax.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.PublicKeyword)))
8✔
16
                return false;
4✔
17

18
            for (var node = fieldDeclarationSyntax.Parent; node is not null; node = node.Parent)
16✔
19
            {
20
                if (node is TypeDeclarationSyntax type)
6✔
21
                {
22
                    if (!type.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.PublicKeyword)))
4!
23
                        return false;
×
24
                }
25
            }
26
            return true;
2✔
27
        }
28

29
        public static bool IsEnumerableValueType(this FieldDeclarationSyntax fieldDeclarationSyntax, SyntaxNodeAnalysisContext context, [NotNullWhen(true)] out ITypeSymbol? typeSymbol)
30
        {
31
            typeSymbol = context.SemanticModel.GetTypeInfo(fieldDeclarationSyntax.Declaration.Type).Type;
3✔
32
            if (typeSymbol is null)
3!
33
                return false;
×
34

35
            if (typeSymbol.TypeKind == TypeKind.TypeParameter)
3✔
36
            {
37
                var typeDeclaration = fieldDeclarationSyntax.Ancestors().OfType<TypeDeclarationSyntax>().FirstOrDefault();
1✔
38
                if (typeDeclaration is null)
1!
39
                    return false;
×
40

41
                var typeName = typeSymbol.Name;
1✔
42
                var constraintClauses = typeDeclaration.ConstraintClauses.FirstOrDefault(node => node.Name.Identifier.ValueText == typeName);
2✔
43
                if (constraintClauses is null || !constraintClauses.Constraints.Any(constraint => constraint.IsEnumerator(context)))
3!
44
                    return false;
×
45
            }
46
            else
47
            {
48
                if (!typeSymbol.IsValueType
2!
49
                    || !(typeSymbol.IsEnumerator()
2✔
50
                        || typeSymbol.IsAsyncEnumerator(context.Compilation)))
2✔
51
                    return false;
×
52
            }
53

54
            return true;
3✔
55
        }
56
    }
57
}
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