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

Sholtee / proxygen / 868

01 Nov 2023 05:34AM UTC coverage: 95.021% (+0.1%) from 94.922%
868

push

appveyor

Sholtee
translate some comments, minor refactor

2500 of 2631 relevant lines covered (95.02%)

5.61 hits per line

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

92.31
/SRC/Private/SyntaxFactories/ClassSyntaxFactoryBase.Event.cs
1
/********************************************************************************
2
* ClassSyntaxFactoryBase.Event.cs                                               *
3
*                                                                               *
4
* Author: Denes Solti                                                           *
5
********************************************************************************/
6
using System.Collections.Generic;
7
using System.Diagnostics;
8
using System.Linq;
9

10
using Microsoft.CodeAnalysis.CSharp;
11
using Microsoft.CodeAnalysis.CSharp.Syntax;
12

13
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
14

15
namespace Solti.Utils.Proxy.Internals
16
{
17
    internal partial class ClassSyntaxFactoryBase
18
    {
19
        /// <summary>
20
        /// <code>
21
        /// event TDelegate IInterface.EventName
22
        /// {                                    
23
        ///   add{...}                           
24
        ///   remove{...}                       
25
        /// }                                    
26
        /// </code>
27
        /// </summary>
28
        #if DEBUG
29
        internal
30
        #endif
31
        protected EventDeclarationSyntax ResolveEvent(IEventInfo @event, CSharpSyntaxNode? addBody, CSharpSyntaxNode? removeBody, bool forceInlining = false)
32
        {
6✔
33
            Debug.Assert(@event.DeclaringType.IsInterface);
6✔
34

35
            EventDeclarationSyntax result = EventDeclaration
6✔
36
            (
37
                type: ResolveType(@event.Type),
38
                identifier: Identifier(@event.Name)
39
            )
40
            .WithExplicitInterfaceSpecifier
41
            (
42
                explicitInterfaceSpecifier: ExplicitInterfaceSpecifier
43
                (
44
                    (NameSyntax) ResolveType(@event.DeclaringType)
45
                )
46
            );
47

48
            List<AccessorDeclarationSyntax> accessors = new(2);
6✔
49

50
            if (@event.AddMethod is not null && addBody is not null)
6✔
51
                accessors.Add
6✔
52
                (
53
                    ResolveAccessor(SyntaxKind.AddAccessorDeclaration, addBody, forceInlining)
54
                );
55

56
            if (@event.RemoveMethod is not null && removeBody is not null)
6✔
57
                accessors.Add
6✔
58
                (
59
                    ResolveAccessor(SyntaxKind.RemoveAccessorDeclaration, removeBody, forceInlining)
60
                );
61

62
            return !accessors.Any() ? result : result.WithAccessorList
6✔
63
            (
64
                accessorList: AccessorList
65
                (
66
                    accessors: List(accessors)
67
                )
68
            );
69
        }
6✔
70

71
        /// <summary>
72
        /// <code>
73
        /// target.Event [+|-]= ...;
74
        /// </code>
75
        /// </summary>
76
        #if DEBUG
77
        internal
78
        #endif
79
        protected AssignmentExpressionSyntax RegisterEvent(IEventInfo @event, ExpressionSyntax? target, bool add, ExpressionSyntax right, ITypeInfo? castTargetTo = null) => AssignmentExpression
6✔
80
        (
81
            kind: add ? SyntaxKind.AddAssignmentExpression : SyntaxKind.SubtractAssignmentExpression,
82
            left: MemberAccess
83
            (
84
                target,
85
                @event,
86
                castTargetTo
87
            ),
88
            right: right
89
        );
90

91
        #if DEBUG
92
        internal
93
        #endif
94
        protected virtual ClassDeclarationSyntax ResolveEvents(ClassDeclarationSyntax cls, object context) => cls;
6✔
95

96
        #if DEBUG
97
        internal
98
        #endif
99
        protected virtual ClassDeclarationSyntax ResolveEvent(ClassDeclarationSyntax cls, object context, IEventInfo evt) => cls;
×
100
    }
101
}
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