Skip to content
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 @@ -81,9 +81,15 @@ bool IAssemblySymbol.GivesAccessTo(IAssemblySymbol assemblyWantingAccess)

AssemblyIdentity identity = UnderlyingAssemblySymbol.Identity;

// Avoid using the identity to obtain the public key if possible to avoid the allocations associated
// with identity creation
ImmutableArray<byte> publicKey = (assemblyWantingAccess is AssemblySymbol assemblyWantingAccessAssemblySymbol)
Copy link
Contributor

@AlekseyTs AlekseyTs Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

publicKey

I think we should make a similar change for VB implementation as well #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good catch. Done in commit 2.

? assemblyWantingAccessAssemblySymbol.UnderlyingAssemblySymbol.PublicKey.NullToEmpty()
: assemblyWantingAccess.Identity.PublicKey;

foreach (var key in myKeys)
{
IVTConclusion conclusion = identity.PerformIVTCheck(assemblyWantingAccess.Identity.PublicKey, key);
IVTConclusion conclusion = identity.PerformIVTCheck(publicKey, key);
Debug.Assert(conclusion != IVTConclusion.NoRelationshipClaimed);
if (conclusion == IVTConclusion.Match || conclusion == IVTConclusion.OneSignedOneNot)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Return True
End If

' Avoid using the identity to obtain the public key if possible to avoid the allocations associated
' with identity creation
Dim assemblyWantingAccessAssemblySymbol As AssemblySymbol = TryCast(assemblyWantingAccess, AssemblySymbol)
Dim publicKey = If(assemblyWantingAccessAssemblySymbol IsNot Nothing, assemblyWantingAccessAssemblySymbol.PublicKey.NullToEmpty(), assemblyWantingAccess.Identity.PublicKey)

For Each key In myKeys
Dim conclusion As IVTConclusion = Me.Identity.PerformIVTCheck(assemblyWantingAccess.Identity.PublicKey, key)
Dim conclusion As IVTConclusion = Me.Identity.PerformIVTCheck(publicKey, key)
Debug.Assert(conclusion <> IVTConclusion.NoRelationshipClaimed)
If conclusion = IVTConclusion.Match Then
' Note that C# includes OrElse conclusion = IVTConclusion.OneSignedOneNot
Expand Down