public MetadataLoadContext(Compilation compilation) { _compilation = compilation; var assemblies = compilation.References .OfType <PortableExecutableReference>() .ToDictionary(r => AssemblyName.GetAssemblyName(r.FilePath), r => (IAssemblySymbol)compilation.GetAssemblyOrModuleSymbol(r)); foreach (var item in assemblies) { // REVIEW: We need to figure out full framework // _assemblies[item.Key.FullName] = item.Value; _assemblies[item.Key.Name] = item.Value; } CoreAssembly = new AssemblyWrapper(compilation.GetTypeByMetadataName("System.Object").ContainingAssembly, this); MainAssembly = new AssemblyWrapper(compilation.Assembly, this); }
public MetadataLoadContext(Compilation compilation) { _compilation = compilation; Dictionary <AssemblyName, IAssemblySymbol> assemblies = compilation.References .OfType <PortableExecutableReference>() .ToDictionary( r => string.IsNullOrWhiteSpace(r.FilePath) ? new AssemblyName(r.Display) : AssemblyName.GetAssemblyName(r.FilePath), r => (IAssemblySymbol)compilation.GetAssemblyOrModuleSymbol(r) !); foreach (var item in assemblies) { string key = item.Key.Name; _assemblies[key] = item.Value !; if (_collectionsAssemblySymbol == null && key == "System.Collections") { _collectionsAssemblySymbol = item.Value !; } } CoreAssembly = new AssemblyWrapper(compilation.GetTypeByMetadataName("System.Object") !.ContainingAssembly, this); MainAssembly = new AssemblyWrapper(compilation.Assembly, this); }