73 lines
2.6 KiB
C#
73 lines
2.6 KiB
C#
using System.Collections.Immutable;
|
|||
|
|
using System.Globalization;
|
||
|
|
using System.Threading;
|
||
|
|
using Microsoft.CodeAnalysis.CSharp.Emit;
|
||
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
||
|
|
using Roslyn.Utilities;
|
||
|
|
|
||
|
|
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
|
||
|
|
|
||
|
|
internal abstract class SourceOrdinaryMethodSymbolBase : SourceOrdinaryMethodOrUserDefinedOperatorSymbol
|
||
|
|
{
|
||
|
|
private readonly string _name;
|
||
|
|
|
||
|
|
public abstract override ImmutableArray<TypeParameterSymbol> TypeParameters { get; }
|
||
|
|
|
||
|
|
public override string Name => _name;
|
||
|
|
|
||
|
|
protected abstract override SourceMemberMethodSymbol BoundAttributesSource { get; }
|
||
|
|
|
||
|
|
protected SourceOrdinaryMethodSymbolBase(NamedTypeSymbol containingType, string name, Location location, CSharpSyntaxNode syntax, bool isIterator, (DeclarationModifiers declarationModifiers, Flags flags) modifiersAndFlags)
|
||
|
|
: base(containingType, syntax.GetReference(), location, isIterator, modifiersAndFlags)
|
||
|
|
{
|
||
|
|
_name = name;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected sealed override void LazyAsyncMethodChecks(CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
if (!IsAsync)
|
||
|
|
{
|
||
|
|
CompleteAsyncMethodChecks(null, cancellationToken);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance();
|
||
|
|
AsyncMethodChecks(instance);
|
||
|
|
CompleteAsyncMethodChecks(instance, cancellationToken);
|
||
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void CompleteAsyncMethodChecks(BindingDiagnosticBag diagnosticsOpt, CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
if (state.NotePartComplete(CompletionPart.Members))
|
||
|
|
{
|
||
|
|
if (diagnosticsOpt != null)
|
||
|
|
{
|
||
|
|
AddDeclarationDiagnostics(diagnosticsOpt);
|
||
|
|
}
|
||
|
|
CompleteAsyncMethodChecksBetweenStartAndFinish();
|
||
|
|
state.NotePartComplete(CompletionPart.TypeMembers);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
state.SpinWaitComplete(CompletionPart.TypeMembers, cancellationToken);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
protected abstract void CompleteAsyncMethodChecksBetweenStartAndFinish();
|
||
|
|
|
||
|
|
public abstract override string GetDocumentationCommentXml(CultureInfo preferredCulture = null, bool expandIncludes = false, CancellationToken cancellationToken = default(CancellationToken));
|
||
|
|
|
||
|
|
internal abstract override OneOrMany<SyntaxList<AttributeListSyntax>> GetAttributeDeclarations();
|
||
|
|
|
||
|
|
internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<SynthesizedAttributeData> attributes)
|
||
|
|
{
|
||
|
|
base.AddSynthesizedAttributes(moduleBuilder, ref attributes);
|
||
|
|
if (IsExtensionMethod)
|
||
|
|
{
|
||
|
|
CSharpCompilation declaringCompilation = DeclaringCompilation;
|
||
|
|
Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.TrySynthesizeAttribute((WellKnownMember)111));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|