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

Sholtee / proxygen / 1032

26 Apr 2025 04:30AM UTC coverage: 92.643% (+1.0%) from 91.629%
1032

push

appveyor

Sholtee
+1 test case

4810 of 5192 relevant lines covered (92.64%)

0.93 hits per line

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

75.0
/SRC/Public/Generators/InterfaceProxyGenerator.cs
1
/********************************************************************************
2
* InterfaceProxyGenerator.cs                                                    *
3
*                                                                               *
4
* Author: Denes Solti                                                           *
5
********************************************************************************/
6
using System;
7
using System.Threading;
8
using System.Threading.Tasks;
9

10
namespace Solti.Utils.Proxy.Generators
11
{
12
    using Internals;
13

14
    /// <summary>
15
    /// Creates a new <see cref="InterfaceProxyGenerator"/> instance which hooks into the given <paramref name="interface"/>.
16
    /// </summary>
17
    /// <param name="interface">The interface to be proxied</param>
18
    public sealed class InterfaceProxyGenerator(Type @interface) : Generator(id: GenerateId(nameof(InterfaceProxyGenerator), @interface))
1✔
19
    {
20
        /// <summary>
21
        /// The target class or interface for which the proxy will be created.
22
        /// </summary>
23
        public Type Interface { get; } = @interface ?? throw new ArgumentNullException(nameof(@interface));
1✔
24

25
        /// <summary>
26
        /// Activates the proxy type.
27
        /// </summary>
28
        public async Task<object> ActivateAsync(IInterceptor interceptor, object? target = null, CancellationToken cancellation = default)
29
        {
1✔
30
            object result = await base.ActivateAsync(null, cancellation);
1✔
31
            ((ITargetAccess) result).Target = target;
1✔
32
            ((IInterceptorAccess) result).Interceptor = interceptor ?? throw new ArgumentNullException(nameof(interceptor));
×
33
            return result;
1✔
34
        }
1✔
35

36
        /// <summary>
37
        /// Activates the underlying duck type.
38
        /// </summary>
39
        public object Activate(IInterceptor interceptor, object? target = null) => ActivateAsync(interceptor, target, CancellationToken.None)
×
40
            .GetAwaiter()
×
41
            .GetResult();
×
42

43
        private protected override ProxyUnitSyntaxFactoryBase CreateMainUnit(SyntaxFactoryContext context) => new InterfaceProxySyntaxFactory
1✔
44
        (
1✔
45
            MetadataTypeInfo.CreateFrom(Interface),
1✔
46
            context
1✔
47
        );
1✔
48
    }
49
}
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