49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
using System.Collections.Immutable;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
|
|
|
internal sealed class HostObjectModelBinder : Binder
|
|
{
|
|
public HostObjectModelBinder(Binder next)
|
|
: base(next)
|
|
{
|
|
}
|
|
|
|
private TypeSymbol GetHostObjectType()
|
|
{
|
|
return base.Compilation.GetHostObjectTypeSymbol();
|
|
}
|
|
|
|
internal override void LookupSymbolsInSingleBinder(LookupResult result, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
|
|
{
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000e: Invalid comparison between Unknown and I4
|
|
TypeSymbol hostObjectType = GetHostObjectType();
|
|
if ((int)hostObjectType.Kind == 4)
|
|
{
|
|
result.SetFrom((DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_NameNotInContextPossibleMissingReference, new object[2]
|
|
{
|
|
name,
|
|
((MissingMetadataTypeSymbol)hostObjectType).ContainingAssembly.Identity
|
|
}, ImmutableArray<Symbol>.Empty, ImmutableArray<Location>.Empty));
|
|
}
|
|
else
|
|
{
|
|
LookupMembersInternal(result, hostObjectType, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteInfo);
|
|
}
|
|
}
|
|
|
|
internal override void AddLookupSymbolsInfoInSingleBinder(LookupSymbolsInfo result, LookupOptions options, Binder originalBinder)
|
|
{
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000e: Invalid comparison between Unknown and I4
|
|
TypeSymbol hostObjectType = GetHostObjectType();
|
|
if ((int)hostObjectType.Kind != 4)
|
|
{
|
|
AddMemberLookupSymbolsInfo(result, hostObjectType, options, originalBinder);
|
|
}
|
|
}
|
|
}
|