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

NetFabric / NetFabric.CodeAnalysis / 6130084901

09 Sep 2023 09:14AM UTC coverage: 83.158% (+0.2%) from 82.932%
6130084901

push

github

web-flow
Fixes (#27)

227 of 266 branches covered (0.0%)

Branch coverage included in aggregate %.

661 of 661 new or added lines in 31 files covered. (100.0%)

642 of 779 relevant lines covered (82.41%)

18.46 hits per line

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

91.67
/NetFabric.Reflection/Reflection/TypeExtensions.IsDisposable.cs
1
using System;
2
using System.Diagnostics.CodeAnalysis;
3
using System.Reflection;
4

5
namespace NetFabric.Reflection;
6

7
public static partial class TypeExtensions
8
{
9
    /// <summary>
10
    /// Gets a value indicating whether 'using' considers <see cref="System.Type"/> to be disposable.
11
    /// </summary>
12
    /// <param name="type">The <see cref="System.Type"/> to test.</param>
13
    /// <param name="dispose">If methods returns <c>true</c>, contains information on the disposed method 'using' will use.</param>
14
    /// <returns><c>true</c> if 'using' considers <see cref="System.Type"/> to be disposable; otherwise, <c>false</c>.</returns>
15
    /// <remarks>
16
    /// The 'foreach' statement uses a 'using' internally so the same rules apply.
17
    /// </remarks>
18
    public static bool IsDisposable(this Type type, [NotNullWhen(true)] out MethodInfo? dispose)
19
        => type.IsDisposable(out dispose, out _);
×
20
    
21
    internal static bool IsDisposable(this Type type, [NotNullWhen(true)] out MethodInfo? dispose, out bool isByRefLike)
22
    {
23
        isByRefLike = type.IsByRefLike();
95✔
24
        if (isByRefLike)
95✔
25
            dispose = type.GetPublicInstanceDeclaredOnlyMethod(NameOf.Dispose, Type.EmptyTypes);
24✔
26
        else if (type.ImplementsInterface(typeof(IDisposable), out _))
71✔
27
            dispose = typeof(IDisposable).GetPublicInstanceDeclaredOnlyMethod(NameOf.Dispose, Type.EmptyTypes)!;
36✔
28
        else
29
            dispose = default;
35✔
30
        
31
        return dispose is not null;
95✔
32
    }
33
}
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

© 2025 Coveralls, Inc