72 lines
2.4 KiB
C#
72 lines
2.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections.Immutable;
|
|
using System.Reflection;
|
|
using Microsoft.Cci;
|
|
using Microsoft.CodeAnalysis.CSharp.Emit.NoPia;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
using Microsoft.CodeAnalysis.Emit;
|
|
using Microsoft.CodeAnalysis.Symbols;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Emit;
|
|
|
|
internal sealed class ModuleReference : IModuleReference, IUnitReference, IReference, INamedEntity, IFileReference
|
|
{
|
|
private readonly PEModuleBuilder _moduleBeingBuilt;
|
|
|
|
private readonly ModuleSymbol _underlyingModule;
|
|
|
|
string INamedEntity.Name => _underlyingModule.MetadataName;
|
|
|
|
bool IFileReference.HasMetadata => true;
|
|
|
|
string IFileReference.FileName => _underlyingModule.Name;
|
|
|
|
internal ModuleReference(PEModuleBuilder moduleBeingBuilt, ModuleSymbol underlyingModule)
|
|
{
|
|
_moduleBeingBuilt = moduleBeingBuilt;
|
|
_underlyingModule = underlyingModule;
|
|
}
|
|
|
|
void IReference.Dispatch(MetadataVisitor visitor)
|
|
{
|
|
visitor.Visit((IModuleReference)(object)this);
|
|
}
|
|
|
|
ImmutableArray<byte> IFileReference.GetHashValue(AssemblyHashAlgorithm algorithmId)
|
|
{
|
|
return _underlyingModule.GetHash(algorithmId);
|
|
}
|
|
|
|
IAssemblyReference IModuleReference.GetContainingAssembly(EmitContext context)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
|
|
if (EnumBounds.IsNetModule(((CommonPEModuleBuilder)_moduleBeingBuilt).OutputKind) && (object)((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)_moduleBeingBuilt).SourceModule.ContainingAssembly == _underlyingModule.ContainingAssembly)
|
|
{
|
|
return null;
|
|
}
|
|
return ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)_moduleBeingBuilt).Translate(_underlyingModule.ContainingAssembly, context.Diagnostics);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return _underlyingModule.ToString();
|
|
}
|
|
|
|
IEnumerable<ICustomAttribute> IReference.GetAttributes(EmitContext context)
|
|
{
|
|
return SpecializedCollections.EmptyEnumerable<ICustomAttribute>();
|
|
}
|
|
|
|
IDefinition IReference.AsDefinition(EmitContext context)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
ISymbolInternal IReference.GetInternalSymbol()
|
|
{
|
|
return null;
|
|
}
|
|
}
|