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

133 lines
4.1 KiB
C#

using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
internal sealed class ThisParameterSymbol : ParameterSymbol
{
internal const string SymbolName = "this";
private readonly MethodSymbol? _containingMethod;
private readonly TypeSymbol _containingType;
public override string Name => "this";
public override bool IsDiscard => false;
public override TypeWithAnnotations TypeWithAnnotations => TypeWithAnnotations.Create(_containingType, NullableAnnotation.NotAnnotated);
public override RefKind RefKind
{
get
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Invalid comparison between Unknown and I4
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Invalid comparison between Unknown and I4
NamedTypeSymbol containingType = ContainingType;
if ((object)containingType != null && (int)containingType.TypeKind == 10)
{
MethodSymbol? containingMethod = _containingMethod;
if ((object)containingMethod != null && (int)containingMethod.MethodKind == 1)
{
return (RefKind)2;
}
MethodSymbol? containingMethod2 = _containingMethod;
if ((object)containingMethod2 != null && containingMethod2.IsEffectivelyReadOnly)
{
return (RefKind)3;
}
return (RefKind)1;
}
return (RefKind)0;
}
}
public override ImmutableArray<Location> Locations
{
get
{
if ((object)_containingMethod == null)
{
return ImmutableArray<Location>.Empty;
}
return _containingMethod.Locations;
}
}
public override ImmutableArray<SyntaxReference> DeclaringSyntaxReferences => ImmutableArray<SyntaxReference>.Empty;
public override Symbol ContainingSymbol => (Symbol)(((object)_containingMethod) ?? ((object)_containingType));
internal override ConstantValue? ExplicitDefaultConstantValue => null;
internal override bool IsMetadataOptional => false;
public override bool IsParams => false;
internal override bool IsIDispatchConstant => false;
internal override bool IsIUnknownConstant => false;
internal override bool IsCallerFilePath => false;
internal override bool IsCallerLineNumber => false;
internal override bool IsCallerMemberName => false;
internal override int CallerArgumentExpressionParameterIndex => -1;
internal override FlowAnalysisAnnotations FlowAnalysisAnnotations => FlowAnalysisAnnotations.None;
internal override ImmutableHashSet<string> NotNullIfParameterNotNull => ImmutableHashSet<string>.Empty;
public override int Ordinal => -1;
public override ImmutableArray<CustomModifier> RefCustomModifiers => ImmutableArray<CustomModifier>.Empty;
public override bool IsThis => true;
public override bool IsImplicitlyDeclared => true;
internal override bool IsMetadataIn => false;
internal override bool IsMetadataOut => false;
internal override MarshalPseudoCustomAttributeData? MarshallingInformation => null;
internal override ImmutableArray<int> InterpolatedStringHandlerArgumentIndexes => ImmutableArray<int>.Empty;
internal override bool HasInterpolatedStringHandlerArgumentError => false;
internal override ScopedKind EffectiveScope
{
get
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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)
ScopedKind val = (ScopedKind)(_containingType.IsStructType() ? 1 : 0);
if ((int)val != 0 && HasUnscopedRefAttribute)
{
return (ScopedKind)0;
}
return val;
}
}
internal override bool HasUnscopedRefAttribute => _containingMethod.HasUnscopedRefAttributeOnMethodOrProperty();
internal sealed override bool UseUpdatedEscapeRules => _containingMethod?.UseUpdatedEscapeRules ?? _containingType.ContainingModule.UseUpdatedEscapeRules;
internal ThisParameterSymbol(MethodSymbol forMethod)
: this(forMethod, forMethod.ContainingType)
{
}
internal ThisParameterSymbol(MethodSymbol? forMethod, TypeSymbol containingType)
{
_containingMethod = forMethod;
_containingType = containingType;
}
}