72 lines
2.7 KiB
C#
72 lines
2.7 KiB
C#
using System.Reflection;
|
|
using Microsoft.CodeAnalysis.CSharp.Emit;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
internal sealed class SynthesizedEventAccessorSymbol : SourceEventAccessorSymbol
|
|
{
|
|
private readonly object _methodChecksLockObject = new object();
|
|
|
|
public override bool IsImplicitlyDeclared => true;
|
|
|
|
internal override bool GenerateDebugInfo => false;
|
|
|
|
protected override SourceMemberMethodSymbol BoundAttributesSource
|
|
{
|
|
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 != 5)
|
|
{
|
|
return null;
|
|
}
|
|
return (SourceMemberMethodSymbol)base.AssociatedEvent.RemoveMethod;
|
|
}
|
|
}
|
|
|
|
protected override IAttributeTargetSymbol AttributeOwner => base.AssociatedEvent;
|
|
|
|
protected override object MethodChecksLockObject => _methodChecksLockObject;
|
|
|
|
internal override MethodImplAttributes ImplementationAttributes
|
|
{
|
|
get
|
|
{
|
|
MethodImplAttributes methodImplAttributes = base.ImplementationAttributes;
|
|
if (!IsAbstract && !base.AssociatedEvent.IsWindowsRuntimeEvent && !ContainingType.IsStructType() && (object)DeclaringCompilation.GetWellKnownTypeMember((WellKnownMember)141) == null)
|
|
{
|
|
methodImplAttributes |= MethodImplAttributes.Synchronized;
|
|
}
|
|
return methodImplAttributes;
|
|
}
|
|
}
|
|
|
|
internal SynthesizedEventAccessorSymbol(SourceEventSymbol @event, bool isAdder, bool isExpressionBodied, EventSymbol explicitlyImplementedEventOpt = null, string aliasQualifierOpt = null)
|
|
: base(@event, null, @event.Location, explicitlyImplementedEventOpt, aliasQualifierOpt, isAdder, isIterator: false, isNullableAnalysisEnabled: false, isExpressionBodied)
|
|
{
|
|
}
|
|
|
|
internal override OneOrMany<SyntaxList<AttributeListSyntax>> GetAttributeDeclarations()
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
return OneOrMany.Create<SyntaxList<AttributeListSyntax>>(base.AssociatedEvent.AttributeDeclarationSyntaxList);
|
|
}
|
|
|
|
internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<SynthesizedAttributeData> attributes)
|
|
{
|
|
base.AddSynthesizedAttributes(moduleBuilder, ref attributes);
|
|
CSharpCompilation declaringCompilation = DeclaringCompilation;
|
|
Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.TrySynthesizeAttribute((WellKnownMember)112));
|
|
}
|
|
|
|
internal override ExecutableCodeBinder TryGetBodyBinder(BinderFactory binderFactoryOpt = null, bool ignoreAccessibility = false)
|
|
{
|
|
return TryGetBodyBinderFromSyntax(binderFactoryOpt, ignoreAccessibility);
|
|
}
|
|
}
|