using System.Collections.Immutable; using Microsoft.CodeAnalysis.CSharp.Emit; using Microsoft.CodeAnalysis.PooledObjects; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp.Symbols; internal abstract class SynthesizedParameterSymbolBase : ParameterSymbol { private readonly Symbol? _container; private readonly TypeWithAnnotations _type; private readonly int _ordinal; private readonly string _name; private readonly RefKind _refKind; private readonly ScopedKind _scope; public override TypeWithAnnotations TypeWithAnnotations => _type; public override RefKind RefKind => _refKind; public sealed override bool IsDiscard => false; public override string Name => _name; public abstract override ImmutableArray RefCustomModifiers { get; } public override int Ordinal => _ordinal; public override bool IsParams => false; internal override bool IsMetadataOptional => ExplicitDefaultConstantValue != (ConstantValue)null; public override bool IsImplicitlyDeclared => true; internal override ConstantValue? ExplicitDefaultConstantValue => null; internal virtual ConstantValue? DefaultValueFromAttributes => null; internal override bool IsIDispatchConstant { get { throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedParameterSymbol.cs", 87); } } internal override bool IsIUnknownConstant { get { throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedParameterSymbol.cs", 92); } } internal override bool IsCallerLineNumber { get { throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedParameterSymbol.cs", 97); } } internal override bool IsCallerFilePath { get { throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedParameterSymbol.cs", 102); } } internal override bool IsCallerMemberName { get { throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedParameterSymbol.cs", 107); } } internal override int CallerArgumentExpressionParameterIndex => -1; internal override FlowAnalysisAnnotations FlowAnalysisAnnotations => FlowAnalysisAnnotations.None; internal override ImmutableHashSet NotNullIfParameterNotNull => ImmutableHashSet.Empty; public override Symbol? ContainingSymbol => _container; public override ImmutableArray Locations => ImmutableArray.Empty; public override ImmutableArray DeclaringSyntaxReferences => ImmutableArray.Empty; internal override ImmutableArray InterpolatedStringHandlerArgumentIndexes => ImmutableArray.Empty; internal override bool HasInterpolatedStringHandlerArgumentError => false; internal sealed override ScopedKind EffectiveScope => _scope; internal sealed override bool UseUpdatedEscapeRules { get { Symbol container = _container; if (!(container is MethodSymbol { UseUpdatedEscapeRules: var useUpdatedEscapeRules })) { return container?.ContainingModule.UseUpdatedEscapeRules ?? false; } return useUpdatedEscapeRules; } } public SynthesizedParameterSymbolBase(Symbol? container, TypeWithAnnotations type, int ordinal, RefKind refKind, ScopedKind scope, string name) { //IL_001c: 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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) _container = container; _type = type; _ordinal = ordinal; _refKind = refKind; _scope = scope; _name = name; } internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder attributes) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Invalid comparison between Unknown and I4 //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Invalid comparison between Unknown and I4 //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Invalid comparison between Unknown and I4 //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Invalid comparison between Unknown and I4 CSharpCompilation declaringCompilation = DeclaringCompilation; TypeWithAnnotations typeWithAnnotations = TypeWithAnnotations; if (typeWithAnnotations.Type.ContainsDynamic() && declaringCompilation.HasDynamicEmitAttributes(BindingDiagnosticBag.Discarded, Location.None) && declaringCompilation.CanEmitBoolean()) { Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.SynthesizeDynamicAttribute(typeWithAnnotations.Type, typeWithAnnotations.CustomModifiers.Length + RefCustomModifiers.Length, RefKind)); } if (declaringCompilation.ShouldEmitNativeIntegerAttributes(typeWithAnnotations.Type)) { Symbol.AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeNativeIntegerAttribute(this, typeWithAnnotations.Type)); } if (ParameterHelpers.RequiresScopedRefAttribute(this)) { Symbol.AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeScopedRefAttribute(this, EffectiveScope)); } if (typeWithAnnotations.Type.ContainsTupleNames() && declaringCompilation.HasTupleNamesAttributes(BindingDiagnosticBag.Discarded, Location.None) && declaringCompilation.CanEmitSpecialType((SpecialType)20)) { Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.SynthesizeTupleNamesAttribute(typeWithAnnotations.Type)); } if (declaringCompilation.ShouldEmitNullableAttributes(this)) { Symbol.AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeNullableAttributeIfNecessary(this, GetNullableContextValue(), typeWithAnnotations)); } RefKind refKind = RefKind; if ((int)refKind != 3) { if ((int)refKind == 4) { Symbol.AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeRequiresLocationAttribute(this)); } } else { Symbol.AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeIsReadOnlyAttribute(this)); } if (HasUnscopedRefAttribute && ContainingSymbol is SynthesizedDelegateInvokeMethod) { Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.TrySynthesizeAttribute((WellKnownMember)477)); } if (IsParams && ContainingSymbol is SynthesizedDelegateInvokeMethod) { Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.TrySynthesizeAttribute((WellKnownMember)63)); } ConstantValue explicitDefaultConstantValue = ExplicitDefaultConstantValue; bool flag = explicitDefaultConstantValue != (ConstantValue)null && DefaultValueFromAttributes == (ConstantValue)null; if (flag) { Symbol containingSymbol = ContainingSymbol; bool flag2 = ((containingSymbol is SynthesizedDelegateInvokeMethod || containingSymbol is SynthesizedClosureMethod) ? true : false); flag = flag2; } if (flag) { SpecialType specialType = explicitDefaultConstantValue.SpecialType; SynthesizedAttributeData synthesizedAttributeData = (((int)specialType == 17) ? declaringCompilation.SynthesizeDecimalConstantAttribute(explicitDefaultConstantValue.DecimalValue) : (((int)specialType != 33) ? null : declaringCompilation.SynthesizeDateTimeConstantAttribute(explicitDefaultConstantValue.DateTimeValue))); SynthesizedAttributeData attribute = synthesizedAttributeData; Symbol.AddSynthesizedAttribute(ref attributes, attribute); } } }