52 lines
2.0 KiB
C#
52 lines
2.0 KiB
C#
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
internal sealed class SynthesizedExplicitImplementationForwardingMethod : SynthesizedImplementationMethod
|
|
{
|
|
private readonly MethodSymbol _implementingMethod;
|
|
|
|
internal override bool SynthesizesLoweredBoundBody => true;
|
|
|
|
public MethodSymbol ImplementingMethod => _implementingMethod;
|
|
|
|
public override MethodKind MethodKind
|
|
{
|
|
get
|
|
{
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
|
if (!_implementingMethod.IsAccessor())
|
|
{
|
|
return (MethodKind)8;
|
|
}
|
|
return _implementingMethod.MethodKind;
|
|
}
|
|
}
|
|
|
|
public override bool IsStatic => _implementingMethod.IsStatic;
|
|
|
|
internal override bool HasSpecialName => false;
|
|
|
|
internal sealed override bool HasRuntimeSpecialName => false;
|
|
|
|
internal override void GenerateMethodBody(TypeCompilationState compilationState, BindingDiagnosticBag diagnostics)
|
|
{
|
|
SyntheticBoundNodeFactory syntheticBoundNodeFactory = new SyntheticBoundNodeFactory(this, (SyntaxNode)(object)this.GetNonNullSyntaxNode(), compilationState, diagnostics);
|
|
syntheticBoundNodeFactory.CurrentFunction = OriginalDefinition;
|
|
try
|
|
{
|
|
MethodSymbol methodToInvoke = (IsGenericMethod ? ImplementingMethod.Construct(ImmutableArrayExtensions.Cast<TypeParameterSymbol, TypeSymbol>(TypeParameters)) : ImplementingMethod);
|
|
syntheticBoundNodeFactory.CloseMethod(MethodBodySynthesizer.ConstructSingleInvocationMethodBody(syntheticBoundNodeFactory, methodToInvoke, useBaseReference: false));
|
|
}
|
|
catch (SyntheticBoundNodeFactory.MissingPredefinedMember missingPredefinedMember)
|
|
{
|
|
((BindingDiagnosticBag)diagnostics).Add(missingPredefinedMember.Diagnostic);
|
|
syntheticBoundNodeFactory.CloseMethod(syntheticBoundNodeFactory.ThrowNull());
|
|
}
|
|
}
|
|
|
|
public SynthesizedExplicitImplementationForwardingMethod(MethodSymbol interfaceMethod, MethodSymbol implementingMethod, NamedTypeSymbol implementingType)
|
|
: base(interfaceMethod, implementingType, null, generateDebugInfo: false)
|
|
{
|
|
_implementingMethod = implementingMethod;
|
|
}
|
|
}
|