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

Sholtee / proxygen / 1060

02 May 2025 09:09AM UTC coverage: 92.623% (-0.08%) from 92.705%
1060

push

appveyor

Sholtee
fix RoslynV3 ParameterList issue

4859 of 5246 relevant lines covered (92.62%)

0.93 hits per line

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

86.05
/SRC/Private/SyntaxFactories/DuckSyntaxFactory.EventInterceptorFactory.cs
1
/********************************************************************************
2
* DuckSyntaxFactory.EventInterceptorFactory.cs                                  *
3
*                                                                               *
4
* Author: Denes Solti                                                           *
5
********************************************************************************/
6
using System.Linq;
7

8
using Microsoft.CodeAnalysis.CSharp.Syntax;
9

10
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
11

12
namespace Solti.Utils.Proxy.Internals
13
{
14
    internal partial class DuckSyntaxFactory
15
    {
16
        #if DEBUG
17
        internal
18
        #endif
19
        protected override ClassDeclarationSyntax ResolveEvents(ClassDeclarationSyntax cls, object context)
20
        {
1✔
21
            foreach (IEventInfo ifaceEvt in FInterfaceType.Events)
1✔
22
            {
1✔
23
                IEventInfo targetEvt = GetTargetMember
1✔
24
                (
1✔
25
                    ifaceEvt,
1✔
26
                    TargetType!.Events,
1✔
27
                    static (targetEvent, ifaceEvent) =>
1✔
28
                        targetEvent.AddMethod.SignatureEquals(ifaceEvent.AddMethod, ignoreVisibility: true) &&
×
29
                        targetEvent.RemoveMethod.SignatureEquals(ifaceEvent.RemoveMethod, ignoreVisibility: true)
×
30
                );
1✔
31

32
                cls = ResolveEvent(cls, ifaceEvt, targetEvt);
1✔
33
            }
1✔
34

35
            return cls;
1✔
36
        }
1✔
37

38
        /// <summary>
39
        /// <code>
40
        /// event TDelegate IFoo&lt;System.Int32&gt;.Event    
41
        /// {                                            
42
        ///   add => Target.Event += value;             
43
        ///   remove => Target.Event -= value;         
44
        /// }
45
        /// </code>
46
        /// </summary>
47
        #if DEBUG
48
        internal
49
        #endif
50
        protected override ClassDeclarationSyntax ResolveEvent(ClassDeclarationSyntax cls, object context, IEventInfo targetEvt)
51
        {
1✔
52
            Visibility.Check(targetEvt, ContainingAssembly);
1✔
53

54
            IMethodInfo accessor = targetEvt.AddMethod ?? targetEvt.RemoveMethod!;
×
55

56
            //
57
            // Explicit members cannot be accessed directly
58
            //
59

60
            ITypeInfo? castTargetTo = accessor.AccessModifiers is AccessModifiers.Explicit
×
61
                ? accessor.DeclaringInterfaces.Single() // Explicit event can have exactly one declaring interface
×
62
                : null;
×
63

64
            IEventInfo ifaceEvt = (IEventInfo) context;
1✔
65

66
            return cls.AddMembers
1✔
67
            (
1✔
68
                ResolveEvent
1✔
69
                (
1✔
70
                    ifaceEvt,
1✔
71
                    addBody: CreateBody(register: true),
1✔
72
                    removeBody: CreateBody(register: false)
1✔
73
                )
1✔
74
            );
1✔
75

76
            ArrowExpressionClauseSyntax CreateBody(bool register) => ArrowExpressionClause
1✔
77
            (
1✔
78
                expression: RegisterEvent
1✔
79
                (
1✔
80
                    targetEvt,
1✔
81
                    GetTarget(),
1✔
82
                    register,
1✔
83
                    FValue,
1✔
84
                    castTargetTo
1✔
85
                )
1✔
86
            );
1✔
87
        }
1✔
88
    }
89
}
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