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

Sholtee / proxygen / 957

03 Apr 2025 03:49AM UTC coverage: 90.283% (+3.1%) from 87.222%
957

push

appveyor

Sholtee
fix method hash generation

4841 of 5362 relevant lines covered (90.28%)

0.9 hits per line

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

76.6
/SRC/Private/Reflection/SymbolAssemblyInfo.cs
1
/********************************************************************************
2
* SymbolAssemblyInfo.cs                                                         *
3
*                                                                               *
4
* Author: Denes Solti                                                           *
5
********************************************************************************/
6
using System;
7
using System.IO;
8

9
using Microsoft.CodeAnalysis;
10
using Microsoft.CodeAnalysis.CSharp;
11

12
namespace Solti.Utils.Proxy.Internals
13
{
14
    internal sealed class SymbolAssemblyInfo(IAssemblySymbol underlyingSymbol, Compilation compilation) : IAssemblyInfo
1✔
15
    {
16
        private IAssemblySymbol UnderlyingSymbol { get; } = underlyingSymbol;
1✔
17

18
        public static IAssemblyInfo CreateFrom(IAssemblySymbol asm, Compilation compilation)
19
        {
1✔
20
            asm.EnsureNotError();
1✔
21

22
            return new SymbolAssemblyInfo(asm, compilation);
1✔
23
        }
1✔
24

25
        private readonly Lazy<string?> FLocation = new(() =>
1✔
26
        {
1✔
27
            if (SymbolEqualityComparer.Default.Equals(underlyingSymbol, compilation.Assembly))
1✔
28
                //
1✔
29
                // Assembly being compiled doesn't have path
1✔
30
                //
1✔
31

1✔
32
                return null;
×
33

1✔
34
            foreach (MetadataReference reference in compilation.References)
×
35
            {
1✔
36
                if (SymbolEqualityComparer.Default.Equals(underlyingSymbol, compilation.GetAssemblyOrModuleSymbol(reference)))
1✔
37
                {
1✔
38
                    //
1✔
39
                    // MetadataReference.Display is not necessarily a path
1✔
40
                    //
1✔
41

1✔
42
                    return !string.IsNullOrEmpty(reference.Display) && File.Exists(reference.Display)
×
43
                        ? reference.Display
×
44
                        : null;
×
45
                }
1✔
46
            }
1✔
47

1✔
48
            return null;
×
49
        });
1✔
50
        public string? Location => FLocation.Value;
1✔
51

52
        public bool IsDynamic => false; // We cannot reference dynamic ASMs during build
1✔
53

54
        public string Name => UnderlyingSymbol.Identity.ToString();
1✔
55

56
        public bool IsFriend(string asmName) => StringComparer.OrdinalIgnoreCase.Equals(UnderlyingSymbol.Name, asmName) || UnderlyingSymbol.GivesAccessTo // TODO: strong name support
1✔
57
        (
1✔
58
            CSharpCompilation.Create(asmName).Assembly
1✔
59
        );
1✔
60

61
        public ITypeInfo? GetType(string fullName)
62
        {
1✔
63
            INamedTypeSymbol? type = UnderlyingSymbol.GetTypeByMetadataName(fullName);
1✔
64

65
            return type is not null
×
66
                ? SymbolTypeInfo.CreateFrom(type, compilation)
×
67
                : null;
×
68
        }
1✔
69

70
        public override int GetHashCode() => SymbolEqualityComparer.Default.GetHashCode(UnderlyingSymbol);
×
71

72
        public override bool Equals(object obj) => obj is SymbolAssemblyInfo that && SymbolEqualityComparer.Default.Equals(that.UnderlyingSymbol, UnderlyingSymbol);
×
73

74
        public override string ToString() => UnderlyingSymbol.ToString();
1✔
75
    }
76
}
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