Files
2026-08-27 10:56:38 -06:00

67 lines
2.7 KiB
C#

using System.Collections.Immutable;
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 SynthesizedAccessorValueParameterSymbol : SourceComplexParameterSymbolBase
{
internal override FlowAnalysisAnnotations FlowAnalysisAnnotations
{
get
{
FlowAnalysisAnnotations flowAnalysisAnnotations = FlowAnalysisAnnotations.None;
if (ContainingSymbol is SourcePropertyAccessorSymbol { AssociatedSymbol: SourcePropertySymbolBase associatedSymbol })
{
if (associatedSymbol.HasDisallowNull)
{
flowAnalysisAnnotations |= FlowAnalysisAnnotations.DisallowNull;
}
if (associatedSymbol.HasAllowNull)
{
flowAnalysisAnnotations |= FlowAnalysisAnnotations.AllowNull;
}
}
return flowAnalysisAnnotations;
}
}
internal override ImmutableHashSet<string> NotNullIfParameterNotNull => ImmutableHashSet<string>.Empty;
public override ImmutableArray<CustomModifier> RefCustomModifiers => ImmutableArray<CustomModifier>.Empty;
public override bool IsImplicitlyDeclared => true;
protected override IAttributeTargetSymbol AttributeOwner => (SourceMemberMethodSymbol)ContainingSymbol;
public SynthesizedAccessorValueParameterSymbol(SourceMemberMethodSymbol accessor, TypeWithAnnotations paramType, int ordinal)
: base(accessor, ordinal, paramType, (RefKind)0, "value", accessor.TryGetFirstLocation(), null, isParams: false, isExtensionMethodThis: false, (ScopedKind)0)
{
}
internal override OneOrMany<SyntaxList<AttributeListSyntax>> GetAttributeDeclarations()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return ((SourceMemberMethodSymbol)ContainingSymbol).GetAttributeDeclarations();
}
internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<SynthesizedAttributeData> attributes)
{
base.AddSynthesizedAttributes(moduleBuilder, ref attributes);
if (ContainingSymbol is SourcePropertyAccessorSymbol { AssociatedSymbol: SourcePropertySymbolBase associatedSymbol })
{
FlowAnalysisAnnotations flowAnalysisAnnotations = FlowAnalysisAnnotations;
if ((flowAnalysisAnnotations & FlowAnalysisAnnotations.DisallowNull) != FlowAnalysisAnnotations.None)
{
Symbol.AddSynthesizedAttribute(ref attributes, new SynthesizedAttributeData(associatedSymbol.DisallowNullAttributeIfExists));
}
if ((flowAnalysisAnnotations & FlowAnalysisAnnotations.AllowNull) != FlowAnalysisAnnotations.None)
{
Symbol.AddSynthesizedAttribute(ref attributes, new SynthesizedAttributeData(associatedSymbol.AllowNullAttributeIfExists));
}
}
}
}