Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dudikeleti committed Nov 15, 2024
1 parent 9c86443 commit c8ef7f1
Show file tree
Hide file tree
Showing 3 changed files with 322 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,24 @@ private static bool HasAttributeFromSet(CustomAttributeHandleCollection attribut
{
foreach (var attributeHandle in attributes)
{
string fullName;
var attribute = reader.GetCustomAttribute(attributeHandle);
var ctor = reader.GetMemberReference((MemberReferenceHandle)attribute.Constructor);
var attributeType = reader.GetTypeReference((TypeReferenceHandle)ctor.Parent);
var fullName = GetFullTypeName(attributeType.Namespace, attributeType.Name, reader);
if (attribute.Constructor.Kind == HandleKind.MemberReference)
{
var ctor = reader.GetMemberReference((MemberReferenceHandle)attribute.Constructor);
var attributeType = reader.GetTypeReference((TypeReferenceHandle)ctor.Parent);
fullName = GetFullTypeName(attributeType.Namespace, attributeType.Name, reader);
}
else if (attribute.Constructor.Kind == HandleKind.MethodDefinition)
{
var ctor = reader.GetMethodDefinition((MethodDefinitionHandle)attribute.Constructor);
var attributeType = reader.GetTypeDefinition(ctor.GetDeclaringType());
fullName = GetFullTypeName(attributeType.Namespace, attributeType.Name, reader);
}
else
{
continue;
}

if (attributeNames.Contains(fullName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ internal class SpanCodeOriginManager
{
private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(SpanCodeOriginManager));

private readonly int _maxUserFrames;

private readonly bool _isCodeOriginEnabled;

private readonly ConcurrentDictionary<Assembly, AssemblyPdbInfo?> _assemblyPdbCache = new();

private readonly CodeOriginTags _tags;

private readonly int _maxUserFrames;

private readonly bool _isCodeOriginEnabled;

private readonly ImmutableHashSet<string> _thirdPartyDetectionExcludes;

private readonly ImmutableHashSet<string> _thirdPartyDetectionIncludes;

private SpanCodeOriginManager()
{
_tags = new CodeOriginTags(_maxUserFrames);
var settings = LiveDebugger.Instance?.Settings ?? DebuggerSettings.FromDefaultSource();
_maxUserFrames = settings.CodeOriginMaxUserFrames;
_isCodeOriginEnabled = settings.CodeOriginForSpansEnabled;
_tags = new CodeOriginTags(_maxUserFrames);
_thirdPartyDetectionExcludes = settings.ThirdPartyDetectionExcludes;
_thirdPartyDetectionIncludes = settings.ThirdPartyDetectionIncludes;
}
Expand Down
Loading

0 comments on commit c8ef7f1

Please sign in to comment.