1121 lines
39 KiB
C#
1121 lines
39 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Immutable;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using Microsoft.Cci;
|
|
using Microsoft.CodeAnalysis.CSharp.Emit;
|
|
using Microsoft.CodeAnalysis.CSharp.Emit.NoPia;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel;
|
|
using Microsoft.CodeAnalysis.Emit;
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
|
using Microsoft.CodeAnalysis.Symbols;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
internal abstract class MethodSymbol : Symbol, ITypeMemberReference, IReference, INamedEntity, IMethodReference, ISignature, IGenericMethodInstanceReference, ISpecializedMethodReference, ITypeDefinitionMember, IDefinition, IMethodDefinition, IMethodSymbolInternal, ISymbolInternal
|
|
{
|
|
internal const MethodSymbol None = null;
|
|
|
|
private ParameterSignature _lazyParameterSignature;
|
|
|
|
IGenericMethodInstanceReference IMethodReference.AsGenericMethodInstanceReference
|
|
{
|
|
get
|
|
{
|
|
if (!AdaptedMethodSymbol.IsDefinition && AdaptedMethodSymbol.IsGenericMethod)
|
|
{
|
|
return (IGenericMethodInstanceReference)(object)this;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
ISpecializedMethodReference IMethodReference.AsSpecializedMethodReference
|
|
{
|
|
get
|
|
{
|
|
if (!AdaptedMethodSymbol.IsDefinition && (!AdaptedMethodSymbol.IsGenericMethod || PEModuleBuilder.IsGenericType(AdaptedMethodSymbol.ContainingType)))
|
|
{
|
|
return (ISpecializedMethodReference)(object)this;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
string INamedEntity.Name => AdaptedMethodSymbol.MetadataName;
|
|
|
|
bool IMethodReference.AcceptsExtraArguments => AdaptedMethodSymbol.IsVararg;
|
|
|
|
ushort IMethodReference.GenericParameterCount => (ushort)AdaptedMethodSymbol.Arity;
|
|
|
|
bool IMethodReference.IsGeneric => AdaptedMethodSymbol.IsGenericMethod;
|
|
|
|
ushort ISignature.ParameterCount => (ushort)AdaptedMethodSymbol.ParameterCount;
|
|
|
|
ImmutableArray<IParameterTypeInformation> IMethodReference.ExtraParameters => ImmutableArray<IParameterTypeInformation>.Empty;
|
|
|
|
CallingConvention ISignature.CallingConvention => AdaptedMethodSymbol.CallingConvention;
|
|
|
|
ImmutableArray<ICustomModifier> ISignature.ReturnValueCustomModifiers => ImmutableArray<ICustomModifier>.CastUp<CustomModifier>(AdaptedMethodSymbol.ReturnTypeWithAnnotations.CustomModifiers);
|
|
|
|
ImmutableArray<ICustomModifier> ISignature.RefCustomModifiers => ImmutableArray<ICustomModifier>.CastUp<CustomModifier>(AdaptedMethodSymbol.RefCustomModifiers);
|
|
|
|
bool ISignature.ReturnValueIsByRef => AdaptedMethodSymbol.RefKind.IsManagedReference();
|
|
|
|
IMethodReference ISpecializedMethodReference.UnspecializedVersion => (IMethodReference)(object)AdaptedMethodSymbol.OriginalDefinition.GetCciAdapter();
|
|
|
|
ITypeDefinition ITypeDefinitionMember.ContainingTypeDefinition
|
|
{
|
|
get
|
|
{
|
|
if (AdaptedMethodSymbol.OriginalDefinition is SynthesizedGlobalMethodSymbol synthesizedGlobalMethodSymbol)
|
|
{
|
|
return (ITypeDefinition)(object)synthesizedGlobalMethodSymbol.ContainingPrivateImplementationDetailsType;
|
|
}
|
|
return (ITypeDefinition)(object)AdaptedMethodSymbol.ContainingType.GetCciAdapter();
|
|
}
|
|
}
|
|
|
|
TypeMemberVisibility ITypeDefinitionMember.Visibility => PEModuleBuilder.MemberVisibility(AdaptedMethodSymbol);
|
|
|
|
IEnumerable<IGenericMethodParameter> IMethodDefinition.GenericParameters
|
|
{
|
|
get
|
|
{
|
|
ImmutableArray<TypeParameterSymbol>.Enumerator enumerator = AdaptedMethodSymbol.TypeParameters.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
TypeParameterSymbol current = enumerator.Current;
|
|
yield return (IGenericMethodParameter)(object)current.GetCciAdapter();
|
|
}
|
|
}
|
|
}
|
|
|
|
bool IMethodDefinition.HasDeclarativeSecurity => AdaptedMethodSymbol.HasDeclarativeSecurity;
|
|
|
|
IEnumerable<SecurityAttribute> IMethodDefinition.SecurityAttributes => AdaptedMethodSymbol.GetSecurityInformation();
|
|
|
|
bool IMethodDefinition.IsAbstract => AdaptedMethodSymbol.IsAbstract;
|
|
|
|
bool IMethodDefinition.IsAccessCheckedOnOverride => AdaptedMethodSymbol.IsAccessCheckedOnOverride;
|
|
|
|
bool IMethodDefinition.IsConstructor => (int)AdaptedMethodSymbol.MethodKind == 1;
|
|
|
|
bool IMethodDefinition.IsExternal => AdaptedMethodSymbol.IsExternal;
|
|
|
|
bool IMethodDefinition.IsHiddenBySignature => !AdaptedMethodSymbol.HidesBaseMethodsByName;
|
|
|
|
bool IMethodDefinition.IsNewSlot => AdaptedMethodSymbol.IsMetadataNewSlot();
|
|
|
|
bool IMethodDefinition.IsPlatformInvoke => AdaptedMethodSymbol.GetDllImportData() != null;
|
|
|
|
IPlatformInvokeInformation IMethodDefinition.PlatformInvokeData => (IPlatformInvokeInformation)(object)AdaptedMethodSymbol.GetDllImportData();
|
|
|
|
bool IMethodDefinition.IsRuntimeSpecial => AdaptedMethodSymbol.HasRuntimeSpecialName;
|
|
|
|
bool IMethodDefinition.IsSealed => AdaptedMethodSymbol.IsMetadataFinal;
|
|
|
|
bool IMethodDefinition.IsSpecialName => AdaptedMethodSymbol.HasSpecialName;
|
|
|
|
bool IMethodDefinition.IsStatic => AdaptedMethodSymbol.IsStatic;
|
|
|
|
bool IMethodDefinition.IsVirtual => AdaptedMethodSymbol.IsMetadataVirtual();
|
|
|
|
ImmutableArray<IParameterDefinition> IMethodDefinition.Parameters => EnumerateDefinitionParameters();
|
|
|
|
bool IMethodDefinition.RequiresSecurityObject => AdaptedMethodSymbol.RequiresSecurityObject;
|
|
|
|
bool IMethodDefinition.ReturnValueIsMarshalledExplicitly => AdaptedMethodSymbol.ReturnValueIsMarshalledExplicitly;
|
|
|
|
IMarshallingInformation IMethodDefinition.ReturnValueMarshallingInformation => (IMarshallingInformation)(object)AdaptedMethodSymbol.ReturnValueMarshallingInformation;
|
|
|
|
ImmutableArray<byte> IMethodDefinition.ReturnValueMarshallingDescriptor => AdaptedMethodSymbol.ReturnValueMarshallingDescriptor;
|
|
|
|
INamespace IMethodDefinition.ContainingNamespace => (INamespace)(object)AdaptedMethodSymbol.ContainingNamespace.GetCciAdapter();
|
|
|
|
internal MethodSymbol AdaptedMethodSymbol => this;
|
|
|
|
internal virtual bool IsAccessCheckedOnOverride
|
|
{
|
|
get
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0009: Invalid comparison between Unknown and I4
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000d: Invalid comparison between Unknown and I4
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0011: Invalid comparison between Unknown and I4
|
|
Accessibility declaredAccessibility = DeclaredAccessibility;
|
|
if (((int)declaredAccessibility == 1 || (int)declaredAccessibility == 2 || (int)declaredAccessibility == 4) && IsMetadataVirtual())
|
|
{
|
|
return !IsMetadataFinal;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal virtual bool IsExternal
|
|
{
|
|
get
|
|
{
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001c: Invalid comparison between Unknown and I4
|
|
if (!IsExtern)
|
|
{
|
|
if ((object)ContainingType != null)
|
|
{
|
|
return (int)ContainingType.TypeKind == 3;
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
internal virtual bool HasRuntimeSpecialName
|
|
{
|
|
get
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Invalid comparison between Unknown and I4
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0011: Invalid comparison between Unknown and I4
|
|
if ((int)MethodKind != 1)
|
|
{
|
|
return (int)MethodKind == 14;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
internal virtual bool IsMetadataFinal
|
|
{
|
|
get
|
|
{
|
|
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0030: Invalid comparison between Unknown and I4
|
|
if (!IsSealed)
|
|
{
|
|
if (IsMetadataVirtual())
|
|
{
|
|
if (!IsVirtual && !IsOverride && !IsAbstract)
|
|
{
|
|
return (int)MethodKind != 4;
|
|
}
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
internal virtual bool ReturnValueIsMarshalledExplicitly => ReturnValueMarshallingInformation != null;
|
|
|
|
internal virtual ImmutableArray<byte> ReturnValueMarshallingDescriptor => default(ImmutableArray<byte>);
|
|
|
|
public new virtual MethodSymbol OriginalDefinition => this;
|
|
|
|
protected sealed override Symbol OriginalSymbolDefinition => OriginalDefinition;
|
|
|
|
public abstract MethodKind MethodKind { get; }
|
|
|
|
public abstract int Arity { get; }
|
|
|
|
public virtual bool IsGenericMethod => Arity != 0;
|
|
|
|
public virtual bool RequiresInstanceReceiver => !IsStatic;
|
|
|
|
internal virtual bool IsDirectlyExcludedFromCodeCoverage => false;
|
|
|
|
internal virtual ImmutableArray<string> NotNullMembers => ImmutableArray<string>.Empty;
|
|
|
|
internal virtual ImmutableArray<string> NotNullWhenTrueMembers => ImmutableArray<string>.Empty;
|
|
|
|
internal virtual ImmutableArray<string> NotNullWhenFalseMembers => ImmutableArray<string>.Empty;
|
|
|
|
public abstract bool IsExtensionMethod { get; }
|
|
|
|
internal abstract bool HasSpecialName { get; }
|
|
|
|
internal abstract MethodImplAttributes ImplementationAttributes { get; }
|
|
|
|
internal abstract bool HasDeclarativeSecurity { get; }
|
|
|
|
internal abstract MarshalPseudoCustomAttributeData ReturnValueMarshallingInformation { get; }
|
|
|
|
internal abstract bool RequiresSecurityObject { get; }
|
|
|
|
public abstract bool HidesBaseMethodsByName { get; }
|
|
|
|
public abstract bool IsVararg { get; }
|
|
|
|
public virtual bool IsCheckedBuiltin => false;
|
|
|
|
public abstract bool ReturnsVoid { get; }
|
|
|
|
public abstract bool IsAsync { get; }
|
|
|
|
public bool ReturnsByRef => (int)RefKind == 1;
|
|
|
|
public bool ReturnsByRefReadonly => (int)RefKind == 3;
|
|
|
|
public abstract RefKind RefKind { get; }
|
|
|
|
public abstract TypeWithAnnotations ReturnTypeWithAnnotations { get; }
|
|
|
|
public TypeSymbol ReturnType => ReturnTypeWithAnnotations.Type;
|
|
|
|
public abstract FlowAnalysisAnnotations ReturnTypeFlowAnalysisAnnotations { get; }
|
|
|
|
public abstract ImmutableHashSet<string> ReturnNotNullIfParameterNotNull { get; }
|
|
|
|
public abstract FlowAnalysisAnnotations FlowAnalysisAnnotations { get; }
|
|
|
|
public abstract ImmutableArray<TypeWithAnnotations> TypeArgumentsWithAnnotations { get; }
|
|
|
|
public abstract ImmutableArray<TypeParameterSymbol> TypeParameters { get; }
|
|
|
|
internal ParameterSymbol ThisParameter
|
|
{
|
|
get
|
|
{
|
|
if (!TryGetThisParameter(out var thisParameter))
|
|
{
|
|
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/MethodSymbol.cs", 282);
|
|
}
|
|
return thisParameter;
|
|
}
|
|
}
|
|
|
|
internal virtual int ParameterCount => Parameters.Length;
|
|
|
|
public abstract ImmutableArray<ParameterSymbol> Parameters { get; }
|
|
|
|
public virtual MethodSymbol ConstructedFrom => this;
|
|
|
|
internal virtual bool IsExplicitInterfaceImplementation => ExplicitInterfaceImplementations.Any();
|
|
|
|
internal abstract bool IsDeclaredReadOnly { get; }
|
|
|
|
internal abstract bool IsInitOnly { get; }
|
|
|
|
internal virtual bool IsEffectivelyReadOnly
|
|
{
|
|
get
|
|
{
|
|
if (!IsDeclaredReadOnly)
|
|
{
|
|
NamedTypeSymbol containingType = ContainingType;
|
|
if ((object)containingType == null || !containingType.IsReadOnly)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return IsValidReadOnlyTarget;
|
|
}
|
|
}
|
|
|
|
protected bool IsValidReadOnlyTarget
|
|
{
|
|
get
|
|
{
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001c: Invalid comparison between Unknown and I4
|
|
if (!IsStatic && ContainingType.IsStructType() && (int)MethodKind != 1)
|
|
{
|
|
return !IsInitOnly;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public abstract ImmutableArray<MethodSymbol> ExplicitInterfaceImplementations { get; }
|
|
|
|
public abstract ImmutableArray<CustomModifier> RefCustomModifiers { get; }
|
|
|
|
public abstract Symbol AssociatedSymbol { get; }
|
|
|
|
public MethodSymbol OverriddenMethod
|
|
{
|
|
get
|
|
{
|
|
if (IsOverride && (object)ConstructedFrom == this)
|
|
{
|
|
if (base.IsDefinition)
|
|
{
|
|
return (MethodSymbol)OverriddenOrHiddenMembers.GetOverriddenMember();
|
|
}
|
|
return (MethodSymbol)OverriddenOrHiddenMembersResult.GetOverriddenMember(this, OriginalDefinition.OverriddenMethod);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public bool IsConditional
|
|
{
|
|
get
|
|
{
|
|
if (GetAppliedConditionalSymbols().Any())
|
|
{
|
|
return true;
|
|
}
|
|
if (IsOverride)
|
|
{
|
|
MethodSymbol overriddenMethod = OverriddenMethod;
|
|
if ((object)overriddenMethod != null)
|
|
{
|
|
return overriddenMethod.IsConditional;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal bool HasSetsRequiredMembers
|
|
{
|
|
get
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Invalid comparison between Unknown and I4
|
|
if ((int)MethodKind == 1)
|
|
{
|
|
return HasSetsRequiredMembersImpl;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
protected abstract bool HasSetsRequiredMembersImpl { get; }
|
|
|
|
internal abstract bool HasUnscopedRefAttribute { get; }
|
|
|
|
internal abstract bool UseUpdatedEscapeRules { get; }
|
|
|
|
internal virtual OverriddenOrHiddenMembersResult OverriddenOrHiddenMembers => this.MakeOverriddenOrHiddenMembers();
|
|
|
|
public sealed override SymbolKind Kind => (SymbolKind)9;
|
|
|
|
internal bool IsScriptConstructor
|
|
{
|
|
get
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Invalid comparison between Unknown and I4
|
|
if ((int)MethodKind == 1)
|
|
{
|
|
return ContainingType.IsScriptClass;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal virtual bool IsScriptInitializer => false;
|
|
|
|
internal bool IsImplicitConstructor
|
|
{
|
|
get
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Invalid comparison between Unknown and I4
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0011: Invalid comparison between Unknown and I4
|
|
if ((int)MethodKind == 1 || (int)MethodKind == 14)
|
|
{
|
|
return IsImplicitlyDeclared;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal bool IsImplicitInstanceConstructor
|
|
{
|
|
get
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Invalid comparison between Unknown and I4
|
|
if ((int)MethodKind == 1)
|
|
{
|
|
return IsImplicitlyDeclared;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal bool IsSubmissionConstructor
|
|
{
|
|
get
|
|
{
|
|
if (IsScriptConstructor)
|
|
{
|
|
return ContainingAssembly.IsInteractive;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal bool IsSubmissionInitializer
|
|
{
|
|
get
|
|
{
|
|
if (IsScriptInitializer)
|
|
{
|
|
return ContainingAssembly.IsInteractive;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal bool IsEntryPointCandidate
|
|
{
|
|
get
|
|
{
|
|
if (this.IsPartialDefinition() && (object)PartialImplementationPart == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (IsStatic && !IsAbstract && !IsVirtual)
|
|
{
|
|
return Name == "Main";
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal virtual MethodSymbol CallsiteReducedFromMethod => null;
|
|
|
|
public virtual MethodSymbol PartialImplementationPart => null;
|
|
|
|
public virtual MethodSymbol PartialDefinitionPart => null;
|
|
|
|
public virtual MethodSymbol ReducedFrom => null;
|
|
|
|
public virtual TypeSymbol ReceiverType => ContainingType;
|
|
|
|
internal ImmutableArray<TypeWithAnnotations> ParameterTypesWithAnnotations
|
|
{
|
|
get
|
|
{
|
|
ParameterSignature.PopulateParameterSignature(Parameters, ref _lazyParameterSignature);
|
|
return _lazyParameterSignature.parameterTypesWithAnnotations;
|
|
}
|
|
}
|
|
|
|
internal ImmutableArray<RefKind> ParameterRefKinds
|
|
{
|
|
get
|
|
{
|
|
ParameterSignature.PopulateParameterSignature(Parameters, ref _lazyParameterSignature);
|
|
return _lazyParameterSignature.parameterRefKinds;
|
|
}
|
|
}
|
|
|
|
internal abstract CallingConvention CallingConvention { get; }
|
|
|
|
internal virtual ImmutableArray<NamedTypeSymbol> UnmanagedCallingConventionTypes => ImmutableArray<NamedTypeSymbol>.Empty;
|
|
|
|
internal virtual TypeMap TypeSubstitution => null;
|
|
|
|
public sealed override bool HasUnsupportedMetadata
|
|
{
|
|
get
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
DiagnosticInfo diagnosticInfo = GetUseSiteInfo().DiagnosticInfo;
|
|
bool flag = diagnosticInfo != null;
|
|
if (flag)
|
|
{
|
|
int code = diagnosticInfo.Code;
|
|
bool flag2 = ((code == 570 || code == 9041) ? true : false);
|
|
flag = flag2;
|
|
}
|
|
return flag;
|
|
}
|
|
}
|
|
|
|
internal virtual bool IsIterator => false;
|
|
|
|
internal virtual TypeWithAnnotations IteratorElementTypeWithAnnotations => default(TypeWithAnnotations);
|
|
|
|
internal virtual bool SynthesizesLoweredBoundBody => false;
|
|
|
|
internal abstract bool GenerateDebugInfo { get; }
|
|
|
|
internal virtual NullableAnnotation ReceiverNullableAnnotation
|
|
{
|
|
get
|
|
{
|
|
if (RequiresInstanceReceiver)
|
|
{
|
|
return (NullableAnnotation)1;
|
|
}
|
|
return (NullableAnnotation)0;
|
|
}
|
|
}
|
|
|
|
public abstract bool AreLocalsZeroed { get; }
|
|
|
|
bool IMethodSymbolInternal.IsIterator => IsIterator;
|
|
|
|
IDefinition IReference.AsDefinition(EmitContext context)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return (IDefinition)(object)ResolvedMethodImpl(context);
|
|
}
|
|
|
|
ITypeReference ITypeMemberReference.GetContainingType(EmitContext context)
|
|
{
|
|
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
|
|
if (AdaptedMethodSymbol.OriginalDefinition is SynthesizedGlobalMethodSymbol synthesizedGlobalMethodSymbol)
|
|
{
|
|
return (ITypeReference)(object)synthesizedGlobalMethodSymbol.ContainingPrivateImplementationDetailsType;
|
|
}
|
|
NamedTypeSymbol containingType = AdaptedMethodSymbol.ContainingType;
|
|
return (ITypeReference)(object)((PEModuleBuilder)(object)context.Module).Translate(containingType, (SyntaxNode)(object)(CSharpSyntaxNode)(object)((EmitContext)(ref context)).SyntaxNode, context.Diagnostics, fromImplements: false, AdaptedMethodSymbol.IsDefinition);
|
|
}
|
|
|
|
void IReference.Dispatch(MetadataVisitor visitor)
|
|
{
|
|
if (!AdaptedMethodSymbol.IsDefinition)
|
|
{
|
|
if (AdaptedMethodSymbol.IsGenericMethod)
|
|
{
|
|
visitor.Visit((IGenericMethodInstanceReference)(object)this);
|
|
}
|
|
else
|
|
{
|
|
visitor.Visit((IMethodReference)(object)this);
|
|
}
|
|
return;
|
|
}
|
|
PEModuleBuilder pEModuleBuilder = (PEModuleBuilder)(object)visitor.Context.Module;
|
|
if (AdaptedMethodSymbol.ContainingModule == ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)pEModuleBuilder).SourceModule)
|
|
{
|
|
visitor.Visit((IMethodDefinition)(object)this);
|
|
}
|
|
else
|
|
{
|
|
visitor.Visit((IMethodReference)(object)this);
|
|
}
|
|
}
|
|
|
|
IMethodDefinition IMethodReference.GetResolvedMethod(EmitContext context)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return ResolvedMethodImpl(context);
|
|
}
|
|
|
|
private IMethodDefinition ResolvedMethodImpl(EmitContext context)
|
|
{
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
|
PEModuleBuilder pEModuleBuilder = (PEModuleBuilder)(object)context.Module;
|
|
if (AdaptedMethodSymbol.IsDefinition && AdaptedMethodSymbol.ContainingModule == ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)pEModuleBuilder).SourceModule)
|
|
{
|
|
return (IMethodDefinition)(object)this;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
ImmutableArray<IParameterTypeInformation> ISignature.GetParameters(EmitContext context)
|
|
{
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
|
PEModuleBuilder pEModuleBuilder = (PEModuleBuilder)(object)context.Module;
|
|
if (AdaptedMethodSymbol.IsDefinition && AdaptedMethodSymbol.ContainingModule == ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)pEModuleBuilder).SourceModule)
|
|
{
|
|
return StaticCast<IParameterTypeInformation>.From<IParameterDefinition>(EnumerateDefinitionParameters());
|
|
}
|
|
return pEModuleBuilder.Translate(AdaptedMethodSymbol.Parameters);
|
|
}
|
|
|
|
private ImmutableArray<IParameterDefinition> EnumerateDefinitionParameters()
|
|
{
|
|
return StaticCast<IParameterDefinition>.From<ParameterSymbol>(AdaptedMethodSymbol.Parameters);
|
|
}
|
|
|
|
ITypeReference ISignature.GetType(EmitContext context)
|
|
{
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
|
|
return ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)(PEModuleBuilder)(object)context.Module).Translate(AdaptedMethodSymbol.ReturnType, (SyntaxNode)(object)(CSharpSyntaxNode)(object)((EmitContext)(ref context)).SyntaxNode, context.Diagnostics);
|
|
}
|
|
|
|
IEnumerable<ITypeReference> IGenericMethodInstanceReference.GetGenericArguments(EmitContext context)
|
|
{
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
|
|
PEModuleBuilder moduleBeingBuilt = (PEModuleBuilder)(object)context.Module;
|
|
ImmutableArray<TypeWithAnnotations>.Enumerator enumerator = AdaptedMethodSymbol.TypeArgumentsWithAnnotations.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
yield return ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)moduleBeingBuilt).Translate(enumerator.Current.Type, (SyntaxNode)(object)(CSharpSyntaxNode)(object)((EmitContext)(ref context)).SyntaxNode, context.Diagnostics);
|
|
}
|
|
}
|
|
|
|
IMethodReference IGenericMethodInstanceReference.GetGenericMethod(EmitContext context)
|
|
{
|
|
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
|
|
if (!PEModuleBuilder.IsGenericType(AdaptedMethodSymbol.ContainingType))
|
|
{
|
|
return ((PEModuleBuilder)(object)context.Module).Translate(AdaptedMethodSymbol.OriginalDefinition, (SyntaxNode)(object)(CSharpSyntaxNode)(object)((EmitContext)(ref context)).SyntaxNode, context.Diagnostics, null, needDeclaration: true);
|
|
}
|
|
return (IMethodReference)(object)new SpecializedMethodReference(AdaptedMethodSymbol.ConstructedFrom);
|
|
}
|
|
|
|
IMethodBody IMethodDefinition.GetBody(EmitContext context)
|
|
{
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
|
return ((CommonPEModuleBuilder)(PEModuleBuilder)(object)context.Module).GetMethodBody((IMethodSymbolInternal)(object)AdaptedMethodSymbol);
|
|
}
|
|
|
|
MethodImplAttributes IMethodDefinition.GetImplementationAttributes(EmitContext context)
|
|
{
|
|
return AdaptedMethodSymbol.ImplementationAttributes;
|
|
}
|
|
|
|
IEnumerable<ICustomAttribute> IMethodDefinition.GetReturnValueAttributes(EmitContext context)
|
|
{
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
ImmutableArray<CSharpAttributeData> returnTypeAttributes = AdaptedMethodSymbol.GetReturnTypeAttributes();
|
|
ArrayBuilder<SynthesizedAttributeData> attributes = null;
|
|
AdaptedMethodSymbol.AddSynthesizedReturnTypeAttributes((PEModuleBuilder)(object)context.Module, ref attributes);
|
|
return (IEnumerable<ICustomAttribute>)AdaptedMethodSymbol.GetCustomAttributesToEmit(returnTypeAttributes, attributes, isReturnType: true, emittingAssemblyAttributesInNetModule: false);
|
|
}
|
|
|
|
internal new MethodSymbol GetCciAdapter()
|
|
{
|
|
return this;
|
|
}
|
|
|
|
internal abstract bool IsMetadataNewSlot(bool ignoreInterfaceImplementationChanges = false);
|
|
|
|
internal abstract bool IsMetadataVirtual(bool ignoreInterfaceImplementationChanges = false);
|
|
|
|
internal abstract UnmanagedCallersOnlyAttributeData? GetUnmanagedCallersOnlyAttributeData(bool forceComplete);
|
|
|
|
public abstract DllImportData? GetDllImportData();
|
|
|
|
internal abstract IEnumerable<SecurityAttribute> GetSecurityInformation();
|
|
|
|
internal ImmutableArray<TypeWithAnnotations> GetTypeParametersAsTypeArguments()
|
|
{
|
|
return TypeMap.TypeParametersAsTypeSymbolsWithAnnotations(TypeParameters);
|
|
}
|
|
|
|
internal virtual bool TryGetThisParameter(out ParameterSymbol thisParameter)
|
|
{
|
|
thisParameter = null;
|
|
return false;
|
|
}
|
|
|
|
public virtual ImmutableArray<CSharpAttributeData> GetReturnTypeAttributes()
|
|
{
|
|
return ImmutableArray<CSharpAttributeData>.Empty;
|
|
}
|
|
|
|
internal MethodSymbol GetLeastOverriddenMethod(NamedTypeSymbol accessingTypeOpt)
|
|
{
|
|
return GetLeastOverriddenMethodCore(accessingTypeOpt, requireSameReturnType: false);
|
|
}
|
|
|
|
private MethodSymbol GetLeastOverriddenMethodCore(NamedTypeSymbol accessingTypeOpt, bool requireSameReturnType)
|
|
{
|
|
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
|
accessingTypeOpt = accessingTypeOpt?.OriginalDefinition;
|
|
MethodSymbol methodSymbol = this;
|
|
while (methodSymbol.IsOverride && !methodSymbol.HidesBaseMethodsByName)
|
|
{
|
|
MethodSymbol overriddenMethod = methodSymbol.OverriddenMethod;
|
|
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
|
|
if ((object)overriddenMethod == null || ((object)accessingTypeOpt != null && !AccessCheck.IsSymbolAccessible(overriddenMethod, accessingTypeOpt, ref useSiteInfo)) || (requireSameReturnType && !ReturnType.Equals(overriddenMethod.ReturnType, (TypeCompareKind)63)))
|
|
{
|
|
break;
|
|
}
|
|
methodSymbol = overriddenMethod;
|
|
}
|
|
return methodSymbol;
|
|
}
|
|
|
|
internal MethodSymbol GetConstructedLeastOverriddenMethod(NamedTypeSymbol accessingTypeOpt, bool requireSameReturnType)
|
|
{
|
|
MethodSymbol leastOverriddenMethodCore = ConstructedFrom.GetLeastOverriddenMethodCore(accessingTypeOpt, requireSameReturnType);
|
|
if (!leastOverriddenMethodCore.IsGenericMethod)
|
|
{
|
|
return leastOverriddenMethodCore;
|
|
}
|
|
return leastOverriddenMethodCore.Construct(TypeArgumentsWithAnnotations);
|
|
}
|
|
|
|
internal virtual bool CallsAreOmitted(SyntaxTree syntaxTree)
|
|
{
|
|
if (syntaxTree != null)
|
|
{
|
|
return CallsAreConditionallyOmitted(syntaxTree);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool CallsAreConditionallyOmitted(SyntaxTree syntaxTree)
|
|
{
|
|
if (IsConditional)
|
|
{
|
|
ImmutableArray<string> appliedConditionalSymbols = GetAppliedConditionalSymbols();
|
|
if (syntaxTree.IsAnyPreprocessorSymbolDefined(appliedConditionalSymbols))
|
|
{
|
|
return false;
|
|
}
|
|
if (IsOverride)
|
|
{
|
|
MethodSymbol overriddenMethod = OverriddenMethod;
|
|
if ((object)overriddenMethod != null && overriddenMethod.IsConditional)
|
|
{
|
|
return overriddenMethod.CallsAreConditionallyOmitted(syntaxTree);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
internal abstract ImmutableArray<string> GetAppliedConditionalSymbols();
|
|
|
|
internal static bool CanOverrideOrHide(MethodKind kind)
|
|
{
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004e: Expected I4, but got Unknown
|
|
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
|
|
switch ((int)kind)
|
|
{
|
|
case 0:
|
|
case 1:
|
|
case 4:
|
|
case 8:
|
|
case 13:
|
|
case 14:
|
|
return false;
|
|
case 2:
|
|
case 3:
|
|
case 5:
|
|
case 7:
|
|
case 9:
|
|
case 10:
|
|
case 11:
|
|
case 12:
|
|
case 17:
|
|
return true;
|
|
default:
|
|
throw ExceptionUtilities.UnexpectedValue((object)kind);
|
|
}
|
|
}
|
|
|
|
internal override TResult Accept<TArgument, TResult>(CSharpSymbolVisitor<TArgument, TResult> visitor, TArgument argument)
|
|
{
|
|
return visitor.VisitMethod(this, argument);
|
|
}
|
|
|
|
public override void Accept(CSharpSymbolVisitor visitor)
|
|
{
|
|
visitor.VisitMethod(this);
|
|
}
|
|
|
|
public override TResult Accept<TResult>(CSharpSymbolVisitor<TResult> visitor)
|
|
{
|
|
return visitor.VisitMethod(this);
|
|
}
|
|
|
|
public MethodSymbol ReduceExtensionMethod(TypeSymbol receiverType, CSharpCompilation compilation)
|
|
{
|
|
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001e: Invalid comparison between Unknown and I4
|
|
if ((object)receiverType == null)
|
|
{
|
|
throw new ArgumentNullException("receiverType");
|
|
}
|
|
if (!IsExtensionMethod || (int)MethodKind == 13 || receiverType.IsVoidType())
|
|
{
|
|
return null;
|
|
}
|
|
return ReducedExtensionMethodSymbol.Create(this, receiverType, compilation);
|
|
}
|
|
|
|
public MethodSymbol ReduceExtensionMethod()
|
|
{
|
|
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0010: Invalid comparison between Unknown and I4
|
|
if (!IsExtensionMethod || (int)MethodKind == 13)
|
|
{
|
|
return null;
|
|
}
|
|
return ReducedExtensionMethodSymbol.Create(this);
|
|
}
|
|
|
|
public virtual TypeSymbol GetTypeInferredDuringReduction(TypeParameterSymbol reducedFromTypeParameter)
|
|
{
|
|
throw new InvalidOperationException();
|
|
}
|
|
|
|
public MethodSymbol Construct(params TypeSymbol[] typeArguments)
|
|
{
|
|
return Construct(ImmutableArray.Create(typeArguments));
|
|
}
|
|
|
|
public MethodSymbol Construct(ImmutableArray<TypeSymbol> typeArguments)
|
|
{
|
|
return Construct(ImmutableArrayExtensions.SelectAsArray<TypeSymbol, TypeWithAnnotations>(typeArguments, (Func<TypeSymbol, TypeWithAnnotations>)((TypeSymbol a) => TypeWithAnnotations.Create(a))));
|
|
}
|
|
|
|
internal MethodSymbol Construct(ImmutableArray<TypeWithAnnotations> typeArguments)
|
|
{
|
|
if ((object)this != ConstructedFrom || Arity == 0)
|
|
{
|
|
throw new InvalidOperationException();
|
|
}
|
|
if (typeArguments.IsDefault)
|
|
{
|
|
throw new ArgumentNullException("typeArguments");
|
|
}
|
|
if (typeArguments.Any(NamedTypeSymbol.TypeWithAnnotationsIsNullFunction))
|
|
{
|
|
throw new ArgumentException(CSharpResources.TypeArgumentCannotBeNull, "typeArguments");
|
|
}
|
|
if (typeArguments.Length != Arity)
|
|
{
|
|
throw new ArgumentException(CSharpResources.WrongNumberOfTypeArguments, "typeArguments");
|
|
}
|
|
if (ConstructedNamedTypeSymbol.TypeParametersMatchTypeArguments(TypeParameters, typeArguments))
|
|
{
|
|
return this;
|
|
}
|
|
return new ConstructedMethodSymbol(this, typeArguments);
|
|
}
|
|
|
|
internal MethodSymbol AsMember(NamedTypeSymbol newOwner)
|
|
{
|
|
if (!newOwner.IsDefinition)
|
|
{
|
|
return new SubstitutedMethodSymbol(newOwner, this);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
internal TypeSymbol GetParameterType(int index)
|
|
{
|
|
return ParameterTypesWithAnnotations[index].Type;
|
|
}
|
|
|
|
internal override UseSiteInfo<AssemblySymbol> GetUseSiteInfo()
|
|
{
|
|
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
if (base.IsDefinition)
|
|
{
|
|
return new UseSiteInfo<AssemblySymbol>(base.PrimaryDependency);
|
|
}
|
|
return OriginalDefinition.GetUseSiteInfo();
|
|
}
|
|
|
|
internal bool CalculateUseSiteDiagnostic(ref UseSiteInfo<AssemblySymbol> result)
|
|
{
|
|
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
|
|
if (DeriveUseSiteInfoFromType(ref result, ReturnTypeWithAnnotations, IsInitOnly ? AllowedRequiredModifierType.System_Runtime_CompilerServices_IsExternalInit : AllowedRequiredModifierType.None) || DeriveUseSiteInfoFromCustomModifiers(ref result, RefCustomModifiers, AllowedRequiredModifierType.System_Runtime_InteropServices_InAttribute) || DeriveUseSiteInfoFromParameters(ref result, Parameters))
|
|
{
|
|
return true;
|
|
}
|
|
ModuleSymbol containingModule = ContainingModule;
|
|
if ((object)containingModule != null && containingModule.HasUnifiedReferences)
|
|
{
|
|
HashSet<TypeSymbol> checkedTypes = null;
|
|
DiagnosticInfo result2 = result.DiagnosticInfo;
|
|
if (ReturnTypeWithAnnotations.GetUnificationUseSiteDiagnosticRecursive(ref result2, this, ref checkedTypes) || Symbol.GetUnificationUseSiteDiagnosticRecursive(ref result2, RefCustomModifiers, this, ref checkedTypes) || Symbol.GetUnificationUseSiteDiagnosticRecursive(ref result2, Parameters, this, ref checkedTypes) || Symbol.GetUnificationUseSiteDiagnosticRecursive(ref result2, TypeParameters, this, ref checkedTypes))
|
|
{
|
|
result = result.AdjustDiagnosticInfo(result2);
|
|
return true;
|
|
}
|
|
result = result.AdjustDiagnosticInfo(result2);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
internal static (bool IsCallConvs, ImmutableHashSet<INamedTypeSymbolInternal>? CallConvs) TryDecodeUnmanagedCallersOnlyCallConvsField(string key, TypedConstant value, bool isField, Location? location, BindingDiagnosticBag? diagnostics)
|
|
{
|
|
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
|
|
ImmutableHashSet<INamedTypeSymbolInternal> item = null;
|
|
if (!UnmanagedCallersOnlyAttributeData.IsCallConvsTypedConstant(key, isField, ref value))
|
|
{
|
|
return (IsCallConvs: false, CallConvs: item);
|
|
}
|
|
if (((TypedConstant)(ref value)).Values.IsDefaultOrEmpty)
|
|
{
|
|
item = ImmutableHashSet<INamedTypeSymbolInternal>.Empty;
|
|
return (IsCallConvs: true, CallConvs: item);
|
|
}
|
|
PooledHashSet<INamedTypeSymbolInternal> instance = PooledHashSet<INamedTypeSymbolInternal>.GetInstance();
|
|
ImmutableArray<TypedConstant>.Enumerator enumerator = ((TypedConstant)(ref value)).Values.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
TypedConstant current = enumerator.Current;
|
|
if (!(((TypedConstant)(ref current)).ValueInternal is NamedTypeSymbol namedTypeSymbol) || !FunctionPointerTypeSymbol.IsCallingConventionModifier(namedTypeSymbol))
|
|
{
|
|
diagnostics?.Add(ErrorCode.ERR_InvalidUnmanagedCallersOnlyCallConv, location, ((TypedConstant)(ref current)).ValueInternal ?? "null");
|
|
}
|
|
else
|
|
{
|
|
((HashSet<INamedTypeSymbolInternal>)(object)instance).Add((INamedTypeSymbolInternal)(object)namedTypeSymbol);
|
|
}
|
|
}
|
|
item = ((IEnumerable<INamedTypeSymbolInternal>)instance).ToImmutableHashSet();
|
|
instance.Free();
|
|
return (IsCallConvs: true, CallConvs: item);
|
|
}
|
|
|
|
internal bool CheckAndReportValidUnmanagedCallersOnlyTarget(SyntaxNode? node, BindingDiagnosticBag? diagnostics)
|
|
{
|
|
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0027: Invalid comparison between Unknown and I4
|
|
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002c: Invalid comparison between Unknown and I4
|
|
bool flag = !IsStatic || IsAbstract || IsVirtual;
|
|
if (!flag)
|
|
{
|
|
MethodKind methodKind = MethodKind;
|
|
bool flag2 = (((int)methodKind == 10 || (int)methodKind == 17) ? true : false);
|
|
flag = !flag2;
|
|
}
|
|
if (flag)
|
|
{
|
|
diagnostics?.Add(ErrorCode.ERR_UnmanagedCallersOnlyRequiresStatic, node.Location);
|
|
return true;
|
|
}
|
|
if (isGenericMethod(this) || ContainingType.IsGenericType)
|
|
{
|
|
diagnostics?.Add(ErrorCode.ERR_UnmanagedCallersOnlyMethodOrTypeCannotBeGeneric, node.Location);
|
|
return true;
|
|
}
|
|
return false;
|
|
static bool isGenericMethod([DisallowNull] MethodSymbol? method)
|
|
{
|
|
do
|
|
{
|
|
if (method.IsGenericMethod)
|
|
{
|
|
return true;
|
|
}
|
|
method = method.ContainingSymbol as MethodSymbol;
|
|
}
|
|
while ((object)method != null);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
protected sealed override bool IsHighestPriorityUseSiteErrorCode(int code)
|
|
{
|
|
if (code == 570 || code == 9041)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
internal virtual void GenerateMethodBody(TypeCompilationState compilationState, BindingDiagnosticBag diagnostics)
|
|
{
|
|
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/MethodSymbol.cs", 1102);
|
|
}
|
|
|
|
internal abstract int CalculateLocalSyntaxOffset(int localPosition, SyntaxTree localTree);
|
|
|
|
internal virtual void AddSynthesizedReturnTypeAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<SynthesizedAttributeData> attributes)
|
|
{
|
|
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
|
|
if (ReturnsByRefReadonly)
|
|
{
|
|
Symbol.AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeIsReadOnlyAttribute(this));
|
|
}
|
|
CSharpCompilation declaringCompilation = DeclaringCompilation;
|
|
TypeWithAnnotations returnTypeWithAnnotations = ReturnTypeWithAnnotations;
|
|
if (returnTypeWithAnnotations.Type.ContainsDynamic() && declaringCompilation.HasDynamicEmitAttributes(BindingDiagnosticBag.Discarded, Location.None))
|
|
{
|
|
Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.SynthesizeDynamicAttribute(returnTypeWithAnnotations.Type, returnTypeWithAnnotations.CustomModifiers.Length + RefCustomModifiers.Length, RefKind));
|
|
}
|
|
if (declaringCompilation.ShouldEmitNativeIntegerAttributes(returnTypeWithAnnotations.Type))
|
|
{
|
|
Symbol.AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeNativeIntegerAttribute(this, returnTypeWithAnnotations.Type));
|
|
}
|
|
if (returnTypeWithAnnotations.Type.ContainsTupleNames() && declaringCompilation.HasTupleNamesAttributes(BindingDiagnosticBag.Discarded, Location.None))
|
|
{
|
|
Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.SynthesizeTupleNamesAttribute(returnTypeWithAnnotations.Type));
|
|
}
|
|
if (declaringCompilation.ShouldEmitNullableAttributes(this))
|
|
{
|
|
Symbol.AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeNullableAttributeIfNecessary(this, GetNullableContextValue(), returnTypeWithAnnotations));
|
|
}
|
|
}
|
|
|
|
internal abstract bool IsNullableAnalysisEnabled();
|
|
|
|
int IMethodSymbolInternal.CalculateLocalSyntaxOffset(int localPosition, SyntaxTree localTree)
|
|
{
|
|
return CalculateLocalSyntaxOffset(localPosition, localTree);
|
|
}
|
|
|
|
IMethodSymbolInternal IMethodSymbolInternal.Construct(params ITypeSymbolInternal[] typeArguments)
|
|
{
|
|
return (IMethodSymbolInternal)(object)Construct((TypeSymbol[])(object)typeArguments);
|
|
}
|
|
|
|
protected sealed override ISymbol CreateISymbol()
|
|
{
|
|
return (ISymbol)(object)new Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.MethodSymbol(this);
|
|
}
|
|
|
|
public override bool Equals(Symbol other, TypeCompareKind compareKind)
|
|
{
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
|
|
if (other is SubstitutedMethodSymbol substitutedMethodSymbol)
|
|
{
|
|
return substitutedMethodSymbol.Equals(this, compareKind);
|
|
}
|
|
if (other is NativeIntegerMethodSymbol nativeIntegerMethodSymbol)
|
|
{
|
|
return nativeIntegerMethodSymbol.Equals(this, compareKind);
|
|
}
|
|
return base.Equals(other, compareKind);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
|
|
protected static void AddRequiredMembersMarkerAttributes(ref ArrayBuilder<SynthesizedAttributeData> attributes, MethodSymbol methodToAttribute)
|
|
{
|
|
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
|
|
if (methodToAttribute.ShouldCheckRequiredMembers() && methodToAttribute.ContainingType.HasAnyRequiredMembers)
|
|
{
|
|
ObsoleteAttributeData? obsoleteAttributeData = methodToAttribute.ObsoleteAttributeData;
|
|
CSharpCompilation declaringCompilation = methodToAttribute.DeclaringCompilation;
|
|
if (obsoleteAttributeData == null)
|
|
{
|
|
Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.TrySynthesizeAttribute((WellKnownMember)397, ImmutableArray.Create<TypedConstant>(new TypedConstant((ITypeSymbolInternal)(object)declaringCompilation.GetSpecialType((SpecialType)20), (TypedConstantKind)1, (object)"Constructors of types with required members are not supported in this version of your compiler."), new TypedConstant((ITypeSymbolInternal)(object)declaringCompilation.GetSpecialType((SpecialType)7), (TypedConstantKind)1, (object)true))));
|
|
}
|
|
Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.TrySynthesizeAttribute((WellKnownMember)476, ImmutableArray.Create<TypedConstant>(new TypedConstant((ITypeSymbolInternal)(object)declaringCompilation.GetSpecialType((SpecialType)20), (TypedConstantKind)1, (object)"RequiredMembers"))));
|
|
}
|
|
}
|
|
}
|