• 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.CodeAnalysis/ITypeSymbolExtensions.IsDisposable.cs
1
using Microsoft.CodeAnalysis;
2
using System;
3
using System.Diagnostics.CodeAnalysis;
4

5
namespace NetFabric.CodeAnalysis;
6

7
public static partial class ITypeSymbolExtensions
8
{
9

10
    /// <summary>
11
    /// Gets a value indicating whether 'using' considers <see cref="Microsoft.CodeAnalysis.ITypeSymbol"/> to be disposable.
12
    /// </summary>
13
    /// <param name="typeSymbol">The <see cref="Microsoft.CodeAnalysis.ITypeSymbol"/> to test.</param>
14
    /// <param name="compilation">The <see cref="Microsoft.CodeAnalysis.Compilation"/> context.</param>
15
    /// <param name="dispose">If methods returns <c>true</c>, contains information on the disposed method 'using' will use.</param>
16
    /// <returns><c>true</c> if 'using' considers <see cref="Microsoft.CodeAnalysis.ITypeSymbol"/> to be disposable; otherwise, <c>false</c>.</returns>
17
    /// <remarks>
18
    /// The 'foreach' statement uses a 'using' internally so the same rules apply.
19
    /// </remarks>
20
    public static bool IsDisposable(this ITypeSymbol typeSymbol, Compilation compilation,
21
        [NotNullWhen(true)] out IMethodSymbol? dispose)
22
        => typeSymbol.IsDisposable(compilation, out dispose, out _);
×
23
    
24
    static bool IsDisposable(this ITypeSymbol typeSymbol, Compilation compilation, 
25
        [NotNullWhen(true)] out IMethodSymbol? dispose,
26
        out bool isRefLike)
27
    {
28
        isRefLike = typeSymbol.IsRefLikeType;
15✔
29
        if (isRefLike)
15✔
30
            dispose = typeSymbol.GetPublicMethod(NameOf.Dispose);
4✔
31
        else if (typeSymbol.ImplementsInterface(SpecialType.System_IDisposable, out _))
11✔
32
            dispose = compilation.GetSpecialType(SpecialType.System_IDisposable).GetPublicMethod(NameOf.Dispose);
3✔
33
        else
34
            dispose = default;
8✔
35

36
        return dispose is not null;
15✔
37
    }
38

39
}
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