14 types derived from PortableExecutableReference
Microsoft.CodeAnalysis (1)
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (1)
Microsoft.CodeAnalysis.InteractiveHost (1)
Microsoft.CodeAnalysis.LanguageServer (1)
Microsoft.CodeAnalysis.Test.Utilities (2)
Microsoft.CodeAnalysis.UnitTests (2)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (1)
Microsoft.CodeAnalysis.Workspaces (2)
Microsoft.VisualStudio.LanguageServices (1)
Microsoft.VisualStudio.LanguageServices.UnitTests (1)
VBCSCompiler (1)
2 instantiations of PortableExecutableReference
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (1)
Microsoft.VisualStudio.LanguageServices.UnitTests (1)
1222 references to PortableExecutableReference
ConfigurationSchemaGenerator (2)
Microsoft.CodeAnalysis (49)
ReferenceManager\CommonReferenceManager.Resolution.cs (7)
320var peReference = (PortableExecutableReference)boundReference;
475private Metadata? GetMetadata(PortableExecutableReference peReference, CommonMessageProvider messageProvider, Location location, DiagnosticBag diagnostics)
505newDiagnostic = PortableExecutableReference.ExceptionToDiagnostic(e, messageProvider, location, peReference.Display ?? "", peReference.Properties.Kind);
526private bool TryGetObservedMetadata(PortableExecutableReference peReference, DiagnosticBag diagnostics, out Metadata? metadata)
545internal AssemblyMetadata? GetAssemblyMetadata(PortableExecutableReference peReference, DiagnosticBag diagnostics)
868private static PortableExecutableReference? ResolveReferenceDirective(string reference, Location location, TCompilation compilation)
Microsoft.CodeAnalysis.CSharp (5)
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (2)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (3)
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (51)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (13)
Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests (6)
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (2)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (43)
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (243)
Compilation\ReferenceManagerTests.cs (55)
41var wimpl = AssemblyMetadata.CreateFromImage(TestResources.WinRt.WImpl).GetReference(display: "WImpl");
61var v1 = AssemblyMetadata.CreateFromImage(TestResources.General.C1).GetReference(display: "C, V1");
64var v2 = AssemblyMetadata.CreateFromImage(TestResources.General.C2).GetReference(display: "C, V2");
105var v1 = MetadataReference.CreateFromImage(TestResources.General.C1);
106var v2 = MetadataReference.CreateFromImage(TestResources.General.C2);
741var r1 = AssemblyMetadata.CreateFromImage(Net461.Resources.SystemCore).GetReference(filePath: @"c:\temp\aa.dll", display: "System.Core.v4_0_30319.dll");
742var r2 = AssemblyMetadata.CreateFromImage(Net461.Resources.SystemCore).GetReference(filePath: @"c:\temp\aa.dll", display: "System.Core.v4_0_30319.dll");
743var r2_SysCore = r2.WithAliases(new[] { "SysCore" });
756var r1 = AssemblyMetadata.CreateFromImage(TestResources.General.C1).GetReference(filePath: @"c:\temp\a.dll", display: "R1");
757var r2 = AssemblyMetadata.CreateFromImage(TestResources.General.C1).GetReference(filePath: @"c:\temp\a.dll", display: "R2");
758var rGoo = r2.WithAliases(new[] { "goo" });
759var rBar = r2.WithAliases(new[] { "bar" });
760var rEmbed = r1.WithEmbedInteropTypes(true);
856var r1 = MetadataReference.CreateFromFile(p1);
857var r2 = MetadataReference.CreateFromFile(p2);
858var r3 = MetadataReference.CreateFromFile(p3);
871assemblyNames: new Dictionary<string, PortableExecutableReference> { { "Lib", r3 } },
872files: new Dictionary<string, PortableExecutableReference> { { p2, r2 }, { p3, r3 } }))
898var dr1 = compilation.GetDirectiveReference(rd1) as PortableExecutableReference;
899var dr2 = compilation.GetDirectiveReference(rd2) as PortableExecutableReference;
900var dr3 = compilation.GetDirectiveReference(rd3) as PortableExecutableReference;
927var m1 = MetadataReference.CreateFromFile(p1, new MetadataReferenceProperties(MetadataImageKind.Module));
928var m2 = MetadataReference.CreateFromFile(p2, new MetadataReferenceProperties(MetadataImageKind.Module));
959var ref1 = AssemblyMetadata.CreateFromImage(TestResources.General.C2).GetReference(embedInteropTypes: true, filePath: @"R:\A\MTTestLib1.dll");
960var ref2 = AssemblyMetadata.CreateFromImage(TestResources.General.C2).GetReference(embedInteropTypes: false, filePath: @"R:\B\MTTestLib1.dll");
996var r1 = MetadataReference.CreateFromFile(p1);
997var r2 = MetadataReference.CreateFromFile(p2);
1043var ref1 = AssemblyMetadata.CreateFromFile(exe1.Path).GetReference(aliases: ImmutableArray.Create("A1"));
1044var ref2 = AssemblyMetadata.CreateFromFile(exe2.Path).GetReference(aliases: ImmutableArray.Create("A2"));
1129var mdRefLib1 = metadataLib1.GetReference(filePath: @"C:\W1.dll");
1130var mdRefLib2 = metadataLib2.GetReference(filePath: @"C:\W2.dll");
1164var mdRefLib1 = metadataLib1.GetReference(filePath: @"C:\W1.dll");
1165var mdRefLib2 = metadataLib2.GetReference(filePath: @"C:\WB.dll");
1194var mdRefLib1 = metadataLib1.GetReference(filePath: @"C:\WB.dll");
1195var mdRefLib2 = metadataLib2.GetReference(filePath: @"C:\WB_Version1.dll");
1214var arSA = TestReferences.SymbolsTests.Versioning.AR_SA;
1215var enUS = TestReferences.SymbolsTests.Versioning.EN_US;
1246public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
1259return ImmutableArray<PortableExecutableReference>.Empty;
1305public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
1368files: new Dictionary<string, PortableExecutableReference>()
1394var refB = MetadataReference.CreateFromImage(b.EmitToArray());
1404var refA2 = MetadataReference.CreateFromImage(a2.EmitToArray());
1441var refB = MetadataReference.CreateFromImage(b.EmitToArray());
1445var refA2 = MetadataReference.CreateFromImage(a2.EmitToArray());
1646var oldRef = oldMetadata.GetReference();
1733var refLib = ((MetadataImageReference)lib.EmitToImageReference()).WithEmbedInteropTypes(true);
1763var assemblyRef = assemblyMetadata.GetReference();
2328new TestMetadataReferenceResolver(assemblyNames: new Dictionary<string, PortableExecutableReference>()
2330{ "a", (PortableExecutableReference)aRef.WithProperties(MetadataReferenceProperties.Assembly.WithRecursiveAliases(true)) }
2357new TestMetadataReferenceResolver(assemblyNames: new Dictionary<string, PortableExecutableReference>()
2359{ "a", (PortableExecutableReference)aRef.WithProperties(MetadataReferenceProperties.Assembly) }
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests (2)
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (1)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (9)
Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler (7)
Microsoft.CodeAnalysis.ExpressionEvaluator.FunctionResolver.UnitTests (3)
Microsoft.CodeAnalysis.Features (48)
AddImport\AbstractAddImportFeatureService.cs (21)
31: IAddImportFeatureService, IEqualityComparer<PortableExecutableReference>
35/// Cache of information about whether a <see cref="PortableExecutableReference"/> is likely contained within a
38private static readonly ConditionalWeakTable<PortableExecutableReference, StrongBox<bool>> s_isInPackagesDirectory = new();
146var referenceToCompilation = new ConcurrentDictionary<PortableExecutableReference, Compilation>(concurrencyLevel: 2, capacity: project.Solution.Projects.Sum(p => p.MetadataReferences.Count));
171ConcurrentDictionary<PortableExecutableReference, Compilation> referenceToCompilation,
260ConcurrentDictionary<PortableExecutableReference, Compilation> referenceToCompilation,
272var seenReferences = new HashSet<PortableExecutableReference>(comparer: this);
273seenReferences.AddAll(project.MetadataReferences.OfType<PortableExecutableReference>());
321private static ImmutableArray<(Project, PortableExecutableReference)> GetUnreferencedMetadataReferences(
322Project project, HashSet<PortableExecutableReference> seenReferences)
324using var _ = ArrayBuilder<(Project, PortableExecutableReference)>.GetInstance(out var result);
336if (reference is PortableExecutableReference peReference &&
399private static bool IsInPackagesDirectory(PortableExecutableReference reference)
405static bool ComputeIsInPackagesDirectory(PortableExecutableReference reference)
413static bool ContainsPathComponent(PortableExecutableReference reference, string pathComponent)
428private static Compilation CreateCompilation(Project project, PortableExecutableReference reference)
435bool IEqualityComparer<PortableExecutableReference>.Equals(PortableExecutableReference? x, PortableExecutableReference? y)
448int IEqualityComparer<PortableExecutableReference>.GetHashCode(PortableExecutableReference obj)
Microsoft.CodeAnalysis.InteractiveHost (3)
Microsoft.CodeAnalysis.LanguageServer (3)
Microsoft.CodeAnalysis.Rebuild.UnitTests (4)
Microsoft.CodeAnalysis.Scripting (17)
Hosting\Resolvers\RuntimeMetadataReferenceResolver.cs (14)
41private readonly Func<string, MetadataReferenceProperties, PortableExecutableReference> _createFromFileFunc;
55Func<string, MetadataReferenceProperties, PortableExecutableReference>? createFromFileFunc = null)
72Func<string, MetadataReferenceProperties, PortableExecutableReference>? createFromFileFunc = null)
86Func<string, MetadataReferenceProperties, PortableExecutableReference>? createFromfileFunc = null)
97public override PortableExecutableReference? ResolveMissingAssembly(MetadataReference definition, AssemblyIdentity referenceIdentity)
112var result = ResolveTrustedPlatformAssembly(referenceIdentity.Name, s_resolvedMissingAssemblyReferenceProperties);
120var definitionDirectory = PathUtilities.GetDirectoryName((definition as PortableExecutableReference)?.FilePath);
137private PortableExecutableReference CreateFromFile(string filePath, MetadataReferenceProperties properties) =>
140private PortableExecutableReference CreateResolvedMissingReference(string fullPath) =>
143public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string? baseFilePath, MetadataReferenceProperties properties)
158var result = ResolveTrustedPlatformAssembly(PathUtilities.GetFileName(reference, includeExtension: false), properties);
187var result = ResolveTrustedPlatformAssembly(identity.Name, properties);
195return ImmutableArray<PortableExecutableReference>.Empty;
198private PortableExecutableReference? ResolveTrustedPlatformAssembly(string name, MetadataReferenceProperties properties)
Microsoft.CodeAnalysis.Scripting.TestUtilities (4)
Microsoft.CodeAnalysis.Scripting.UnitTests (3)
Microsoft.CodeAnalysis.Test.Utilities (501)
Mocks\TestMetadataReferenceResolver.cs (11)
18private readonly Dictionary<string, PortableExecutableReference> _assemblyNames;
19private readonly Dictionary<string, PortableExecutableReference> _files;
23Dictionary<string, PortableExecutableReference> assemblyNames = null,
24Dictionary<string, PortableExecutableReference> files = null)
27_assemblyNames = assemblyNames ?? new Dictionary<string, PortableExecutableReference>();
28_files = files ?? new Dictionary<string, PortableExecutableReference>();
31public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
33Dictionary<string, PortableExecutableReference> map;
42return ImmutableArray<PortableExecutableReference>.Empty;
53return map.TryGetValue(reference, out var result) ? ImmutableArray.Create(result) : ImmutableArray<PortableExecutableReference>.Empty;
Microsoft.CodeAnalysis.UnitTests (33)
MetadataReferences\MetadataReferenceTests.cs (31)
98var r = MetadataReference.CreateFromStream(stream);
118var r = MetadataReference.CreateFromStream(new MemoryStream(TestResources.General.C1, writable: false));
129var r = MetadataReference.CreateFromStream(
145var r = MetadataReference.CreateFromStream(
163var r = MetadataReference.CreateFromFile(file.Path,
187var r = MetadataReference.CreateFromFile(file.Path, MetadataReferenceProperties.Module);
208var r = (PortableExecutableReference)MetadataReference.CreateFromAssemblyInternal(assembly);
225var r = (PortableExecutableReference)MetadataReference.CreateFromAssemblyInternal(assembly, new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray.Create("a", "b"), embedInteropTypes: true), documentation: doc);
257var r = module.GetReference(filePath: @"c:\temp", display: "hello", documentation: doc);
266var r1 = r.WithAliases(default(ImmutableArray<string>));
270var r2 = r.WithEmbedInteropTypes(false);
274var r3 = r.WithProperties(new MetadataReferenceProperties(MetadataImageKind.Module));
277var r4 = r.WithProperties(new MetadataReferenceProperties(MetadataImageKind.Assembly));
290var r = assembly.GetReference(
305var r2 = r.WithEmbedInteropTypes(true);
309var r3 = r.WithAliases(ImmutableArray.Create("b", "c"));
317var r4 = r.WithEmbedInteropTypes(false);
325var r5 = r.WithProperties(new MetadataReferenceProperties(MetadataImageKind.Module));
330var r6 = r.WithProperties(new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray.Create("x"), embedInteropTypes: true));
404var mmr1 = module.GetReference();
409var r = module.GetReference(filePath: path);
419var mmr1 = assembly.GetReference();
424var r = assembly.GetReference(filePath: path);
487protected override PortableExecutableReference WithPropertiesImpl(MetadataReferenceProperties properties)
515protected override PortableExecutableReference WithPropertiesImpl(MetadataReferenceProperties properties)
529var i1 = AssemblyMetadata.CreateFromImage(Net461.Resources.mscorlib).GetReference(display: "i1");
530var i2 = AssemblyMetadata.CreateFromImage(Net461.Resources.mscorlib).GetReference(display: "i2");
568var corlib = AssemblyMetadata.CreateFromImage(Net461.Resources.mscorlib).
584var r = MetadataReference.CreateFromStream(new MemoryStream(TestResources.SymbolsTests.Metadata.InvalidPublicKey, writable: false));
Microsoft.CodeAnalysis.VisualBasic (3)
Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests (3)
Microsoft.CodeAnalysis.VisualBasic.Scripting.UnitTests (2)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (1)
Microsoft.CodeAnalysis.Workspaces (75)
FindSymbols\SymbolTree\SymbolTreeInfo_Metadata.cs (17)
32/// cref="PortableExecutableReference"/>. Generating symbol trees for metadata can be expensive (in large
40private static readonly ConditionalWeakTable<PortableExecutableReference, AsyncLazy<SymbolTreeInfo>> s_peReferenceToInfo = new();
45/// cref="PortableExecutableReference"/>s, while having different checksums. For example, if the aliases of a
46/// <see cref="PortableExecutableReference"/> are changed (see <see
47/// cref="PortableExecutableReference.WithAliases(IEnumerable{string})"/>, then it will have a different
70public static MetadataId? GetMetadataIdNoThrow(PortableExecutableReference reference)
82private static Metadata? GetMetadataNoThrow(PortableExecutableReference reference)
95/// Produces a <see cref="SymbolTreeInfo"/> for a given <see cref="PortableExecutableReference"/>.
104PortableExecutableReference reference,
117/// Produces a <see cref="SymbolTreeInfo"/> for a given <see cref="PortableExecutableReference"/>.
127PortableExecutableReference reference,
146PortableExecutableReference reference,
171PortableExecutableReference reference,
201public static async Task<SymbolTreeInfo?> TryGetCachedInfoForMetadataReferenceIgnoreChecksumAsync(PortableExecutableReference reference, CancellationToken cancellationToken)
211SolutionServices services, PortableExecutableReference reference, CancellationToken cancellationToken)
228private static string GetMetadataKeySuffix(PortableExecutableReference reference)
238PortableExecutableReference reference,
Microsoft.CodeAnalysis.Workspaces.MSBuild (3)
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (19)
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (1)
Microsoft.CodeAnalysis.Workspaces.UnitTests (15)
Microsoft.Maui.Controls.SourceGen (2)
Microsoft.VisualStudio.LanguageServices (19)
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (3)
Microsoft.VisualStudio.LanguageServices.Test.Utilities2 (1)
Microsoft.VisualStudio.LanguageServices.UnitTests (1)
SemanticSearch.BuildTask (1)
SemanticSearch.BuildTask.UnitTests (3)
StackDepthTest (1)
VBCSCompiler (11)
src\Compilers\Server\VBCSCompiler\CSharpCompilerServer.cs (4)
17private readonly Func<string, MetadataReferenceProperties, PortableExecutableReference> _metadataProvider;
19internal CSharpCompilerServer(Func<string, MetadataReferenceProperties, PortableExecutableReference> metadataProvider, string[] args, BuildPaths buildPaths, string? libDirectory, IAnalyzerAssemblyLoader analyzerLoader, GeneratorDriverCache driverCache)
24internal CSharpCompilerServer(Func<string, MetadataReferenceProperties, PortableExecutableReference> metadataProvider, string? responseFile, string[] args, BuildPaths buildPaths, string? libDirectory, IAnalyzerAssemblyLoader analyzerLoader, GeneratorDriverCache driverCache)
30internal override Func<string, MetadataReferenceProperties, PortableExecutableReference> GetMetadataProvider()
src\Compilers\Server\VBCSCompiler\VisualBasicCompilerServer.cs (4)
19private readonly Func<string, MetadataReferenceProperties, PortableExecutableReference> _metadataProvider;
21internal VisualBasicCompilerServer(Func<string, MetadataReferenceProperties, PortableExecutableReference> metadataProvider, string[] args, BuildPaths buildPaths, string? libDirectory, IAnalyzerAssemblyLoader analyzerLoader, GeneratorDriverCache driverCache)
26internal VisualBasicCompilerServer(Func<string, MetadataReferenceProperties, PortableExecutableReference> metadataProvider, string? responseFile, string[] args, BuildPaths buildPaths, string? libDirectory, IAnalyzerAssemblyLoader analyzerLoader, GeneratorDriverCache driverCache)
32internal override Func<string, MetadataReferenceProperties, PortableExecutableReference> GetMetadataProvider()