Skip to content

[Code Origin] DEBUG-3935 Fix type handle mismatch when resolving attribute type #6994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,40 @@ private static bool HasAttributeFromSet(CustomAttributeHandleCollection attribut
{
string fullName;
var attribute = reader.GetCustomAttribute(attributeHandle);
if (attribute.Constructor.Kind == HandleKind.MemberReference)
switch (attribute.Constructor.Kind)
{
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;
case HandleKind.MemberReference:
{
var ctor = reader.GetMemberReference((MemberReferenceHandle)attribute.Constructor);
switch (ctor.Parent.Kind)
{
case HandleKind.TypeReference:
var tr = reader.GetTypeReference((TypeReferenceHandle)ctor.Parent);
fullName = GetFullTypeName(tr.Namespace, tr.Name, reader);
break;

case HandleKind.TypeDefinition:
var td = reader.GetTypeDefinition((TypeDefinitionHandle)ctor.Parent);
fullName = GetFullTypeName(td.Namespace, td.Name, reader);
break;

default:
continue;
}

break;
}

case HandleKind.MethodDefinition:
{
var ctor = reader.GetMethodDefinition((MethodDefinitionHandle)attribute.Constructor);
var td = reader.GetTypeDefinition(ctor.GetDeclaringType());
fullName = GetFullTypeName(td.Namespace, td.Name, reader);
break;
}

default:
continue;
}

if (attributeNames.Contains(fullName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private void AddEntrySpanTags(Span span, Type type, MethodInfo method)
}
catch (Exception ex)
{
Log.Error(ex, "Failed to load PDB info for assembly {AssemblyName}", asm.Location);
Log.Error(ex, "Error while getting endpoints for assembly: {AssemblyName}", asm.Location);
return null;
}
});
Expand Down
Loading