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

Sholtee / proxygen / 1005

17 Apr 2025 01:11PM UTC coverage: 91.501% (+1.3%) from 90.219%
1005

push

appveyor

Sholtee
greenify tests

5006 of 5471 relevant lines covered (91.5%)

0.92 hits per line

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

91.3
/SRC/Private/SourceGenerators/ProxyEmbedderBase.cs
1
/********************************************************************************
2
* ProxyEmbedderBase.cs                                                          *
3
*                                                                               *
4
* Author: Denes Solti                                                           *
5
********************************************************************************/
6
using System;
7
using System.Collections.Generic;
8
using System.Diagnostics;
9
using System.Linq;
10
using System.Threading;
11

12
using Microsoft.CodeAnalysis;
13
using Microsoft.CodeAnalysis.CSharp;
14
using Microsoft.CodeAnalysis.Diagnostics;
15

16
namespace Solti.Utils.Proxy.Internals
17
{
18
    internal abstract partial class ProxyEmbedderBase
19
    {
20
        protected static readonly SymbolEqualityComparer SymbolEqualityComparer = SymbolEqualityComparer.Default;
1✔
21

22
        protected static void Execute
23
        (
24
            Compilation cmp,
25
            AnalyzerConfigOptions configOptions,
26
            IReadOnlyCollection<INamedTypeSymbol> aotGenerators,
27
            Action<Diagnostic> reportDiagnostic,
28
            Action<SourceCode> addSource,
29
            CancellationToken cancellation
30
        )
31
        {
1✔
32
            Config config = new
1✔
33
            (
1✔
34
                new AnalyzerConfigReader(configOptions)
1✔
35
            );
1✔
36
#if DEBUG
37
            if (config.DebugGenerator && !Debugger.IsAttached)
×
38
                Debugger.Launch();
×
39
#endif
40
            //
41
            // Only C# 7.0+ is supported
42
            //
43

44
            if (cmp is not CSharpCompilation { LanguageVersion: >= LanguageVersion.CSharp7 } compilation)
1✔
45
            {
1✔
46
                reportDiagnostic
1✔
47
                (
1✔
48
                    Diagnostics.PGE00(Location.None)
1✔
49
                );
1✔
50
                return;
1✔
51
            }
52

53
            if (!aotGenerators.Any())
1✔
54
                return;
1✔
55

56
            int extensionCount = 0;
1✔
57

58
            foreach (INamedTypeSymbol generator in aotGenerators)
1✔
59
            {
1✔
60
                Location location = generator.Locations[0];  // don't use Single() here
1✔
61

62
                try
63
                {
1✔
64
                    generator.EnsureNotError();
1✔
65

66
                    ExtendWith
1✔
67
                    (
1✔
68
                        CreateMainUnit(generator, compilation, config),
1✔
69
                        location
1✔
70
                    );
1✔
71

72
                    extensionCount++;
1✔
73
                }
1✔
74
                catch (InvalidSymbolException)
1✔
75
                {
1✔
76
                    //
77
                    // Jump to the next generator
78
                    //
79
                }
1✔
80
                catch (Exception e)
1✔
81
                {
1✔
82
                    ReportError(e, location);
1✔
83
                }
1✔
84
            }
1✔
85

86
            //
87
            // Chunks are applied only if the source has been augmented.
88
            //
89

90
            if (extensionCount > 0)
1✔
91
            {
1✔
92
                try
93
                {
1✔
94
                    foreach (UnitSyntaxFactoryBase chunk in CreateChunks(compilation, config))
1✔
95
                    {
1✔
96
                        ExtendWith(chunk, Location.None);
1✔
97
                    }
1✔
98
                }
1✔
99
                catch (Exception e)
×
100
                {
×
101
                    ReportError(e, Location.None);
×
102
                }
×
103
            }
1✔
104

105
            void ReportError(Exception ex, Location location) => reportDiagnostic
1✔
106
            (
1✔
107
                Diagnostics.PGE01
1✔
108
                (
1✔
109
                    location,
1✔
110
                    ex.Message,
1✔
111
                    LogException(ex, cancellation) ?? "NULL"
1✔
112
                )
1✔
113
            );
1✔
114

115
            void ExtendWith(UnitSyntaxFactoryBase syntaxFactory, Location location)
116
            {
1✔
117
                SourceCode source = syntaxFactory.GetSourceCode(cancellation); 
1✔
118

119
                addSource(source);
1✔
120

121
                reportDiagnostic
1✔
122
                (
1✔
123
                    Diagnostics.PGI00(location, source.Hint)
1✔
124
                );
1✔
125
            }
1✔
126
        }
1✔
127
    }
128
}
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