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

32911 lines
1.5 MiB
Plaintext

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using Microsoft.Cci;
using Microsoft.CodeAnalysis.CSharp.CodeGen;
using Microsoft.CodeAnalysis.CSharp.Emit.NoPia;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.RuntimeMembers;
using Microsoft.CodeAnalysis.Symbols;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp;
internal class Binder
{
internal sealed class CapturedParametersFinder : IdentifierUsedAsValueFinder
{
private readonly SynthesizedPrimaryConstructor _primaryConstructor;
private readonly HashSet<string> _namesToCheck;
private readonly ArrayBuilder<ParameterSymbol> _captured;
private CapturedParametersFinder(SynthesizedPrimaryConstructor primaryConstructor, HashSet<string> namesToCheck, ArrayBuilder<ParameterSymbol> captured)
{
_primaryConstructor = primaryConstructor;
_namesToCheck = namesToCheck;
_captured = captured;
}
public static IReadOnlyDictionary<ParameterSymbol, FieldSymbol> GetCapturedParameters(SynthesizedPrimaryConstructor primaryConstructor)
{
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
PooledHashSet<string> instance = PooledHashSet<string>.GetInstance();
addParameterNames(instance);
if (((HashSet<string>)(object)instance).Count == 0)
{
instance.Free();
return SpecializedCollections.EmptyReadOnlyDictionary<ParameterSymbol, FieldSymbol>();
}
ArrayBuilder<ParameterSymbol> instance2 = ArrayBuilder<ParameterSymbol>.GetInstance(primaryConstructor.Parameters.Length);
CapturedParametersFinder finder = new CapturedParametersFinder(primaryConstructor, (HashSet<string>)(object)instance, instance2);
SourceMemberContainerTypeSymbol containingType = primaryConstructor.ContainingType;
foreach (SourceMemberMethodSymbol methodsPossiblyCapturingPrimaryConstructorParameter in containingType.GetMethodsPossiblyCapturingPrimaryConstructorParameters())
{
getBodyBinderAndSyntax(methodsPossiblyCapturingPrimaryConstructorParameter, out var bodyBinder, out var syntaxNode);
if (bodyBinder != null && !checkParameterReferencesInMethodBody(syntaxNode, bodyBinder))
{
break;
}
}
finder.Free();
instance.Free();
if (instance2.Count == 0)
{
instance2.Free();
return SpecializedCollections.EmptyReadOnlyDictionary<ParameterSymbol, FieldSymbol>();
}
Dictionary<ParameterSymbol, FieldSymbol> dictionary = new Dictionary<ParameterSymbol, FieldSymbol>((IEqualityComparer<ParameterSymbol>?)ReferenceEqualityComparer.Instance);
Enumerator<ParameterSymbol> enumerator2 = instance2.GetEnumerator();
while (enumerator2.MoveNext())
{
ParameterSymbol current = enumerator2.Current;
dictionary.Add(current, new SynthesizedPrimaryConstructorParameterBackingFieldSymbol(current, GeneratedNames.MakePrimaryConstructorParameterFieldName(current.Name), containingType.IsReadOnly));
}
instance2.Free();
return dictionary;
void addParameterNames(PooledHashSet<string> namesToCheck)
{
ImmutableArray<ParameterSymbol>.Enumerator enumerator3 = primaryConstructor.Parameters.GetEnumerator();
while (enumerator3.MoveNext())
{
ParameterSymbol current2 = enumerator3.Current;
if (current2.Name.Length != 0)
{
((HashSet<string>)(object)namesToCheck).Add(current2.Name);
}
}
}
bool checkParameterReferencesInMethodBody(CSharpSyntaxNode cSharpSyntaxNode, Binder binder)
{
if (cSharpSyntaxNode is ConstructorDeclarationSyntax constructorDeclarationSyntax)
{
if (finder.CheckIdentifiersInNode(constructorDeclarationSyntax.Initializer, binder) && finder.CheckIdentifiersInNode(constructorDeclarationSyntax.Body, binder))
{
return finder.CheckIdentifiersInNode(constructorDeclarationSyntax.ExpressionBody, binder);
}
return false;
}
if (cSharpSyntaxNode is BaseMethodDeclarationSyntax baseMethodDeclarationSyntax)
{
if (finder.CheckIdentifiersInNode(baseMethodDeclarationSyntax.Body, binder))
{
return finder.CheckIdentifiersInNode(baseMethodDeclarationSyntax.ExpressionBody, binder);
}
return false;
}
if (cSharpSyntaxNode is AccessorDeclarationSyntax accessorDeclarationSyntax)
{
if (finder.CheckIdentifiersInNode(accessorDeclarationSyntax.Body, binder))
{
return finder.CheckIdentifiersInNode(accessorDeclarationSyntax.ExpressionBody, binder);
}
return false;
}
if (cSharpSyntaxNode is ArrowExpressionClauseSyntax node)
{
return finder.CheckIdentifiersInNode(node, binder);
}
throw ExceptionUtilities.UnexpectedValue((object)cSharpSyntaxNode);
}
static void getBodyBinderAndSyntax(SourceMemberMethodSymbol sourceMethod, out Binder? reference, out CSharpSyntaxNode? reference2)
{
reference = null;
reference2 = null;
reference = sourceMethod.TryGetBodyBinder();
if (reference != null)
{
reference2 = sourceMethod.SyntaxNode;
}
}
}
protected override bool IsIdentifierOfInterest(IdentifierNameSyntax id)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
HashSet<string> namesToCheck = _namesToCheck;
SyntaxToken identifier = id.Identifier;
return namesToCheck.Contains(((SyntaxToken)(ref identifier)).ValueText);
}
protected override bool CheckAndClearLookupResult(Binder enclosingBinder, IdentifierNameSyntax id, LookupResult lookupResult)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
if (lookupResult.IsMultiViable)
{
bool? flag = null;
bool flag2 = false;
Enumerator<Symbol> enumerator = lookupResult.Symbols.GetEnumerator();
while (enumerator.MoveNext())
{
if (!(enumerator.Current is ParameterSymbol parameterSymbol) || (object)parameterSymbol.ContainingSymbol != _primaryConstructor)
{
continue;
}
bool valueOrDefault = flag == true;
if (!flag.HasValue)
{
valueOrDefault = enclosingBinder.IsInsideNameof;
flag = valueOrDefault;
}
if (flag == true)
{
break;
}
if (lookupResult.IsSingleViable && IdentifierUsedAsValueFinder.isTypeOrValueReceiver(enclosingBinder, id, parameterSymbol.Type, out SyntaxNode memberAccessNode, out string memberName, out int targetMemberArity, out bool invoked))
{
lookupResult.Clear();
if (IdentifierUsedAsValueFinder.TreatAsInstanceMemberAccess(enclosingBinder, parameterSymbol.Type, memberAccessNode, memberName, targetMemberArity, invoked, lookupResult))
{
_captured.Add(parameterSymbol);
flag2 = true;
}
break;
}
_captured.Add(parameterSymbol);
flag2 = true;
}
if (flag2)
{
HashSet<string> namesToCheck = _namesToCheck;
SyntaxToken identifier = id.Identifier;
namesToCheck.Remove(((SyntaxToken)(ref identifier)).ValueText);
if (_namesToCheck.Count == 0)
{
return false;
}
}
}
lookupResult.Clear();
return true;
}
}
internal abstract class IdentifierUsedAsValueFinder
{
private LookupResult? _lookupResult;
protected void Free()
{
_lookupResult?.Free();
}
protected bool CheckIdentifiersInNode(CSharpSyntaxNode? node, Binder binder)
{
if (node == null)
{
return true;
}
foreach (SyntaxNode item in ((SyntaxNode)node).DescendantNodesAndSelf((Func<SyntaxNode, bool>)childrenNeedChecking, false))
{
Binder enclosingBinder = getEnclosingBinderForNode(node, binder, item);
if (!(item is AnonymousFunctionExpressionSyntax lambdaSyntax))
{
if (!(item is IdentifierNameSyntax identifierNameSyntax))
{
if (!(item is QueryExpressionSyntax query) || CheckQuery(query, enclosingBinder))
{
continue;
}
return false;
}
CSharpSyntaxNode parent = identifierNameSyntax.Parent;
if (!(parent is MemberAccessExpressionSyntax memberAccessExpressionSyntax))
{
if (!(parent is QualifiedNameSyntax qualifiedNameSyntax))
{
if (parent is AssignmentExpressionSyntax assignmentExpressionSyntax)
{
bool flag = assignmentExpressionSyntax.Left == identifierNameSyntax;
if (flag)
{
bool flag2;
switch (assignmentExpressionSyntax.Parent?.Kind())
{
case SyntaxKind.ObjectInitializerExpression:
case SyntaxKind.WithInitializerExpression:
flag2 = true;
break;
default:
flag2 = false;
break;
}
flag = flag2;
}
if (flag)
{
continue;
}
}
}
else if (qualifiedNameSyntax.Left != identifierNameSyntax)
{
continue;
}
}
else if (memberAccessExpressionSyntax.Expression != identifierNameSyntax)
{
continue;
}
if (SyntaxFacts.IsInTypeOnlyContext(identifierNameSyntax))
{
parent = identifierNameSyntax.Parent;
if (!(parent is BinaryExpressionSyntax binaryExpressionSyntax) || ((SyntaxNode)parent).RawKind != 8686 || binaryExpressionSyntax.Right != identifierNameSyntax)
{
continue;
}
}
if (IsIdentifierOfInterest(identifierNameSyntax) && !CheckIdentifier(enclosingBinder, identifierNameSyntax))
{
return false;
}
}
else if (!CheckLambda(lambdaSyntax, enclosingBinder))
{
return false;
}
}
return true;
static bool childrenNeedChecking(SyntaxNode n)
{
if (!(n is MemberBindingExpressionSyntax) && !(n is BaseExpressionColonSyntax) && !(n is NameEqualsSyntax))
{
if (n is GotoStatementSyntax)
{
if (n.RawKind == 8800)
{
goto IL_006b;
}
}
else
{
if (n is TypeParameterConstraintClauseSyntax || n is AliasQualifiedNameSyntax)
{
goto IL_006b;
}
if (n is AttributeListSyntax)
{
return false;
}
if (n is ParameterSyntax)
{
return false;
}
if (n is AnonymousFunctionExpressionSyntax || n is QueryExpressionSyntax)
{
return false;
}
if (n is ExpressionSyntax expressionSyntax && SyntaxFacts.IsInTypeOnlyContext(expressionSyntax))
{
CSharpSyntaxNode parent2 = expressionSyntax.Parent;
if (!(parent2 is BinaryExpressionSyntax binaryExpressionSyntax2) || ((SyntaxNode)parent2).RawKind != 8686 || binaryExpressionSyntax2.Right != expressionSyntax)
{
return false;
}
}
}
return true;
}
goto IL_006b;
IL_006b:
return false;
}
static Binder getEnclosingBinderForNode(CSharpSyntaxNode contextNode, Binder contextBinder, SyntaxNode targetNode)
{
while (true)
{
Binder binder2 = contextBinder.GetBinder(targetNode);
if (binder2 != null)
{
return binder2;
}
if ((object)targetNode == contextNode)
{
break;
}
targetNode = targetNode.Parent;
}
return contextBinder;
}
}
protected abstract bool IsIdentifierOfInterest(IdentifierNameSyntax id);
private bool CheckLambda(AnonymousFunctionExpressionSyntax lambdaSyntax, Binder enclosingBinder)
{
UnboundLambda unboundLambda = enclosingBinder.AnalyzeAnonymousFunction(lambdaSyntax, BindingDiagnosticBag.Discarded);
ExecutableCodeBinder executableCodeBinder = CreateLambdaBodyBinder(enclosingBinder, unboundLambda);
return CheckIdentifiersInNode(lambdaSyntax.Body, executableCodeBinder.GetBinder((SyntaxNode)(object)lambdaSyntax.Body) ?? executableCodeBinder);
}
private static ExecutableCodeBinder CreateLambdaBodyBinder(Binder enclosingBinder, UnboundLambda unboundLambda)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
unboundLambda.HasExplicitReturnType(out var refKind, out var returnType);
LambdaSymbol lambdaSymbol = new LambdaSymbol(enclosingBinder, enclosingBinder.Compilation, enclosingBinder.ContainingMemberOrLambda, unboundLambda, ImmutableArray<TypeWithAnnotations>.Empty, ImmutableArray<RefKind>.Empty, refKind, returnType);
return new ExecutableCodeBinder(unboundLambda.Syntax, lambdaSymbol, unboundLambda.GetWithParametersBinder(lambdaSymbol, enclosingBinder));
}
private bool CheckIdentifier(Binder enclosingBinder, IdentifierNameSyntax id)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (_lookupResult == null)
{
_lookupResult = LookupResult.GetInstance();
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
enclosingBinder.LookupIdentifier(_lookupResult, id, SyntaxFacts.IsInvoked(id), ref useSiteInfo);
return CheckAndClearLookupResult(enclosingBinder, id, _lookupResult);
}
protected abstract bool CheckAndClearLookupResult(Binder enclosingBinder, IdentifierNameSyntax id, LookupResult lookupResult);
protected static bool isTypeOrValueReceiver(Binder enclosingBinder, IdentifierNameSyntax id, TypeSymbol type, [NotNullWhen(true)] out SyntaxNode? memberAccessNode, [NotNullWhen(true)] out string? memberName, out int targetMemberArity, out bool invoked)
{
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
memberAccessNode = null;
memberName = null;
targetMemberArity = 0;
invoked = false;
CSharpSyntaxNode parent = id.Parent;
SyntaxToken identifier;
if (parent is MemberAccessExpressionSyntax memberAccessExpressionSyntax)
{
if (((SyntaxNode)parent).RawKind == 8689 && memberAccessExpressionSyntax.Expression == id)
{
SimpleNameSyntax simpleNameSyntax = (SimpleNameSyntax)(object)(memberAccessNode = (SyntaxNode?)(object)memberAccessExpressionSyntax.Name);
identifier = simpleNameSyntax.Identifier;
memberName = ((SyntaxToken)(ref identifier)).ValueText;
targetMemberArity = simpleNameSyntax.Arity;
invoked = SyntaxFacts.IsInvoked(memberAccessExpressionSyntax);
}
}
else if (!(parent is QualifiedNameSyntax qualifiedNameSyntax))
{
if (parent is FromClauseSyntax fromClauseSyntax && parent.Parent is QueryExpressionSyntax queryExpressionSyntax && queryExpressionSyntax.FromClause == fromClauseSyntax && fromClauseSyntax.Expression == id)
{
memberName = GetFirstInvokedMethodName(queryExpressionSyntax, out memberAccessNode);
targetMemberArity = 0;
invoked = true;
}
}
else if (qualifiedNameSyntax.Left == id)
{
SimpleNameSyntax simpleNameSyntax = (SimpleNameSyntax)(object)(memberAccessNode = (SyntaxNode?)(object)qualifiedNameSyntax.Right);
identifier = simpleNameSyntax.Identifier;
memberName = ((SyntaxToken)(ref identifier)).ValueText;
targetMemberArity = simpleNameSyntax.Arity;
invoked = false;
}
if (memberAccessNode != null)
{
return enclosingBinder.IsPotentialColorColorReceiver(id, type);
}
return false;
}
protected static bool TreatAsInstanceMemberAccess(Binder enclosingBinder, TypeSymbol type, SyntaxNode memberAccessNode, string memberName, int targetMemberArity, bool invoked, LookupResult lookupResult)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Invalid comparison between Unknown and I4
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
enclosingBinder.LookupInstanceMember(lookupResult, type, leftIsBaseReference: false, memberName, targetMemberArity, invoked, ref useSiteInfo);
bool result;
if (lookupResult.IsMultiViable)
{
ArrayBuilder<Symbol> instance = ArrayBuilder<Symbol>.GetInstance();
bool wasError;
Symbol symbolOrMethodOrPropertyGroup = enclosingBinder.GetSymbolOrMethodOrPropertyGroup(lookupResult, memberAccessNode, memberName, targetMemberArity, instance, BindingDiagnosticBag.Discarded, out wasError, null);
if ((object)symbolOrMethodOrPropertyGroup == null)
{
lookupResult.Clear();
enclosingBinder.CheckWhatCandidatesWeHave(instance, type, memberName, targetMemberArity, ref lookupResult, ref useSiteInfo, out var haveInstanceCandidates, out wasError);
result = haveInstanceCandidates;
}
else
{
result = !symbolOrMethodOrPropertyGroup.IsStatic && (int)symbolOrMethodOrPropertyGroup.Kind != 11;
}
instance.Free();
}
else
{
result = true;
}
lookupResult.Clear();
return result;
}
private bool CheckQuery(QueryExpressionSyntax query, Binder enclosingBinder)
{
if (CheckIdentifiersInNode(query.FromClause.Expression, enclosingBinder))
{
QueryTranslationState item = enclosingBinder.MakeInitialQueryTranslationState(query, BindingDiagnosticBag.Discarded).Item1;
bool flag = BindQueryInternal(enclosingBinder, item);
QueryContinuationSyntax continuation = query.Body.Continuation;
while (continuation != null && flag)
{
enclosingBinder.PrepareQueryTranslationStateForContinuation(item, continuation, BindingDiagnosticBag.Discarded);
flag = BindQueryInternal(enclosingBinder, item);
continuation = continuation.Body.Continuation;
}
item.Free();
return flag;
}
return false;
}
private bool BindQueryInternal(Binder enclosingBinder, QueryTranslationState state)
{
do
{
if (EnumerableExtensions.IsEmpty<QueryClauseSyntax>((IReadOnlyCollection<QueryClauseSyntax>)state.clauses))
{
return FinalTranslation(enclosingBinder, state);
}
}
while (ReduceQuery(enclosingBinder, state));
return false;
}
private bool FinalTranslation(Binder enclosingBinder, QueryTranslationState state)
{
switch (state.selectOrGroup.Kind())
{
case SyntaxKind.SelectClause:
{
SelectClauseSyntax obj2 = (SelectClauseSyntax)state.selectOrGroup;
RangeVariableSymbol rangeVariable2 = state.rangeVariable;
ExpressionSyntax expression = obj2.Expression;
return MakeQueryUnboundLambda(enclosingBinder, state.RangeVariableMap(), rangeVariable2, expression);
}
case SyntaxKind.GroupClause:
{
GroupClauseSyntax obj = (GroupClauseSyntax)state.selectOrGroup;
RangeVariableSymbol rangeVariable = state.rangeVariable;
ExpressionSyntax groupExpression = obj.GroupExpression;
ExpressionSyntax byExpression = obj.ByExpression;
if (MakeQueryUnboundLambda(enclosingBinder, state.RangeVariableMap(), rangeVariable, byExpression))
{
return MakeQueryUnboundLambda(enclosingBinder, state.RangeVariableMap(), rangeVariable, groupExpression);
}
return false;
}
default:
return true;
}
}
private bool ReduceQuery(Binder enclosingBinder, QueryTranslationState state)
{
QueryClauseSyntax queryClauseSyntax = state.clauses.Pop();
return queryClauseSyntax.Kind() switch
{
SyntaxKind.WhereClause => ReduceWhere(enclosingBinder, (WhereClauseSyntax)queryClauseSyntax, state),
SyntaxKind.JoinClause => ReduceJoin(enclosingBinder, (JoinClauseSyntax)queryClauseSyntax, state),
SyntaxKind.OrderByClause => ReduceOrderBy(enclosingBinder, (OrderByClauseSyntax)queryClauseSyntax, state),
SyntaxKind.FromClause => ReduceFrom(enclosingBinder, (FromClauseSyntax)queryClauseSyntax, state),
SyntaxKind.LetClause => ReduceLet(enclosingBinder, (LetClauseSyntax)queryClauseSyntax, state),
_ => throw ExceptionUtilities.UnexpectedValue((object)queryClauseSyntax.Kind()),
};
}
private bool ReduceWhere(Binder enclosingBinder, WhereClauseSyntax where, QueryTranslationState state)
{
return MakeQueryUnboundLambda(enclosingBinder, state.RangeVariableMap(), state.rangeVariable, where.Condition);
}
private bool ReduceJoin(Binder enclosingBinder, JoinClauseSyntax join, QueryTranslationState state)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
if (CheckIdentifiersInNode(join.InExpression, enclosingBinder) && MakeQueryUnboundLambda(enclosingBinder, state.RangeVariableMap(), state.rangeVariable, join.LeftExpression))
{
RangeVariableSymbol rangeVariableSymbol = state.AddRangeVariable(enclosingBinder, join.Identifier, BindingDiagnosticBag.Discarded);
if (MakeQueryUnboundLambda(enclosingBinder, QueryTranslationState.RangeVariableMap(rangeVariableSymbol), rangeVariableSymbol, join.RightExpression))
{
if (join.Into != null)
{
state.allRangeVariables[rangeVariableSymbol].Free();
state.allRangeVariables.Remove(rangeVariableSymbol);
state.AddRangeVariable(enclosingBinder, join.Into.Identifier, BindingDiagnosticBag.Discarded);
}
return true;
}
}
return false;
}
private bool ReduceOrderBy(Binder enclosingBinder, OrderByClauseSyntax orderby, QueryTranslationState state)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
Enumerator<OrderingSyntax> enumerator = orderby.Orderings.GetEnumerator();
while (enumerator.MoveNext())
{
OrderingSyntax current = enumerator.Current;
if (!MakeQueryUnboundLambda(enclosingBinder, state.RangeVariableMap(), state.rangeVariable, current.Expression))
{
return false;
}
}
return true;
}
private bool ReduceFrom(Binder enclosingBinder, FromClauseSyntax from, QueryTranslationState state)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
RangeVariableSymbol rangeVariable = state.rangeVariable;
if (MakeQueryUnboundLambda(enclosingBinder, state.RangeVariableMap(), rangeVariable, from.Expression))
{
state.AddRangeVariable(enclosingBinder, from.Identifier, BindingDiagnosticBag.Discarded);
return true;
}
return false;
}
private bool ReduceLet(Binder enclosingBinder, LetClauseSyntax let, QueryTranslationState state)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
RangeVariableSymbol rangeVariable = state.rangeVariable;
if (MakeQueryUnboundLambda(enclosingBinder, state.RangeVariableMap(), rangeVariable, let.Expression))
{
state.rangeVariable = state.TransparentRangeVariable(enclosingBinder);
state.AddTransparentIdentifier(rangeVariable.Name);
RangeVariableSymbol key = state.AddRangeVariable(enclosingBinder, let.Identifier, BindingDiagnosticBag.Discarded);
ArrayBuilder<string> obj = state.allRangeVariables[key];
SyntaxToken identifier = let.Identifier;
obj.Add(((SyntaxToken)(ref identifier)).ValueText);
return true;
}
return false;
}
private bool MakeQueryUnboundLambda(Binder enclosingBinder, RangeVariableMap qvm, RangeVariableSymbol parameter, ExpressionSyntax expression)
{
UnboundLambda unboundLambda = Binder.MakeQueryUnboundLambda((CSharpSyntaxNode)expression, new QueryUnboundLambdaState(enclosingBinder, qvm, ImmutableArray.Create(parameter), delegate
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Binder/Binder.IdentifierUsedAsValueFinder.cs", 535);
}), false);
ExecutableCodeBinder executableCodeBinder = CreateLambdaBodyBinder(enclosingBinder, unboundLambda);
return CheckIdentifiersInNode(expression, executableCodeBinder.GetRequiredBinder((SyntaxNode)(object)expression));
}
}
internal readonly struct NamespaceOrTypeOrAliasSymbolWithAnnotations
{
private readonly TypeWithAnnotations _typeWithAnnotations;
private readonly Symbol _symbol;
private readonly bool _isNullableEnabled;
internal TypeWithAnnotations TypeWithAnnotations => _typeWithAnnotations;
internal Symbol Symbol => _symbol ?? TypeWithAnnotations.Type;
internal bool IsType => !_typeWithAnnotations.IsDefault;
internal bool IsAlias
{
get
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
Symbol symbol = _symbol;
if ((object)symbol == null)
{
return false;
}
return (int)symbol.Kind == 0;
}
}
internal NamespaceOrTypeSymbol NamespaceOrTypeSymbol => Symbol as NamespaceOrTypeSymbol;
internal bool IsDefault
{
get
{
if (!_typeWithAnnotations.HasType)
{
return (object)_symbol == null;
}
return false;
}
}
internal bool IsNullableEnabled => _isNullableEnabled;
private NamespaceOrTypeOrAliasSymbolWithAnnotations(TypeWithAnnotations typeWithAnnotations)
{
_typeWithAnnotations = typeWithAnnotations;
_symbol = null;
_isNullableEnabled = false;
}
private NamespaceOrTypeOrAliasSymbolWithAnnotations(Symbol symbol, bool isNullableEnabled)
{
_typeWithAnnotations = default(TypeWithAnnotations);
_symbol = symbol;
_isNullableEnabled = isNullableEnabled;
}
internal static NamespaceOrTypeOrAliasSymbolWithAnnotations CreateUnannotated(bool isNullableEnabled, Symbol symbol)
{
if ((object)symbol == null)
{
return default(NamespaceOrTypeOrAliasSymbolWithAnnotations);
}
if (symbol is TypeSymbol typeSymbol)
{
return new NamespaceOrTypeOrAliasSymbolWithAnnotations(TypeWithAnnotations.Create(isNullableEnabled, typeSymbol));
}
return new NamespaceOrTypeOrAliasSymbolWithAnnotations(symbol, isNullableEnabled);
}
public static implicit operator NamespaceOrTypeOrAliasSymbolWithAnnotations(TypeWithAnnotations typeWithAnnotations)
{
return new NamespaceOrTypeOrAliasSymbolWithAnnotations(typeWithAnnotations);
}
}
protected enum OverflowChecks
{
Implicit,
Disabled,
Enabled
}
private class QueryTranslationState
{
public BoundExpression fromExpression;
public RangeVariableSymbol rangeVariable;
public readonly Stack<QueryClauseSyntax> clauses = new Stack<QueryClauseSyntax>();
public SelectOrGroupClauseSyntax selectOrGroup;
public readonly Dictionary<RangeVariableSymbol, ArrayBuilder<string>> allRangeVariables = new Dictionary<RangeVariableSymbol, ArrayBuilder<string>>();
private int _nextTransparentIdentifierNumber;
public static RangeVariableMap RangeVariableMap(params RangeVariableSymbol[] parameters)
{
RangeVariableMap rangeVariableMap = new RangeVariableMap();
foreach (RangeVariableSymbol key in parameters)
{
rangeVariableMap.Add(key, ImmutableArray<string>.Empty);
}
return rangeVariableMap;
}
public RangeVariableMap RangeVariableMap()
{
RangeVariableMap rangeVariableMap = new RangeVariableMap();
foreach (RangeVariableSymbol key in allRangeVariables.Keys)
{
rangeVariableMap.Add(key, allRangeVariables[key].ToImmutable());
}
return rangeVariableMap;
}
internal RangeVariableSymbol AddRangeVariable(Binder binder, SyntaxToken identifier, BindingDiagnosticBag diagnostics)
{
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
RangeVariableSymbol rangeVariableSymbol = new RangeVariableSymbol(valueText, binder.ContainingMemberOrLambda, ((SyntaxToken)(ref identifier)).GetLocation());
bool flag = false;
foreach (RangeVariableSymbol key in allRangeVariables.Keys)
{
if (key.Name == valueText)
{
diagnostics.Add(ErrorCode.ERR_QueryDuplicateRangeVariable, ((SyntaxToken)(ref identifier)).GetLocation(), valueText);
flag = true;
}
}
if (!flag && diagnostics != BindingDiagnosticBag.Discarded)
{
new LocalScopeBinder(binder).ValidateDeclarationNameConflictsInScope(rangeVariableSymbol, diagnostics);
}
allRangeVariables.Add(rangeVariableSymbol, ArrayBuilder<string>.GetInstance());
return rangeVariableSymbol;
}
internal void AddTransparentIdentifier(string name)
{
foreach (ArrayBuilder<string> value in allRangeVariables.Values)
{
value.Add(name);
}
}
internal string TransparentRangeVariableName()
{
return "<>h__TransparentIdentifier" + _nextTransparentIdentifierNumber++;
}
internal RangeVariableSymbol TransparentRangeVariable(Binder binder)
{
return new RangeVariableSymbol(TransparentRangeVariableName(), binder.ContainingMemberOrLambda, null, isTransparent: true);
}
public void Clear()
{
fromExpression = null;
rangeVariable = null;
selectOrGroup = null;
foreach (ArrayBuilder<string> value in allRangeVariables.Values)
{
value.Free();
}
allRangeVariables.Clear();
clauses.Clear();
}
public void Free()
{
Clear();
}
}
private delegate BoundBlock LambdaBodyFactory(LambdaSymbol lambdaSymbol, Binder lambdaBodyBinder, BindingDiagnosticBag diagnostics);
private sealed class QueryUnboundLambdaState : UnboundLambdaState
{
private readonly ImmutableArray<RangeVariableSymbol> _parameters;
private readonly LambdaBodyFactory _bodyFactory;
private readonly RangeVariableMap _rangeVariableMap;
public override bool HasSignature => true;
public override bool HasExplicitlyTypedParameterList => false;
public override int ParameterCount => _parameters.Length;
public override bool IsAsync => false;
public override bool IsStatic => false;
public override bool HasParamsArray => false;
public override MessageID MessageID => MessageID.IDS_FeatureQueryExpression;
public QueryUnboundLambdaState(Binder binder, RangeVariableMap rangeVariableMap, ImmutableArray<RangeVariableSymbol> parameters, LambdaBodyFactory bodyFactory, bool includeCache = true)
: base(binder, includeCache)
{
_parameters = parameters;
_rangeVariableMap = rangeVariableMap;
_bodyFactory = bodyFactory;
}
public override string ParameterName(int index)
{
return _parameters[index].Name;
}
public override bool ParameterIsDiscard(int index)
{
return false;
}
public override SyntaxList<AttributeListSyntax> ParameterAttributes(int index)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
return default(SyntaxList<AttributeListSyntax>);
}
public override bool HasExplicitReturnType(out RefKind refKind, out TypeWithAnnotations returnType)
{
refKind = (RefKind)0;
returnType = default(TypeWithAnnotations);
return false;
}
public override RefKind RefKind(int index)
{
return (RefKind)0;
}
public override ScopedKind DeclaredScope(int index)
{
return (ScopedKind)0;
}
public override Location ParameterLocation(int index)
{
return _parameters[index].TryGetFirstLocation();
}
public override ParameterSyntax ParameterSyntax(int index)
{
return null;
}
public override TypeWithAnnotations ParameterTypeWithAnnotations(int index)
{
throw new ArgumentException();
}
public override void GenerateAnonymousFunctionConversionError(BindingDiagnosticBag diagnostics, TypeSymbol targetType)
{
base.GenerateAnonymousFunctionConversionError(diagnostics, targetType);
}
public override Binder GetWithParametersBinder(LambdaSymbol lambdaSymbol, Binder binder)
{
return new WithQueryLambdaParametersBinder(lambdaSymbol, _rangeVariableMap, binder);
}
protected override UnboundLambdaState WithCachingCore(bool includeCache)
{
return new QueryUnboundLambdaState(Binder, _rangeVariableMap, _parameters, _bodyFactory, includeCache);
}
protected override BoundExpression GetLambdaExpressionBody(BoundBlock body)
{
return null;
}
protected override BoundBlock CreateBlockFromLambdaExpressionBody(Binder lambdaBodyBinder, BoundExpression expression, BindingDiagnosticBag diagnostics)
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Binder/Binder.QueryUnboundLambdaState.cs", 81);
}
protected override BoundBlock BindLambdaBodyCore(LambdaSymbol lambdaSymbol, Binder lambdaBodyBinder, BindingDiagnosticBag diagnostics)
{
return _bodyFactory(lambdaSymbol, lambdaBodyBinder, diagnostics);
}
}
private class RangeVariableMap : Dictionary<RangeVariableSymbol, ImmutableArray<string>>
{
}
[Flags]
internal enum BindValueKind : ushort
{
RValue = 4,
Assignable = 8,
RefersToLocation = 0x10,
RefAssignable = 0x20,
RValueOrMethodGroup = 5,
CompoundAssignment = 0xC,
IncrementDecrement = 0xD,
ReadonlyRef = 0x14,
AddressOf = 0x15,
FixedReceiver = 0x16,
RefOrOut = 0x1C,
RefReturn = 0x1D
}
internal enum AddressKind
{
Writeable,
Constrained,
ReadOnly,
ReadOnlyStrict
}
private sealed class WithQueryLambdaParametersBinder : WithLambdaParametersBinder
{
private readonly RangeVariableMap _rangeVariableMap;
private readonly MultiDictionary<string, RangeVariableSymbol> _parameterMap;
public WithQueryLambdaParametersBinder(LambdaSymbol lambdaSymbol, RangeVariableMap rangeVariableMap, Binder next)
: base(lambdaSymbol, next)
{
_rangeVariableMap = rangeVariableMap;
_parameterMap = new MultiDictionary<string, RangeVariableSymbol>();
foreach (RangeVariableSymbol key in rangeVariableMap.Keys)
{
_parameterMap.Add(key.Name, key);
}
}
protected override BoundExpression BindRangeVariable(SimpleNameSyntax node, RangeVariableSymbol qv, BindingDiagnosticBag diagnostics)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (_rangeVariableMap.TryGetValue(qv, out var value))
{
BoundExpression boundExpression;
if (value.IsEmpty)
{
boundExpression = new BoundParameter((SyntaxNode)(object)node, parameterMap[qv.Name].Single());
}
else
{
boundExpression = new BoundParameter((SyntaxNode)(object)node, lambdaSymbol.Parameters[0]);
for (int num = value.Length - 1; num >= 0; num--)
{
boundExpression.WasCompilerGenerated = true;
string name = value[num];
boundExpression = SelectField(node, boundExpression, name, diagnostics);
}
}
return new BoundRangeVariable((SyntaxNode)(object)node, qv, boundExpression, boundExpression.Type);
}
return base.BindRangeVariable(node, qv, diagnostics);
}
private BoundExpression SelectField(SimpleNameSyntax node, BoundExpression receiver, string name, BindingDiagnosticBag diagnostics)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol namedTypeSymbol = receiver.Type as NamedTypeSymbol;
if ((object)namedTypeSymbol == null || !namedTypeSymbol.IsAnonymousType)
{
CSDiagnosticInfo cSDiagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_UnsupportedTransparentIdentifierAccess, name, (object)new FormattedSymbol((ISymbolInternal)(object)(receiver.ExpressionSymbol ?? namedTypeSymbol), SymbolDisplayFormat.CSharpErrorMessageNoParameterNamesFormat));
TypeSymbol? type = receiver.Type;
if ((object)type == null || !type.IsErrorType())
{
Error(diagnostics, (DiagnosticInfo)(object)cSDiagnosticInfo, (SyntaxNode)(object)node);
}
return new BoundBadExpression((SyntaxNode)(object)node, LookupResultKind.Empty, ImmutableArray.Create(receiver.ExpressionSymbol), ImmutableArray.Create(BindToTypeForErrorRecovery(receiver)), new ExtendedErrorTypeSymbol(base.Compilation, "", 0, (DiagnosticInfo?)(object)cSDiagnosticInfo));
}
LookupResult instance = LookupResult.GetInstance();
LookupOptions options = LookupOptions.MustBeInstance;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupMembersWithFallback(instance, receiver.Type, name, 0, ref useSiteInfo, null, options);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
BoundExpression result = BindMemberOfType((SyntaxNode)(object)node, (SyntaxNode)(object)node, name, 0, indexed: false, receiver, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), instance, BoundMethodGroupFlags.None, diagnostics);
instance.Free();
return result;
}
internal override void LookupSymbolsInSingleBinder(LookupResult result, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
if ((options & LookupOptions.NamespaceAliasesOnly) != LookupOptions.Default)
{
return;
}
Enumerator<string, RangeVariableSymbol> enumerator = _parameterMap[name].GetEnumerator();
try
{
while (enumerator.MoveNext())
{
RangeVariableSymbol current = enumerator.Current;
result.MergeEqual(originalBinder.CheckViability(current, arity, options, null, diagnose, ref useSiteInfo));
}
}
finally
{
((IDisposable)enumerator/*cast due to constrained. prefix*/).Dispose();
}
}
internal override void AddLookupSymbolsInfoInSingleBinder(LookupSymbolsInfo result, LookupOptions options, Binder originalBinder)
{
if (!options.CanConsiderMembers())
{
return;
}
foreach (KeyValuePair<string, ValueSet<string, RangeVariableSymbol>> item in _parameterMap)
{
((AbstractLookupSymbolsInfo<Symbol>)result).AddSymbol((Symbol)null, item.Key, 0);
}
}
}
private readonly struct AttributeExpressionVisitor(Binder binder)
{
private readonly Binder _binder = binder;
public ImmutableArray<TypedConstant> VisitArguments(ImmutableArray<BoundExpression> arguments, BindingDiagnosticBag diagnostics, ref bool attrHasErrors, bool parentHasErrors = false)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
ImmutableArray<TypedConstant> result = ImmutableArray<TypedConstant>.Empty;
int length = arguments.Length;
if (length > 0)
{
ArrayBuilder<TypedConstant> instance = ArrayBuilder<TypedConstant>.GetInstance(length);
ImmutableArray<BoundExpression>.Enumerator enumerator = arguments.GetEnumerator();
while (enumerator.MoveNext())
{
BoundExpression current = enumerator.Current;
bool curArgumentHasErrors = parentHasErrors || current.HasAnyErrors;
instance.Add(VisitExpression(current, diagnostics, ref attrHasErrors, curArgumentHasErrors));
}
result = instance.ToImmutableAndFree();
}
return result;
}
public ImmutableArray<KeyValuePair<string, TypedConstant>> VisitNamedArguments(ImmutableArray<BoundAssignmentOperator> arguments, BindingDiagnosticBag diagnostics, ref bool attrHasErrors)
{
ArrayBuilder<KeyValuePair<string, TypedConstant>> val = null;
ImmutableArray<BoundAssignmentOperator>.Enumerator enumerator = arguments.GetEnumerator();
while (enumerator.MoveNext())
{
BoundAssignmentOperator current = enumerator.Current;
KeyValuePair<string, TypedConstant>? keyValuePair = VisitNamedArgument(current, diagnostics, ref attrHasErrors);
if (keyValuePair.HasValue)
{
if (val == null)
{
val = ArrayBuilder<KeyValuePair<string, TypedConstant>>.GetInstance();
}
val.Add(keyValuePair.Value);
}
}
return val?.ToImmutableAndFree() ?? ImmutableArray<KeyValuePair<string, TypedConstant>>.Empty;
}
private KeyValuePair<string, TypedConstant>? VisitNamedArgument(BoundAssignmentOperator assignment, BindingDiagnosticBag diagnostics, ref bool attrHasErrors)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
KeyValuePair<string, TypedConstant>? result = null;
switch (assignment.Left.Kind)
{
case BoundKind.FieldAccess:
{
BoundFieldAccess boundFieldAccess = (BoundFieldAccess)assignment.Left;
result = new KeyValuePair<string, TypedConstant>(boundFieldAccess.FieldSymbol.Name, VisitExpression(assignment.Right, diagnostics, ref attrHasErrors, assignment.HasAnyErrors));
break;
}
case BoundKind.PropertyAccess:
{
BoundPropertyAccess boundPropertyAccess = (BoundPropertyAccess)assignment.Left;
result = new KeyValuePair<string, TypedConstant>(boundPropertyAccess.PropertySymbol.Name, VisitExpression(assignment.Right, diagnostics, ref attrHasErrors, assignment.HasAnyErrors));
break;
}
}
return result;
}
private TypedConstant VisitExpression(BoundExpression node, BindingDiagnosticBag diagnostics, ref bool attrHasErrors, bool curArgumentHasErrors)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Invalid comparison between Unknown and I4
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
TypedConstantKind attributeParameterTypedConstantKind = node.Type.GetAttributeParameterTypedConstantKind(_binder.Compilation);
return VisitExpression(node, attributeParameterTypedConstantKind, diagnostics, ref attrHasErrors, curArgumentHasErrors || (int)attributeParameterTypedConstantKind == 0);
}
private TypedConstant VisitExpression(BoundExpression node, TypedConstantKind typedConstantKind, BindingDiagnosticBag diagnostics, ref bool attrHasErrors, bool curArgumentHasErrors)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
ConstantValue constantValueOpt = node.ConstantValueOpt;
if (constantValueOpt != (ConstantValue)null)
{
if (constantValueOpt.IsBad)
{
typedConstantKind = (TypedConstantKind)0;
}
ConstantValueUtils.CheckLangVersionForConstantValue(node, diagnostics);
return CreateTypedConstant(node, typedConstantKind, diagnostics, ref attrHasErrors, curArgumentHasErrors, constantValueOpt.Value);
}
return (TypedConstant)(node.Kind switch
{
BoundKind.Conversion => VisitConversion((BoundConversion)node, diagnostics, ref attrHasErrors, curArgumentHasErrors),
BoundKind.TypeOfOperator => VisitTypeOfExpression((BoundTypeOfOperator)node, diagnostics, ref attrHasErrors, curArgumentHasErrors),
BoundKind.ArrayCreation => VisitArrayCreation((BoundArrayCreation)node, diagnostics, ref attrHasErrors, curArgumentHasErrors),
_ => CreateTypedConstant(node, (TypedConstantKind)0, diagnostics, ref attrHasErrors, curArgumentHasErrors),
});
}
private TypedConstant VisitArrayCollectionExpression(TypeSymbol type, BoundCollectionExpression collection, BindingDiagnosticBag diagnostics, ref bool attrHasErrors, bool curArgumentHasErrors)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
TypedConstantKind attributeParameterTypedConstantKind = type.GetAttributeParameterTypedConstantKind(_binder.Compilation);
ImmutableArray<BoundExpression> elements = collection.Elements;
ArrayBuilder<TypedConstant> instance = ArrayBuilder<TypedConstant>.GetInstance(elements.Length);
ImmutableArray<BoundExpression>.Enumerator enumerator = elements.GetEnumerator();
while (enumerator.MoveNext())
{
BoundExpression current = enumerator.Current;
instance.Add(VisitCollectionExpressionElement(current, diagnostics, ref attrHasErrors, curArgumentHasErrors || current.HasAnyErrors));
}
return CreateTypedConstant(collection, attributeParameterTypedConstantKind, diagnostics, ref attrHasErrors, curArgumentHasErrors, null, instance.ToImmutableAndFree());
}
private TypedConstant VisitCollectionExpressionElement(BoundExpression node, BindingDiagnosticBag diagnostics, ref bool attrHasErrors, bool curArgumentHasErrors)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if (node is BoundCollectionExpressionSpreadElement boundCollectionExpressionSpreadElement)
{
Error(diagnostics, ErrorCode.ERR_BadAttributeArgument, SyntaxNodeOrToken.op_Implicit(node.Syntax));
attrHasErrors = true;
return new TypedConstant((ITypeSymbolInternal)(object)boundCollectionExpressionSpreadElement.Expression.Type, (TypedConstantKind)0, (object)null);
}
return VisitExpression(node, diagnostics, ref attrHasErrors, curArgumentHasErrors);
}
private TypedConstant VisitConversion(BoundConversion node, BindingDiagnosticBag diagnostics, ref bool attrHasErrors, bool curArgumentHasErrors)
{
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Invalid comparison between Unknown and I4
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Invalid comparison between Unknown and I4
TypeSymbol type = node.Type;
BoundExpression operand = node.Operand;
TypeSymbol type2 = operand.Type;
if (node.Conversion.IsCollectionExpression && node.Conversion.GetCollectionExpressionTypeKind(out TypeSymbol _) == CollectionExpressionTypeKind.Array)
{
return VisitArrayCollectionExpression(type, (BoundCollectionExpression)operand, diagnostics, ref attrHasErrors, curArgumentHasErrors);
}
if ((object)type != null && (object)type2 != null && ((int)type.SpecialType == 1 || (type2.IsArray() && type.IsArray() && (int)((ArrayTypeSymbol)type).ElementType.SpecialType == 1)))
{
TypedConstantKind attributeParameterTypedConstantKind = type2.GetAttributeParameterTypedConstantKind(_binder.Compilation);
return VisitExpression(operand, attributeParameterTypedConstantKind, diagnostics, ref attrHasErrors, curArgumentHasErrors);
}
return CreateTypedConstant(node, (TypedConstantKind)0, diagnostics, ref attrHasErrors, curArgumentHasErrors);
}
private static TypedConstant VisitTypeOfExpression(BoundTypeOfOperator node, BindingDiagnosticBag diagnostics, ref bool attrHasErrors, bool curArgumentHasErrors)
{
//IL_0084: 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_0019: Invalid comparison between Unknown and I4
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
TypeSymbol type = node.SourceType.Type;
if ((object)type != null)
{
bool flag = true;
flag = (int)type.Kind != 17 && (type.IsUnboundGenericType() || !type.ContainsTypeParameter());
if (!flag && !curArgumentHasErrors)
{
Error(diagnostics, ErrorCode.ERR_AttrArgWithTypeVars, SyntaxNodeOrToken.op_Implicit(node.Syntax), ((Symbol)type).ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat));
curArgumentHasErrors = true;
attrHasErrors = true;
}
}
return CreateTypedConstant(node, (TypedConstantKind)3, diagnostics, ref attrHasErrors, curArgumentHasErrors, node.SourceType.Type);
}
private TypedConstant VisitArrayCreation(BoundArrayCreation node, BindingDiagnosticBag diagnostics, ref bool attrHasErrors, bool curArgumentHasErrors)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
ImmutableArray<BoundExpression> bounds = node.Bounds;
int length = bounds.Length;
if (length > 1)
{
return CreateTypedConstant(node, (TypedConstantKind)0, diagnostics, ref attrHasErrors, curArgumentHasErrors);
}
TypedConstantKind attributeParameterTypedConstantKind = ((ArrayTypeSymbol)node.Type).GetAttributeParameterTypedConstantKind(_binder.Compilation);
ImmutableArray<TypedConstant> arrayValue = ((node.InitializerOpt != null) ? VisitArguments(node.InitializerOpt.Initializers, diagnostics, ref attrHasErrors, curArgumentHasErrors) : ((length == 0) ? ImmutableArray<TypedConstant>.Empty : ((!bounds[0].IsDefaultValue()) ? ImmutableArray.Create<TypedConstant>(CreateTypedConstant(node, (TypedConstantKind)0, diagnostics, ref attrHasErrors, curArgumentHasErrors)) : ImmutableArray<TypedConstant>.Empty)));
return CreateTypedConstant(node, attributeParameterTypedConstantKind, diagnostics, ref attrHasErrors, curArgumentHasErrors, null, arrayValue);
}
private static TypedConstant CreateTypedConstant(BoundExpression node, TypedConstantKind typedConstantKind, BindingDiagnosticBag diagnostics, ref bool attrHasErrors, bool curArgumentHasErrors, object? simpleValue = null, ImmutableArray<TypedConstant> arrayValue = default(ImmutableArray<TypedConstant>))
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Invalid comparison between Unknown and I4
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
TypeSymbol type = node.Type;
if ((int)typedConstantKind != 0 && type.ContainsTypeParameter())
{
typedConstantKind = (TypedConstantKind)0;
}
if ((int)typedConstantKind == 0)
{
if (!curArgumentHasErrors)
{
Error(diagnostics, ErrorCode.ERR_BadAttributeArgument, SyntaxNodeOrToken.op_Implicit(node.Syntax));
attrHasErrors = true;
}
return new TypedConstant((ITypeSymbolInternal)(object)type, (TypedConstantKind)0, (object)null);
}
if ((int)typedConstantKind == 4)
{
return new TypedConstant((ITypeSymbolInternal)(object)type, arrayValue);
}
return new TypedConstant((ITypeSymbolInternal)(object)type, typedConstantKind, simpleValue);
}
}
private readonly struct AnalyzedAttributeArguments
{
internal readonly AnalyzedArguments ConstructorArguments;
internal readonly ArrayBuilder<BoundAssignmentOperator>? NamedArguments;
internal AnalyzedAttributeArguments(AnalyzedArguments constructorArguments, ArrayBuilder<BoundAssignmentOperator>? namedArguments)
{
ConstructorArguments = constructorArguments;
NamedArguments = namedArguments;
}
}
[DebuggerDisplay("{GetDebuggerDisplay(),nq}")]
internal sealed class DeconstructionVariable
{
internal readonly BoundExpression? Single;
internal readonly ArrayBuilder<DeconstructionVariable>? NestedVariables;
internal readonly CSharpSyntaxNode Syntax;
internal DeconstructionVariable(BoundExpression variable, SyntaxNode syntax)
{
Single = variable;
NestedVariables = null;
Syntax = (CSharpSyntaxNode)(object)syntax;
}
internal DeconstructionVariable(ArrayBuilder<DeconstructionVariable> variables, SyntaxNode syntax)
{
Single = null;
NestedVariables = variables;
Syntax = (CSharpSyntaxNode)(object)syntax;
}
internal static void FreeDeconstructionVariables(ArrayBuilder<DeconstructionVariable> variables)
{
ArrayBuilderExtensions.FreeAll<DeconstructionVariable>(variables, (Func<DeconstructionVariable, ArrayBuilder<DeconstructionVariable>>)((DeconstructionVariable v) => v.NestedVariables));
}
private string GetDebuggerDisplay()
{
if (Single != null)
{
return Single.GetDebuggerDisplay();
}
return $"Nested variables ({NestedVariables.Count})";
}
}
private sealed class BinderWithContainingMemberOrLambda : Binder
{
private readonly Symbol _containingMemberOrLambda;
internal override Symbol ContainingMemberOrLambda => _containingMemberOrLambda;
internal BinderWithContainingMemberOrLambda(Binder next, Symbol containingMemberOrLambda)
: base(next)
{
_containingMemberOrLambda = containingMemberOrLambda;
}
internal BinderWithContainingMemberOrLambda(Binder next, BinderFlags flags, Symbol containingMemberOrLambda)
: base(next, flags)
{
_containingMemberOrLambda = containingMemberOrLambda;
}
}
private sealed class BinderWithConditionalReceiver : Binder
{
private readonly BoundExpression _receiverExpression;
internal override BoundExpression ConditionalReceiverExpression => _receiverExpression;
internal BinderWithConditionalReceiver(Binder next, BoundExpression receiverExpression)
: base(next)
{
_receiverExpression = receiverExpression;
}
}
internal struct ProcessedFieldInitializers
{
internal ImmutableArray<BoundInitializer> BoundInitializers { get; set; }
internal BoundStatement? LoweredInitializers { get; set; }
internal bool HasErrors { get; set; }
internal ImportChain? FirstImportChain { get; set; }
}
[Flags]
internal enum ConversionForAssignmentFlags
{
None = 0,
DefaultParameter = 1,
RefAssignment = 2,
IncrementAssignment = 4,
CompoundAssignment = 8,
PredefinedOperator = 0x10
}
private enum ConstraintContextualKeyword
{
None,
Unmanaged,
NotNull
}
private class ConsistentSymbolOrder : IComparer<Symbol>
{
public static readonly ConsistentSymbolOrder Instance = new ConsistentSymbolOrder();
public int Compare(Symbol fst, Symbol snd)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected I4, but got Unknown
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
if (snd == fst)
{
return 0;
}
if ((object)fst == null)
{
return -1;
}
if ((object)snd == null)
{
return 1;
}
if (snd.Name != fst.Name)
{
return string.CompareOrdinal(fst.Name, snd.Name);
}
if (snd.Kind != fst.Kind)
{
return fst.Kind - snd.Kind;
}
int num = ((!snd.Locations.IsDefault) ? snd.Locations.Length : 0);
int length = fst.Locations.Length;
if (num != length)
{
return num - length;
}
if (num == 0 && length == 0)
{
return Compare(fst.ContainingSymbol, snd.ContainingSymbol);
}
Location firstLocation = snd.GetFirstLocation();
Location firstLocation2 = fst.GetFirstLocation();
if (firstLocation.IsInSource != firstLocation2.IsInSource)
{
if (!firstLocation.IsInSource)
{
return -1;
}
return 1;
}
int num2 = Compare(fst.ContainingSymbol, snd.ContainingSymbol);
if (!firstLocation.IsInSource)
{
return num2;
}
if (num2 == 0 && firstLocation.SourceTree == firstLocation2.SourceTree)
{
TextSpan sourceSpan = firstLocation2.SourceSpan;
int start = ((TextSpan)(ref sourceSpan)).Start;
sourceSpan = firstLocation.SourceSpan;
return start - ((TextSpan)(ref sourceSpan)).Start;
}
return num2;
}
}
[Flags]
private enum BestSymbolLocation
{
None = 0,
FromFile = 1,
FromSourceModule = 2,
FromAddedModule = 3,
FromReferencedAssembly = 4,
FromCorLibrary = 5
}
[DebuggerDisplay("Location = {_location}, Index = {_index}")]
private readonly struct BestSymbolInfo
{
private readonly BestSymbolLocation _location;
private readonly int _index;
public int Index
{
get
{
if (!IsNone)
{
return _index;
}
return -1;
}
}
public bool IsFromSourceModule => _location == BestSymbolLocation.FromSourceModule;
public bool IsFromAddedModule => _location == BestSymbolLocation.FromAddedModule;
public bool IsFromCompilation
{
get
{
if (_location != BestSymbolLocation.FromSourceModule)
{
return _location == BestSymbolLocation.FromAddedModule;
}
return true;
}
}
public bool IsFromFile => _location == BestSymbolLocation.FromFile;
public bool IsNone => _location == BestSymbolLocation.None;
public bool IsFromCorLibrary => _location == BestSymbolLocation.FromCorLibrary;
public BestSymbolInfo(BestSymbolLocation location, int index)
{
_location = location;
_index = index;
}
public static bool Sort(ref BestSymbolInfo first, ref BestSymbolInfo second)
{
if (IsSecondLocationBetter(first._location, second._location))
{
BestSymbolInfo bestSymbolInfo = first;
first = second;
second = bestSymbolInfo;
return true;
}
return false;
}
public static bool IsSecondLocationBetter(BestSymbolLocation firstLocation, BestSymbolLocation secondLocation)
{
if (firstLocation != BestSymbolLocation.None)
{
return firstLocation > secondLocation;
}
return true;
}
}
private enum EnumeratorResult
{
Succeeded,
FailedNotReported,
FailedAndReported
}
internal readonly BinderFlags Flags;
private Conversions? _lazyConversions;
private OverloadResolution? _lazyOverloadResolution;
private const int ValueKindInsignificantBits = 2;
private const BindValueKind ValueKindSignificantBitsMask = (BindValueKind)65532;
private static readonly Func<PropertySymbol, bool> s_isIndexedPropertyWithNonOptionalArguments = delegate(PropertySymbol property)
{
if (property.IsIndexer || !property.IsIndexedProperty)
{
return false;
}
ParameterSymbol parameterSymbol = property.Parameters[0];
return !parameterSymbol.IsOptional && !parameterSymbol.IsParams;
};
private static readonly SymbolDisplayFormat s_propertyGroupFormat = new SymbolDisplayFormat((SymbolDisplayGlobalNamespaceStyle)0, (SymbolDisplayTypeQualificationStyle)0, (SymbolDisplayGenericsOptions)0, (SymbolDisplayMemberOptions)32, (SymbolDisplayDelegateStyle)0, (SymbolDisplayExtensionMethodStyle)0, (SymbolDisplayParameterOptions)0, (SymbolDisplayPropertyStyle)0, (SymbolDisplayLocalOptions)0, (SymbolDisplayKindOptions)0, (SymbolDisplayMiscellaneousOptions)3);
internal const int MaxParameterListsForErrorRecovery = 10;
private const string transparentIdentifierPrefix = "<>h__TransparentIdentifier";
private static readonly Func<Symbol, MethodSymbol> s_toMethodSymbolFunc = (Symbol s) => (MethodSymbol)s;
private static readonly Func<Symbol, PropertySymbol> s_toPropertySymbolFunc = (Symbol s) => (PropertySymbol)s;
internal CSharpCompilation Compilation { get; }
internal bool IsSemanticModelBinder => Flags.Includes(BinderFlags.SemanticModel);
internal bool IsEarlyAttributeBinder => Flags.Includes(BinderFlags.EarlyAttributeBinding);
protected virtual SyntaxNode? EnclosingNameofArgument => NextRequired.EnclosingNameofArgument;
internal virtual bool IsInsideNameof => NextRequired.IsInsideNameof;
protected internal Binder? Next { get; }
protected internal Binder NextRequired => Next;
protected OverflowChecks CheckOverflow
{
get
{
if (!Flags.Includes(BinderFlags.CheckedRegion))
{
if (!Flags.Includes(BinderFlags.UncheckedRegion))
{
return OverflowChecks.Implicit;
}
return OverflowChecks.Disabled;
}
return OverflowChecks.Enabled;
}
}
internal bool CheckOverflowAtRuntime => CheckOverflow switch
{
OverflowChecks.Implicit => ((CompilationOptions)Compilation.Options).CheckOverflow,
OverflowChecks.Enabled => true,
_ => false,
};
internal bool CheckOverflowAtCompileTime => CheckOverflow != OverflowChecks.Disabled;
internal bool UseUpdatedEscapeRules => Compilation.SourceModule.UseUpdatedEscapeRules;
internal virtual SyntaxNode? ScopeDesignator => null;
internal virtual bool IsLocalFunctionsScopeBinder => false;
internal virtual bool IsLabelsScopeBinder => false;
internal bool InExpressionTree => (Flags & BinderFlags.InExpressionTree) == BinderFlags.InExpressionTree;
internal virtual bool IsNestedFunctionBinder => false;
internal virtual Symbol? ContainingMemberOrLambda => Next.ContainingMemberOrLambda;
internal virtual bool IsInMethodBody => Next.IsInMethodBody;
internal virtual bool IsDirectlyInIterator => Next.IsDirectlyInIterator;
internal virtual bool IsIndirectlyInIterator => Next.IsIndirectlyInIterator;
internal virtual GeneratedLabelSymbol? BreakLabel => Next.BreakLabel;
internal virtual GeneratedLabelSymbol? ContinueLabel => Next.ContinueLabel;
internal virtual ImportChain? ImportChain => Next.ImportChain;
internal virtual QuickAttributeChecker QuickAttributeChecker => Next.QuickAttributeChecker;
protected virtual bool InExecutableBinder => Next.InExecutableBinder;
internal NamedTypeSymbol? ContainingType
{
get
{
Symbol containingMemberOrLambda = ContainingMemberOrLambda;
if ((object)containingMemberOrLambda != null)
{
if (containingMemberOrLambda is NamedTypeSymbol result)
{
return result;
}
return containingMemberOrLambda.ContainingType;
}
return null;
}
}
internal bool BindingTopLevelScriptCode
{
get
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Invalid comparison between Unknown and I4
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Invalid comparison between Unknown and I4
Symbol containingMemberOrLambda = ContainingMemberOrLambda;
SymbolKind? val = containingMemberOrLambda?.Kind;
if (val.HasValue)
{
SymbolKind valueOrDefault = val.GetValueOrDefault();
if ((int)valueOrDefault == 9)
{
return ((MethodSymbol)containingMemberOrLambda).IsScriptInitializer;
}
if ((int)valueOrDefault == 11)
{
return ((NamedTypeSymbol)containingMemberOrLambda).IsScriptClass;
}
}
return false;
}
}
internal virtual ConstantFieldsInProgress ConstantFieldsInProgress => Next.ConstantFieldsInProgress;
internal virtual ConsList<FieldSymbol> FieldsBeingBound => Next.FieldsBeingBound;
internal virtual LocalSymbol? LocalInProgress => Next.LocalInProgress;
internal virtual BoundExpression? ConditionalReceiverExpression => Next.ConditionalReceiverExpression;
internal Conversions Conversions
{
get
{
if (_lazyConversions == null)
{
Interlocked.CompareExchange(ref _lazyConversions, new Conversions(this), null);
}
return _lazyConversions;
}
}
internal OverloadResolution OverloadResolution
{
get
{
if (_lazyOverloadResolution == null)
{
Interlocked.CompareExchange(ref _lazyOverloadResolution, new OverloadResolution(this), null);
}
return _lazyOverloadResolution;
}
}
private bool ContextForbidsAwait
{
get
{
if (!Flags.Includes(BinderFlags.InCatchFilter))
{
return Flags.Includes(BinderFlags.InLockBody);
}
return true;
}
}
internal bool InFieldInitializer => Flags.Includes(BinderFlags.FieldInitializer);
internal bool InParameterDefaultValue => Flags.Includes(BinderFlags.ParameterDefaultValue);
protected bool InConstructorInitializer => Flags.Includes(BinderFlags.ConstructorInitializer);
internal bool InAttributeArgument => Flags.Includes(BinderFlags.AttributeArgument);
internal bool InCref => Flags.Includes(BinderFlags.Cref);
protected bool InCrefButNotParameterOrReturnType
{
get
{
if (InCref)
{
return !Flags.Includes(BinderFlags.CrefParameterOrReturnType);
}
return false;
}
}
internal virtual bool SupportsExtensionMethods => false;
internal virtual ImmutableHashSet<Symbol> LockedOrDisposedVariables => Next.LockedOrDisposedVariables;
internal virtual ImmutableArray<LocalSymbol> Locals => ImmutableArray<LocalSymbol>.Empty;
internal virtual ImmutableArray<LocalFunctionSymbol> LocalFunctions => ImmutableArray<LocalFunctionSymbol>.Empty;
internal virtual ImmutableArray<LabelSymbol> Labels => ImmutableArray<LabelSymbol>.Empty;
internal virtual ImmutableArray<AliasAndExternAliasDirective> ExternAliases => default(ImmutableArray<AliasAndExternAliasDirective>);
internal virtual ImmutableArray<AliasAndUsingDirective> UsingAliases => default(ImmutableArray<AliasAndUsingDirective>);
private bool ShouldCheckConstraints => !Flags.Includes(BinderFlags.SuppressConstraintChecks);
internal bool InUnsafeRegion => Flags.Includes(BinderFlags.UnsafeRegion);
internal Binder(CSharpCompilation compilation)
{
Flags = compilation.Options.TopLevelBinderFlags;
Compilation = compilation;
}
internal Binder(Binder next, Conversions? conversions = null)
{
Next = next;
Flags = next.Flags;
Compilation = next.Compilation;
_lazyConversions = conversions;
}
protected Binder(Binder next, BinderFlags flags)
{
Next = next;
Flags = flags;
Compilation = next.Compilation;
}
internal virtual Binder? GetBinder(SyntaxNode node)
{
return Next.GetBinder(node);
}
internal Binder GetRequiredBinder(SyntaxNode node)
{
return GetBinder(node);
}
internal virtual ImmutableArray<LocalSymbol> GetDeclaredLocalsForScope(SyntaxNode scopeDesignator)
{
return Next.GetDeclaredLocalsForScope(scopeDesignator);
}
internal virtual ImmutableArray<LocalFunctionSymbol> GetDeclaredLocalFunctionsForScope(CSharpSyntaxNode scopeDesignator)
{
return Next.GetDeclaredLocalFunctionsForScope(scopeDesignator);
}
internal bool AreNullableAnnotationsEnabled(SyntaxTree syntaxTree, int position)
{
CSharpSyntaxTree cSharpSyntaxTree = (CSharpSyntaxTree)(object)syntaxTree;
NullableContextState nullableContextState = cSharpSyntaxTree.GetNullableContextState(position);
return nullableContextState.AnnotationsState switch
{
NullableContextState.State.Enabled => true,
NullableContextState.State.Disabled => false,
NullableContextState.State.ExplicitlyRestored => GetGlobalAnnotationState(),
NullableContextState.State.Unknown => AreNullableAnnotationsGloballyEnabled() && !cSharpSyntaxTree.IsGeneratedCode(((CompilationOptions)Compilation.Options).SyntaxTreeOptionsProvider, CancellationToken.None),
_ => throw ExceptionUtilities.UnexpectedValue((object)nullableContextState.AnnotationsState),
};
}
internal bool AreNullableAnnotationsEnabled(SyntaxToken token)
{
return AreNullableAnnotationsEnabled(((SyntaxToken)(ref token)).SyntaxTree, ((SyntaxToken)(ref token)).SpanStart);
}
internal virtual bool AreNullableAnnotationsGloballyEnabled()
{
return Next.AreNullableAnnotationsGloballyEnabled();
}
protected bool GetGlobalAnnotationState()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Invalid comparison between Unknown and I4
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Invalid comparison between Unknown and I4
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
NullableContextOptions nullableContextOptions = ((CompilationOptions)Compilation.Options).NullableContextOptions;
if ((int)nullableContextOptions > 1)
{
if (nullableContextOptions - 2 <= 1)
{
return true;
}
throw ExceptionUtilities.UnexpectedValue((object)((CompilationOptions)Compilation.Options).NullableContextOptions);
}
return false;
}
internal virtual TypeWithAnnotations GetIteratorElementType()
{
return Next.GetIteratorElementType();
}
internal static void Error(BindingDiagnosticBag diagnostics, DiagnosticInfo info, SyntaxNode syntax)
{
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic(info, syntax.Location));
}
internal static void Error(BindingDiagnosticBag diagnostics, DiagnosticInfo info, Location location)
{
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic(info, location));
}
internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, CSharpSyntaxNode syntax)
{
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic((DiagnosticInfo)(object)new CSDiagnosticInfo(code), ((SyntaxNode)syntax).Location));
}
internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, CSharpSyntaxNode syntax, params object[] args)
{
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic((DiagnosticInfo)(object)new CSDiagnosticInfo(code, args), ((SyntaxNode)syntax).Location));
}
internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, SyntaxToken token)
{
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic((DiagnosticInfo)(object)new CSDiagnosticInfo(code), ((SyntaxToken)(ref token)).GetLocation()));
}
internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, SyntaxToken token, params object[] args)
{
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic((DiagnosticInfo)(object)new CSDiagnosticInfo(code, args), ((SyntaxToken)(ref token)).GetLocation()));
}
internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, SyntaxNodeOrToken syntax)
{
Location location = ((SyntaxNodeOrToken)(ref syntax)).GetLocation();
Error(diagnostics, code, location);
}
internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, SyntaxNodeOrToken syntax, params object[] args)
{
Location location = ((SyntaxNodeOrToken)(ref syntax)).GetLocation();
Error(diagnostics, code, location, args);
}
internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, Location location)
{
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic((DiagnosticInfo)(object)new CSDiagnosticInfo(code), location));
}
internal static void Error(BindingDiagnosticBag diagnostics, ErrorCode code, Location location, params object[] args)
{
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic((DiagnosticInfo)(object)new CSDiagnosticInfo(code, args), location));
}
internal void ReportDiagnosticsIfObsolete(DiagnosticBag diagnostics, Symbol symbol, SyntaxNode node, bool hasBaseReceiver)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
ReportDiagnosticsIfObsolete(diagnostics, symbol, SyntaxNodeOrToken.op_Implicit(node), hasBaseReceiver);
}
internal void ReportDiagnosticsIfObsolete(DiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, bool hasBaseReceiver)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected I4, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
SymbolKind kind = symbol.Kind;
switch (kind - 5)
{
default:
if ((int)kind != 15)
{
break;
}
goto case 0;
case 0:
case 1:
case 4:
case 6:
ReportDiagnosticsIfObsolete(diagnostics, symbol, node, hasBaseReceiver, ContainingMemberOrLambda, ContainingType, Flags);
break;
case 2:
case 3:
case 5:
break;
}
}
internal void ReportDiagnosticsIfObsolete(BindingDiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, bool hasBaseReceiver)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
if (((BindingDiagnosticBag)diagnostics).DiagnosticBag != null)
{
ReportDiagnosticsIfObsolete(((BindingDiagnosticBag)diagnostics).DiagnosticBag, symbol, node, hasBaseReceiver);
}
}
internal void ReportDiagnosticsIfObsolete(BindingDiagnosticBag diagnostics, Conversion conversion, SyntaxNodeOrToken node, bool hasBaseReceiver)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
if (conversion.IsValid && (object)conversion.Method != null)
{
ReportDiagnosticsIfObsolete(diagnostics, conversion.Method, node, hasBaseReceiver);
}
}
internal static void ReportDiagnosticsIfObsolete(DiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, bool hasBaseReceiver, Symbol? containingMember, NamedTypeSymbol? containingType, BinderFlags location)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
if ((int)symbol.Kind == 9)
{
symbol = ((MethodSymbol)symbol).ConstructedFrom;
}
Symbol leastOverriddenMember = symbol.GetLeastOverriddenMember(containingType);
bool flag = hasBaseReceiver && (object)symbol != leastOverriddenMember;
if (flag)
{
leastOverriddenMember.GetAttributes();
}
ObsoleteDiagnosticKind obsoleteDiagnosticKind = ReportDiagnosticsIfObsoleteInternal(diagnostics, leastOverriddenMember, node, containingMember, location);
if ((obsoleteDiagnosticKind == ObsoleteDiagnosticKind.NotObsolete || obsoleteDiagnosticKind == ObsoleteDiagnosticKind.Lazy) && flag)
{
ReportDiagnosticsIfObsoleteInternal(diagnostics, symbol, node, containingMember, location);
}
}
internal static void ReportDiagnosticsIfObsolete(BindingDiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, bool hasBaseReceiver, Symbol? containingMember, NamedTypeSymbol? containingType, BinderFlags location)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
if (((BindingDiagnosticBag)diagnostics).DiagnosticBag != null)
{
ReportDiagnosticsIfObsolete(((BindingDiagnosticBag)diagnostics).DiagnosticBag, symbol, node, hasBaseReceiver, containingMember, containingType, location);
}
}
internal static ObsoleteDiagnosticKind ReportDiagnosticsIfObsoleteInternal(DiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, Symbol? containingMember, BinderFlags location)
{
ObsoleteDiagnosticKind obsoleteDiagnosticKind = ObsoleteAttributeHelpers.GetObsoleteDiagnosticKind(symbol, containingMember);
DiagnosticInfo val = null;
switch (obsoleteDiagnosticKind)
{
case ObsoleteDiagnosticKind.Diagnostic:
val = ObsoleteAttributeHelpers.CreateObsoleteDiagnostic(symbol, location);
break;
case ObsoleteDiagnosticKind.Lazy:
case ObsoleteDiagnosticKind.LazyPotentiallySuppressed:
val = (DiagnosticInfo)(object)new LazyObsoleteDiagnosticInfo(symbol, containingMember, location);
break;
}
if (val != null)
{
diagnostics.Add(val, ((SyntaxNodeOrToken)(ref node)).GetLocation());
}
return obsoleteDiagnosticKind;
}
internal static void ReportDiagnosticsIfObsoleteInternal(BindingDiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, Symbol containingMember, BinderFlags location)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
if (((BindingDiagnosticBag)diagnostics).DiagnosticBag != null)
{
ReportDiagnosticsIfObsoleteInternal(((BindingDiagnosticBag)diagnostics).DiagnosticBag, symbol, node, containingMember, location);
}
}
internal static void ReportDiagnosticsIfUnmanagedCallersOnly(BindingDiagnosticBag diagnostics, MethodSymbol symbol, SyntaxNodeOrToken syntax, bool isDelegateConversion)
{
UnmanagedCallersOnlyAttributeData unmanagedCallersOnlyAttributeData = symbol.GetUnmanagedCallersOnlyAttributeData(forceComplete: false);
if (unmanagedCallersOnlyAttributeData != null)
{
diagnostics.Add((DiagnosticInfo?)((unmanagedCallersOnlyAttributeData == UnmanagedCallersOnlyAttributeData.Uninitialized) ? ((object)new LazyUnmanagedCallersOnlyMethodCalledDiagnosticInfo(symbol, isDelegateConversion)) : ((object)new CSDiagnosticInfo(isDelegateConversion ? ErrorCode.ERR_UnmanagedCallersOnlyMethodsCannotBeConvertedToDelegate : ErrorCode.ERR_UnmanagedCallersOnlyMethodsCannotBeCalledDirectly, symbol))), ((SyntaxNodeOrToken)(ref syntax)).GetLocation());
}
}
internal static bool IsSymbolAccessibleConditional(Symbol symbol, AssemblySymbol within, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
return AccessCheck.IsSymbolAccessible(symbol, within, ref useSiteInfo);
}
internal bool IsSymbolAccessibleConditional(Symbol symbol, NamedTypeSymbol within, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, TypeSymbol? throughTypeOpt = null)
{
if (!Flags.Includes(BinderFlags.IgnoreAccessibility))
{
return AccessCheck.IsSymbolAccessible(symbol, within, ref useSiteInfo, throughTypeOpt);
}
return true;
}
internal bool IsSymbolAccessibleConditional(Symbol symbol, NamedTypeSymbol within, TypeSymbol throughTypeOpt, out bool failedThroughTypeCheck, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConsList<TypeSymbol>? basesBeingResolved = null)
{
if (Flags.Includes(BinderFlags.IgnoreAccessibility))
{
failedThroughTypeCheck = false;
return true;
}
return AccessCheck.IsSymbolAccessible(symbol, within, throughTypeOpt, out failedThroughTypeCheck, ref useSiteInfo, basesBeingResolved);
}
internal static void ReportUseSiteDiagnosticForSynthesizedAttribute(CSharpCompilation compilation, WellKnownMember attributeMember, BindingDiagnosticBag diagnostics, Location? location = null, CSharpSyntaxNode? syntax = null)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
bool isOptional = WellKnownMembers.IsSynthesizedAttributeOptional(attributeMember);
GetWellKnownTypeMember(compilation, attributeMember, diagnostics, location, (SyntaxNode)(object)syntax, isOptional);
}
internal static void AddUseSiteDiagnosticForSynthesizedAttribute(CSharpCompilation compilation, WellKnownMember attributeMember, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
GetWellKnownTypeMember(compilation, attributeMember, out var useSiteInfo2, WellKnownMembers.IsSynthesizedAttributeOptional(attributeMember));
useSiteInfo.Add(useSiteInfo2);
}
public CompoundUseSiteInfo<AssemblySymbol> GetNewCompoundUseSiteInfo(BindingDiagnosticBag futureDestination)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
return new CompoundUseSiteInfo<AssemblySymbol>((BindingDiagnosticBag<AssemblySymbol>)(object)futureDestination, Compilation.Assembly);
}
internal BoundExpression WrapWithVariablesIfAny(CSharpSyntaxNode scopeDesignator, BoundExpression expression)
{
ImmutableArray<LocalSymbol> declaredLocalsForScope = GetDeclaredLocalsForScope((SyntaxNode)(object)scopeDesignator);
if (!declaredLocalsForScope.IsEmpty)
{
return new BoundSequence((SyntaxNode)(object)scopeDesignator, declaredLocalsForScope, ImmutableArray<BoundExpression>.Empty, expression, getType())
{
WasCompilerGenerated = true
};
}
return expression;
TypeSymbol getType()
{
return expression.Type;
}
}
internal BoundStatement WrapWithVariablesIfAny(CSharpSyntaxNode scopeDesignator, BoundStatement statement)
{
ImmutableArray<LocalSymbol> declaredLocalsForScope = GetDeclaredLocalsForScope((SyntaxNode)(object)scopeDesignator);
if (declaredLocalsForScope.IsEmpty)
{
return statement;
}
return new BoundBlock(statement.Syntax, declaredLocalsForScope, ImmutableArray.Create(statement))
{
WasCompilerGenerated = true
};
}
internal BoundStatement WrapWithVariablesAndLocalFunctionsIfAny(CSharpSyntaxNode scopeDesignator, BoundStatement statement)
{
ImmutableArray<LocalSymbol> declaredLocalsForScope = GetDeclaredLocalsForScope((SyntaxNode)(object)scopeDesignator);
ImmutableArray<LocalFunctionSymbol> declaredLocalFunctionsForScope = GetDeclaredLocalFunctionsForScope(scopeDesignator);
if (declaredLocalsForScope.IsEmpty && declaredLocalFunctionsForScope.IsEmpty)
{
return statement;
}
return new BoundBlock(statement.Syntax, declaredLocalsForScope, declaredLocalFunctionsForScope, hasUnsafeModifier: false, null, ImmutableArray.Create(statement))
{
WasCompilerGenerated = true
};
}
internal string Dump()
{
return TreeDumper.DumpCompact(dumpAncestors());
TreeDumperNode dumpAncestors()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
TreeDumperNode val = null;
for (Binder binder = this; binder != null; binder = binder.Next)
{
(string description, string? snippet, string locals) tuple = print(binder);
string item = tuple.description;
string item2 = tuple.snippet;
string item3 = tuple.locals;
List<TreeDumperNode> list = new List<TreeDumperNode>();
if (!EnumerableExtensions.IsEmpty(item3))
{
list.Add(new TreeDumperNode("locals", (object)item3, (IEnumerable<TreeDumperNode>)null));
}
Symbol containingMemberOrLambda = binder.ContainingMemberOrLambda;
if (containingMemberOrLambda != null && containingMemberOrLambda != binder.Next?.ContainingMemberOrLambda)
{
list.Add(new TreeDumperNode("containing symbol", (object)containingMemberOrLambda.ToDisplayString(), (IEnumerable<TreeDumperNode>)null));
}
if (item2 != null)
{
list.Add(new TreeDumperNode("scope", (object)$"{item2} ({binder.ScopeDesignator?.Kind()})", (IEnumerable<TreeDumperNode>)null));
}
if (val != null)
{
list.Add(val);
}
val = new TreeDumperNode(item, (object)null, (IEnumerable<TreeDumperNode>)list);
}
return val;
}
static (string description, string? snippet, string locals) print(Binder scope)
{
string item = string.Join(", ", ImmutableArrayExtensions.SelectAsArray<LocalSymbol, string>(scope.Locals, (Func<LocalSymbol, string>)((LocalSymbol s) => s.Name)));
string item2 = null;
if (scope.ScopeDesignator != null)
{
string[] array = ((object)scope.ScopeDesignator).ToString().Split(new string[1] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
if (array.Length == 1)
{
item2 = array[0];
}
else
{
string text = array[0];
string text2 = array[^1].Trim();
int num = Math.Min(text2.Length, 12);
item2 = text.Substring(0, Math.Min(text.Length, 12)) + " ... " + text2.Substring(text2.Length - num, num);
}
item2 = (EnumerableExtensions.IsEmpty(item2) ? null : item2);
}
return (description: scope.GetType().Name, snippet: item2, locals: item);
}
}
private static bool RequiresRValueOnly(BindValueKind kind)
{
return (kind & (BindValueKind)65532) == BindValueKind.RValue;
}
private static bool RequiresAssignmentOnly(BindValueKind kind)
{
return (kind & (BindValueKind)65532) == BindValueKind.Assignable;
}
private static bool RequiresVariable(BindValueKind kind)
{
return !RequiresRValueOnly(kind);
}
private static bool RequiresReferenceToLocation(BindValueKind kind)
{
return (kind & BindValueKind.RefersToLocation) != 0;
}
private static bool RequiresAssignableVariable(BindValueKind kind)
{
return (kind & BindValueKind.Assignable) != 0;
}
private static bool RequiresRefAssignableVariable(BindValueKind kind)
{
return (kind & BindValueKind.RefAssignable) != 0;
}
private static bool RequiresRefOrOut(BindValueKind kind)
{
return (kind & BindValueKind.RefOrOut) == BindValueKind.RefOrOut;
}
private BoundIndexerAccess BindIndexerDefaultArguments(BoundIndexerAccess indexerAccess, BindValueKind valueKind, BindingDiagnosticBag diagnostics)
{
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
bool flag = valueKind == BindValueKind.Assignable && !indexerAccess.Indexer.ReturnsByRef;
MethodSymbol methodSymbol = (flag ? indexerAccess.Indexer.GetOwnOrInheritedSetMethod() : indexerAccess.Indexer.GetOwnOrInheritedGetMethod());
if ((object)methodSymbol != null)
{
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(methodSymbol.ParameterCount);
instance.AddRange(indexerAccess.Arguments);
ArrayBuilder<RefKind> val;
if (!indexerAccess.ArgumentRefKindsOpt.IsDefaultOrEmpty)
{
val = ArrayBuilder<RefKind>.GetInstance(methodSymbol.ParameterCount);
val.AddRange(indexerAccess.ArgumentRefKindsOpt);
}
else
{
val = null;
}
ImmutableArray<int> argsToParamsOpt = indexerAccess.ArgsToParamsOpt;
ImmutableArray<ParameterSymbol> parameters = methodSymbol.Parameters;
if (flag)
{
parameters = parameters.RemoveAt(parameters.Length - 1);
}
BitVector defaultArguments = default(BitVector);
if (indexerAccess.OriginalIndexersOpt.IsDefault)
{
BindDefaultArguments(indexerAccess.Syntax, parameters, instance, val, ref argsToParamsOpt, out defaultArguments, indexerAccess.Expanded, enableCallerInfo: true, diagnostics);
}
indexerAccess = indexerAccess.Update(indexerAccess.ReceiverOpt, indexerAccess.InitialBindingReceiverIsSubjectToCloning, indexerAccess.Indexer, instance.ToImmutableAndFree(), indexerAccess.ArgumentNamesOpt, val?.ToImmutableOrNull() ?? default(ImmutableArray<RefKind>), indexerAccess.Expanded, argsToParamsOpt, defaultArguments, indexerAccess.Type);
val?.Free();
}
return indexerAccess;
}
private BoundExpression CheckValue(BoundExpression expr, BindValueKind valueKind, BindingDiagnosticBag diagnostics)
{
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
switch (expr.Kind)
{
case BoundKind.PropertyGroup:
expr = BindIndexedPropertyAccess((BoundPropertyGroup)expr, mustHaveAllOptionalParameters: false, diagnostics);
if (expr is BoundIndexerAccess indexerAccess)
{
expr = BindIndexerDefaultArguments(indexerAccess, valueKind, diagnostics);
}
break;
case BoundKind.OutVariablePendingInference:
case BoundKind.OutDeconstructVarPendingInference:
return expr;
case BoundKind.DiscardExpression:
return expr;
case BoundKind.IndexerAccess:
expr = BindIndexerDefaultArguments((BoundIndexerAccess)expr, valueKind, diagnostics);
break;
case BoundKind.UnconvertedObjectCreationExpression:
if (valueKind == BindValueKind.RValue)
{
return expr;
}
break;
case BoundKind.UnconvertedCollectionExpression:
if (valueKind == BindValueKind.RValue)
{
return expr;
}
break;
case BoundKind.PointerIndirectionOperator:
if ((valueKind & BindValueKind.RefersToLocation) == BindValueKind.RefersToLocation)
{
BoundPointerIndirectionOperator boundPointerIndirectionOperator = (BoundPointerIndirectionOperator)expr;
expr = boundPointerIndirectionOperator.Update(boundPointerIndirectionOperator.Operand, refersToLocation: true, boundPointerIndirectionOperator.Type);
}
break;
case BoundKind.PointerElementAccess:
if ((valueKind & BindValueKind.RefersToLocation) == BindValueKind.RefersToLocation)
{
BoundPointerElementAccess boundPointerElementAccess = (BoundPointerElementAccess)expr;
expr = boundPointerElementAccess.Update(boundPointerElementAccess.Expression, boundPointerElementAccess.Index, boundPointerElementAccess.Checked, refersToLocation: true, boundPointerElementAccess.Type);
}
break;
}
bool flag = false;
if (expr.Kind == BoundKind.MethodGroup && valueKind != BindValueKind.RValueOrMethodGroup)
{
BoundMethodGroup boundMethodGroup = (BoundMethodGroup)expr;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
MethodGroupResolution methodGroupResolution = ResolveMethodGroup(boundMethodGroup, null, isMethodGroupConversion: false, ref useSiteInfo, inferWithDynamic: false, (RefKind)0, null, isFunctionPointerResolution: false, default(CallingConventionInfo));
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(expr.Syntax, useSiteInfo);
Symbol symbol = null;
bool num = methodGroupResolution.MethodGroup != null;
if (!expr.HasAnyErrors)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(methodGroupResolution.Diagnostics, false);
}
flag = methodGroupResolution.HasAnyErrors;
if (flag)
{
symbol = methodGroupResolution.OtherSymbol;
}
methodGroupResolution.Free();
if (!num)
{
BoundExpression boundExpression = boundMethodGroup.ReceiverOpt;
if ((object)symbol != null && boundExpression != null && boundExpression.Kind == BoundKind.TypeOrValueExpression)
{
BoundTypeOrValueExpression boundTypeOrValueExpression = (BoundTypeOrValueExpression)boundExpression;
boundExpression = (symbol.RequiresInstanceReceiver() ? boundTypeOrValueExpression.Data.ValueExpression : null);
}
return new BoundBadExpression(expr.Syntax, boundMethodGroup.ResultKind, ((object)symbol == null) ? ImmutableArray<Symbol>.Empty : ImmutableArray.Create(symbol), (boundExpression == null) ? ImmutableArray<BoundExpression>.Empty : ImmutableArray.Create(boundExpression), GetNonMethodMemberType(symbol));
}
}
if ((!flag && CheckValueKind(expr.Syntax, expr, valueKind, checkingReceiver: false, diagnostics)) || (expr.HasAnyErrors && valueKind == BindValueKind.RValueOrMethodGroup))
{
return expr;
}
LookupResultKind resultKind = ((valueKind == BindValueKind.RValue || valueKind == BindValueKind.RValueOrMethodGroup) ? LookupResultKind.NotAValue : LookupResultKind.NotAVariable);
return ToBadExpression(expr, resultKind);
}
internal static bool IsTypeOrValueExpression(BoundExpression expression)
{
BoundKind? boundKind = expression?.Kind;
if (boundKind.HasValue)
{
BoundKind valueOrDefault = boundKind.GetValueOrDefault();
if (valueOrDefault == BoundKind.TypeOrValueExpression || (valueOrDefault == BoundKind.QueryClause && ((BoundQueryClause)expression).Value.Kind == BoundKind.TypeOrValueExpression))
{
return true;
}
}
return false;
}
internal bool CheckValueKind(SyntaxNode node, BoundExpression expr, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
{
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Invalid comparison between Unknown and I4
//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
//IL_0409: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_048c: Unknown result type (might be due to invalid IL or missing references)
//IL_05af: Unknown result type (might be due to invalid IL or missing references)
//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
//IL_05bd: Invalid comparison between Unknown and I4
//IL_037e: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
//IL_05c6: Invalid comparison between Unknown and I4
if (expr.HasAnyErrors)
{
return false;
}
switch (expr.Kind)
{
case BoundKind.ImplicitIndexerAccess:
if (((BoundImplicitIndexerAccess)expr).IndexerOrSliceAccess.Kind != BoundKind.IndexerAccess)
{
break;
}
goto case BoundKind.PropertyAccess;
case BoundKind.PropertyAccess:
case BoundKind.IndexerAccess:
return CheckPropertyValueKind(node, expr, valueKind, checkingReceiver, diagnostics);
case BoundKind.EventAccess:
return CheckEventValueKind((BoundEventAccess)expr, valueKind, diagnostics);
}
if (RequiresRValueOnly(valueKind))
{
return CheckNotNamespaceOrType(expr, diagnostics);
}
if (expr.ConstantValueOpt != (ConstantValue)null || (int)expr.Type.GetSpecialTypeSafe() == 6)
{
Error(diagnostics, GetStandardLvalueError(valueKind), SyntaxNodeOrToken.op_Implicit(node));
return false;
}
bool isValueType;
switch (expr.Kind)
{
case BoundKind.NamespaceExpression:
{
BoundNamespaceExpression boundNamespaceExpression = (BoundNamespaceExpression)expr;
Error(diagnostics, ErrorCode.ERR_BadSKknown, SyntaxNodeOrToken.op_Implicit(node), boundNamespaceExpression.NamespaceSymbol, MessageID.IDS_SK_NAMESPACE.Localize(), MessageID.IDS_SK_VARIABLE.Localize());
return false;
}
case BoundKind.TypeExpression:
{
BoundTypeExpression boundTypeExpression = (BoundTypeExpression)expr;
Error(diagnostics, ErrorCode.ERR_BadSKknown, SyntaxNodeOrToken.op_Implicit(node), boundTypeExpression.Type, MessageID.IDS_SK_TYPE.Localize(), MessageID.IDS_SK_VARIABLE.Localize());
return false;
}
case BoundKind.Lambda:
case BoundKind.UnboundLambda:
Error(diagnostics, GetStandardLvalueError(valueKind), SyntaxNodeOrToken.op_Implicit(node));
return false;
case BoundKind.UnconvertedAddressOfOperator:
{
BoundUnconvertedAddressOfOperator boundUnconvertedAddressOfOperator = (BoundUnconvertedAddressOfOperator)expr;
Error(diagnostics, GetMethodGroupOrFunctionPointerLvalueError(valueKind), SyntaxNodeOrToken.op_Implicit(node), boundUnconvertedAddressOfOperator.Operand.Name, MessageID.IDS_AddressOfMethodGroup.Localize());
return false;
}
case BoundKind.MethodGroup:
{
if (valueKind == BindValueKind.AddressOf)
{
return true;
}
BoundMethodGroup boundMethodGroup = (BoundMethodGroup)expr;
Error(diagnostics, GetMethodGroupOrFunctionPointerLvalueError(valueKind), SyntaxNodeOrToken.op_Implicit(node), boundMethodGroup.Name, MessageID.IDS_MethodGroup.Localize());
return false;
}
case BoundKind.RangeVariable:
{
BoundRangeVariable boundRangeVariable = (BoundRangeVariable)expr;
ErrorCode rangeLvalueError = GetRangeLvalueError(valueKind);
if ((rangeLvalueError == ErrorCode.ERR_InvalidAddrOp || rangeLvalueError == ErrorCode.ERR_RefLocalOrParamExpected) ? true : false)
{
Error(diagnostics, rangeLvalueError, SyntaxNodeOrToken.op_Implicit(node));
}
else
{
Error(diagnostics, rangeLvalueError, SyntaxNodeOrToken.op_Implicit(node), boundRangeVariable.RangeVariableSymbol.Name);
}
return false;
}
case BoundKind.Conversion:
if (((BoundConversion)expr).ConversionKind == ConversionKind.Unboxing)
{
Error(diagnostics, ErrorCode.ERR_UnboxNotLValue, SyntaxNodeOrToken.op_Implicit(node));
return false;
}
break;
case BoundKind.ArrayAccess:
return checkArrayAccessValueKind(node, valueKind, ((BoundArrayAccess)expr).Indices, diagnostics);
case BoundKind.PointerIndirectionOperator:
case BoundKind.RefValueOperator:
case BoundKind.DynamicMemberAccess:
case BoundKind.DynamicObjectInitializerMember:
case BoundKind.DynamicIndexerAccess:
if (RequiresRefAssignableVariable(valueKind))
{
Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, SyntaxNodeOrToken.op_Implicit(node));
return false;
}
return true;
case BoundKind.PointerElementAccess:
if (RequiresRefAssignableVariable(valueKind))
{
Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, SyntaxNodeOrToken.op_Implicit(node));
return false;
}
if (((BoundPointerElementAccess)expr).Expression is BoundFieldAccess boundFieldAccess && boundFieldAccess.FieldSymbol.IsFixedSizeBuffer)
{
return CheckValueKind(node, boundFieldAccess.ReceiverOpt, valueKind, checkingReceiver: true, diagnostics);
}
return true;
case BoundKind.Parameter:
{
BoundParameter parameter = (BoundParameter)expr;
return CheckParameterValueKind(node, parameter, valueKind, checkingReceiver, diagnostics);
}
case BoundKind.Local:
{
BoundLocal local = (BoundLocal)expr;
return CheckLocalValueKind(node, local, valueKind, checkingReceiver, diagnostics);
}
case BoundKind.ThisReference:
if (RequiresRefAssignableVariable(valueKind))
{
Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, SyntaxNodeOrToken.op_Implicit(node));
return false;
}
isValueType = ((BoundThisReference)expr).Type.IsValueType;
if (isValueType)
{
if (RequiresAssignableVariable(valueKind))
{
MethodSymbol obj = ContainingMemberOrLambda as MethodSymbol;
if ((object)obj != null && obj.IsEffectivelyReadOnly)
{
goto IL_04cf;
}
}
return true;
}
goto IL_04cf;
case BoundKind.ObjectOrCollectionValuePlaceholder:
case BoundKind.ImplicitReceiver:
return true;
case BoundKind.Call:
{
BoundCall boundCall2 = (BoundCall)expr;
return CheckMethodReturnValueKind(boundCall2.Method, boundCall2.Syntax, node, valueKind, checkingReceiver, diagnostics);
}
case BoundKind.FunctionPointerInvocation:
return CheckMethodReturnValueKind(((BoundFunctionPointerInvocation)expr).FunctionPointer.Signature, expr.Syntax, node, valueKind, checkingReceiver, diagnostics);
case BoundKind.ImplicitIndexerAccess:
{
BoundImplicitIndexerAccess boundImplicitIndexerAccess = (BoundImplicitIndexerAccess)expr;
BoundExpression indexerOrSliceAccess = boundImplicitIndexerAccess.IndexerOrSliceAccess;
if (!(indexerOrSliceAccess is BoundArrayAccess boundArrayAccess))
{
if (indexerOrSliceAccess is BoundCall boundCall)
{
return CheckMethodReturnValueKind(boundCall.Method, boundCall.Syntax, node, valueKind, checkingReceiver, diagnostics);
}
throw ExceptionUtilities.UnexpectedValue((object)boundImplicitIndexerAccess.IndexerOrSliceAccess.Kind);
}
return checkArrayAccessValueKind(node, valueKind, boundArrayAccess.Indices, diagnostics);
}
case BoundKind.InlineArrayAccess:
{
BoundInlineArrayAccess boundInlineArrayAccess = (BoundInlineArrayAccess)expr;
bool flag = boundInlineArrayAccess.IsValue;
if (!flag)
{
WellKnownMember getItemOrSliceHelper = boundInlineArrayAccess.GetItemOrSliceHelper;
bool flag2 = (((int)getItemOrSliceHelper == 402 || (int)getItemOrSliceHelper == 408) ? true : false);
flag = flag2;
}
if (!flag)
{
MethodSymbol methodSymbol = (MethodSymbol)Compilation.GetWellKnownTypeMember(boundInlineArrayAccess.GetItemOrSliceHelper);
if ((object)methodSymbol == null)
{
return true;
}
methodSymbol = methodSymbol.AsMember(methodSymbol.ContainingType.Construct(ImmutableArray.Create(boundInlineArrayAccess.Expression.Type.TryGetInlineArrayElementField().TypeWithAnnotations)));
return CheckMethodReturnValueKind(methodSymbol, boundInlineArrayAccess.Syntax, node, valueKind, checkingReceiver, diagnostics);
}
break;
}
case BoundKind.ConditionalOperator:
{
BoundConditionalOperator boundConditionalOperator = (BoundConditionalOperator)expr;
if (boundConditionalOperator.IsRef && (CheckValueKind(boundConditionalOperator.Consequence.Syntax, boundConditionalOperator.Consequence, valueKind, checkingReceiver: false, diagnostics) & CheckValueKind(boundConditionalOperator.Alternative.Syntax, boundConditionalOperator.Alternative, valueKind, checkingReceiver: false, diagnostics)))
{
return true;
}
break;
}
case BoundKind.FieldAccess:
{
BoundFieldAccess fieldAccess = (BoundFieldAccess)expr;
return CheckFieldValueKind(node, fieldAccess, valueKind, checkingReceiver, diagnostics);
}
case BoundKind.AssignmentOperator:
{
BoundAssignmentOperator assignment = (BoundAssignmentOperator)expr;
return CheckSimpleAssignmentValueKind(node, assignment, valueKind, diagnostics);
}
IL_04cf:
ReportThisLvalueError(node, valueKind, isValueType, isPrimaryConstructorParameter: false, diagnostics);
return false;
}
Error(diagnostics, GetStandardLvalueError(valueKind), SyntaxNodeOrToken.op_Implicit(node));
return false;
bool checkArrayAccessValueKind(SyntaxNode val, BindValueKind kind, ImmutableArray<BoundExpression> indices, BindingDiagnosticBag diagnostics2)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
if (RequiresRefAssignableVariable(kind))
{
Error(diagnostics2, ErrorCode.ERR_RefLocalOrParamExpected, SyntaxNodeOrToken.op_Implicit(val));
return false;
}
if (indices.Length == 1 && TypeSymbol.Equals(indices[0].Type, Compilation.GetWellKnownType((WellKnownType)285), (TypeCompareKind)0))
{
Error(diagnostics2, GetStandardLvalueError(kind), SyntaxNodeOrToken.op_Implicit(val));
return false;
}
return true;
}
}
private static void ReportThisLvalueError(SyntaxNode node, BindValueKind valueKind, bool isValueType, bool isPrimaryConstructorParameter, BindingDiagnosticBag diagnostics)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
ErrorCode thisLvalueError = GetThisLvalueError(valueKind, isValueType, isPrimaryConstructorParameter);
bool flag;
switch (thisLvalueError)
{
case ErrorCode.ERR_InvalidAddrOp:
case ErrorCode.ERR_IncrementLvalueExpected:
case ErrorCode.ERR_RefLvalueExpected:
case ErrorCode.ERR_RefReturnThis:
case ErrorCode.ERR_RefLocalOrParamExpected:
flag = true;
break;
default:
flag = false;
break;
}
if (flag)
{
Error(diagnostics, thisLvalueError, SyntaxNodeOrToken.op_Implicit(node));
return;
}
Error(diagnostics, thisLvalueError, SyntaxNodeOrToken.op_Implicit(node), node);
}
private static bool CheckNotNamespaceOrType(BoundExpression expr, BindingDiagnosticBag diagnostics)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
switch (expr.Kind)
{
case BoundKind.NamespaceExpression:
Error(diagnostics, ErrorCode.ERR_BadSKknown, SyntaxNodeOrToken.op_Implicit(expr.Syntax), ((BoundNamespaceExpression)expr).NamespaceSymbol, MessageID.IDS_SK_NAMESPACE.Localize(), MessageID.IDS_SK_VARIABLE.Localize());
return false;
case BoundKind.TypeExpression:
Error(diagnostics, ErrorCode.ERR_BadSKunknown, SyntaxNodeOrToken.op_Implicit(expr.Syntax), expr.Type, MessageID.IDS_SK_TYPE.Localize());
return false;
default:
return true;
}
}
private bool CheckLocalValueKind(SyntaxNode node, BoundLocal local, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Invalid comparison between Unknown and I4
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
if (valueKind == BindValueKind.AddressOf && IsInAsyncMethod())
{
Error(diagnostics, ErrorCode.WRN_AddressOfInAsync, SyntaxNodeOrToken.op_Implicit(node));
}
LocalSymbol localSymbol = local.LocalSymbol;
if (RequiresAssignableVariable(valueKind))
{
if (LockedOrDisposedVariables.Contains(localSymbol))
{
diagnostics.Add(ErrorCode.WRN_AssignmentToLockOrDispose, local.Syntax.Location, localSymbol);
}
if ((int)localSymbol.RefKind == 3 || ((int)localSymbol.RefKind == 0 && !localSymbol.IsWritableVariable))
{
ReportReadonlyLocalError(node, localSymbol, valueKind, checkingReceiver, diagnostics);
return false;
}
}
else if (RequiresRefAssignableVariable(valueKind))
{
if ((int)localSymbol.RefKind == 0)
{
diagnostics.Add(ErrorCode.ERR_RefLocalOrParamExpected, node.Location);
return false;
}
if (!localSymbol.IsWritableVariable)
{
ReportReadonlyLocalError(node, localSymbol, valueKind, checkingReceiver, diagnostics);
return false;
}
}
return true;
}
private bool CheckParameterValueKind(SyntaxNode node, BoundParameter parameter, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Invalid comparison between Unknown and I4
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
if (valueKind == BindValueKind.AddressOf && IsInAsyncMethod())
{
Error(diagnostics, ErrorCode.WRN_AddressOfInAsync, SyntaxNodeOrToken.op_Implicit(node));
}
ParameterSymbol parameterSymbol = parameter.ParameterSymbol;
RefKind refKind = parameterSymbol.RefKind;
bool flag = refKind - 3 <= 1;
if (flag && RequiresAssignableVariable(valueKind))
{
ReportReadOnlyError(parameterSymbol, node, valueKind, checkingReceiver, diagnostics);
return false;
}
if ((int)parameterSymbol.RefKind == 0 && RequiresRefAssignableVariable(valueKind))
{
Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, SyntaxNodeOrToken.op_Implicit(node));
return false;
}
if ((int)parameterSymbol.RefKind == 0 && parameterSymbol.ContainingSymbol is SynthesizedPrimaryConstructor synthesizedPrimaryConstructor && synthesizedPrimaryConstructor.GetCapturedParameters().TryGetValue(parameterSymbol, out FieldSymbol value))
{
if (value.IsReadOnly && RequiresAssignableVariable(valueKind) && !CanModifyReadonlyField(receiverIsThis: true, value))
{
reportReadOnlyParameterError(parameterSymbol, node, valueKind, checkingReceiver, diagnostics);
return false;
}
if (RequiresAssignableVariable(valueKind) && !value.ContainingType.IsReferenceType)
{
MethodSymbol obj = ContainingMemberOrLambda as MethodSymbol;
if ((object)obj != null && obj.IsEffectivelyReadOnly)
{
ReportThisLvalueError(node, valueKind, isValueType: true, isPrimaryConstructorParameter: true, diagnostics);
return false;
}
}
}
if (LockedOrDisposedVariables.Contains(parameterSymbol))
{
diagnostics.Add(ErrorCode.WRN_AssignmentToLockOrDispose, parameter.Syntax.Location, parameterSymbol.Name);
}
return true;
}
private static void reportReadOnlyParameterError(ParameterSymbol parameterSymbol, SyntaxNode node, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if (checkingReceiver)
{
ErrorCode code = ((valueKind == BindValueKind.RefReturn) ? ErrorCode.ERR_RefReturnReadonlyPrimaryConstructorParameter2 : ((!RequiresRefOrOut(valueKind)) ? ErrorCode.ERR_AssgReadonlyPrimaryConstructorParameter2 : ErrorCode.ERR_RefReadonlyPrimaryConstructorParameter2));
Error(diagnostics, code, SyntaxNodeOrToken.op_Implicit(node), parameterSymbol);
}
else
{
ErrorCode code2 = ((valueKind == BindValueKind.RefReturn) ? ErrorCode.ERR_RefReturnReadonlyPrimaryConstructorParameter : ((!RequiresRefOrOut(valueKind)) ? ErrorCode.ERR_AssgReadonlyPrimaryConstructorParameter : ErrorCode.ERR_RefReadonlyPrimaryConstructorParameter));
Error(diagnostics, code2, SyntaxNodeOrToken.op_Implicit(node));
}
}
private bool CheckFieldValueKind(SyntaxNode node, BoundFieldAccess fieldAccess, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected I4, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Expected I4, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
FieldSymbol fieldSymbol = fieldAccess.FieldSymbol;
if (fieldSymbol.IsReadOnly && (((int)fieldSymbol.RefKind == 0) ? RequiresAssignableVariable(valueKind) : RequiresRefAssignableVariable(valueKind)) && !CanModifyReadonlyField(fieldAccess.ReceiverOpt is BoundThisReference, fieldSymbol))
{
ReportReadOnlyFieldError(fieldSymbol, node, valueKind, checkingReceiver, diagnostics);
return false;
}
if (RequiresAssignableVariable(valueKind))
{
RefKind refKind = fieldSymbol.RefKind;
switch ((int)refKind)
{
case 1:
return true;
case 3:
ReportReadOnlyError(fieldSymbol, node, valueKind, checkingReceiver, diagnostics);
return false;
default:
throw ExceptionUtilities.UnexpectedValue((object)fieldSymbol.RefKind);
case 0:
break;
}
if (fieldSymbol.IsFixedSizeBuffer)
{
Error(diagnostics, GetStandardLvalueError(valueKind), SyntaxNodeOrToken.op_Implicit(node));
return false;
}
}
if (RequiresRefAssignableVariable(valueKind))
{
RefKind refKind = fieldSymbol.RefKind;
switch ((int)refKind)
{
case 0:
Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, SyntaxNodeOrToken.op_Implicit(node));
return false;
case 1:
case 3:
return CheckIsValidReceiverForVariable(node, fieldAccess.ReceiverOpt, BindValueKind.Assignable, diagnostics);
default:
throw ExceptionUtilities.UnexpectedValue((object)fieldSymbol.RefKind);
}
}
if (fieldSymbol.IsStatic || fieldSymbol.ContainingType.IsReferenceType)
{
return true;
}
return CheckIsValidReceiverForVariable(node, fieldAccess.ReceiverOpt, valueKind, diagnostics);
}
private bool CanModifyReadonlyField(bool receiverIsThis, FieldSymbol fieldSymbol)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Invalid comparison between Unknown and I4
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Invalid comparison between Unknown and I4
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
bool isStatic = fieldSymbol.IsStatic;
bool result = false;
Symbol containingMemberOrLambda = ContainingMemberOrLambda;
if ((object)containingMemberOrLambda != null && isStatic == containingMemberOrLambda.IsStatic && (isStatic || receiverIsThis) && (Compilation.FeatureStrictEnabled ? TypeSymbol.Equals(fieldSymbol.ContainingType, containingMemberOrLambda.ContainingType, (TypeCompareKind)63) : TypeSymbol.Equals(fieldSymbol.ContainingType.OriginalDefinition, containingMemberOrLambda.ContainingType.OriginalDefinition, (TypeCompareKind)63)))
{
if ((int)containingMemberOrLambda.Kind == 9)
{
MethodSymbol obj = (MethodSymbol)containingMemberOrLambda;
MethodKind val = (MethodKind)((!isStatic) ? 1 : 14);
result = obj.MethodKind == val || isAssignedFromInitOnlySetterOnThis(receiverIsThis);
}
else if ((int)containingMemberOrLambda.Kind == 6)
{
result = true;
}
}
return result;
bool isAssignedFromInitOnlySetterOnThis(bool flag)
{
if (!flag)
{
return false;
}
if (!(ContainingMemberOrLambda is MethodSymbol methodSymbol))
{
return false;
}
return methodSymbol.IsInitOnly;
}
}
private bool CheckSimpleAssignmentValueKind(SyntaxNode node, BoundAssignmentOperator assignment, BindValueKind valueKind, BindingDiagnosticBag diagnostics)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
if (assignment.IsRef)
{
return CheckValueKind(node, assignment.Left, valueKind, checkingReceiver: false, diagnostics);
}
Error(diagnostics, GetStandardLvalueError(valueKind), SyntaxNodeOrToken.op_Implicit(node));
return false;
}
private bool CheckEventValueKind(BoundEventAccess boundEvent, BindValueKind valueKind, BindingDiagnosticBag diagnostics)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
BoundExpression receiverOpt = boundEvent.ReceiverOpt;
SyntaxNode eventName = GetEventName(boundEvent);
EventSymbol eventSymbol = boundEvent.EventSymbol;
if (valueKind == BindValueKind.CompoundAssignment)
{
if (ReportUseSite(eventSymbol, diagnostics, eventName))
{
return false;
}
return true;
}
if (!boundEvent.IsUsableAsField)
{
Error(diagnostics, GetBadEventUsageDiagnosticInfo(eventSymbol), eventName);
return false;
}
if (ReportUseSite(eventSymbol, diagnostics, eventName))
{
if (!CheckIsValidReceiverForVariable(eventName, receiverOpt, BindValueKind.Assignable, diagnostics))
{
return false;
}
}
else if (RequiresVariable(valueKind))
{
if (eventSymbol.IsWindowsRuntimeEvent && valueKind != BindValueKind.Assignable)
{
if (valueKind == BindValueKind.RefOrOut)
{
Error(diagnostics, ErrorCode.ERR_WinRtEventPassedByRef, SyntaxNodeOrToken.op_Implicit(eventName));
}
else
{
Error(diagnostics, GetStandardLvalueError(valueKind), SyntaxNodeOrToken.op_Implicit(eventName), eventSymbol);
}
return false;
}
if (RequiresVariableReceiver(receiverOpt, eventSymbol.AssociatedField) && !CheckIsValidReceiverForVariable(eventName, receiverOpt, valueKind, diagnostics))
{
return false;
}
}
return true;
}
private bool CheckIsValidReceiverForVariable(SyntaxNode node, BoundExpression receiver, BindValueKind kind, BindingDiagnosticBag diagnostics)
{
if (!Flags.Includes(BinderFlags.ObjectInitializerMember) || receiver.Kind != BoundKind.ObjectOrCollectionValuePlaceholder)
{
return CheckValueKind(node, receiver, kind, checkingReceiver: true, diagnostics);
}
return true;
}
private static bool RequiresVariableReceiver(BoundExpression receiver, Symbol symbol)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
if (symbol.RequiresInstanceReceiver() && (int)symbol.Kind != 5)
{
if (receiver == null)
{
return false;
}
return receiver.Type?.IsValueType == true;
}
return false;
}
protected bool CheckMethodReturnValueKind(MethodSymbol methodSymbol, SyntaxNode callSyntaxOpt, SyntaxNode node, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Invalid comparison between Unknown and I4
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (RequiresVariable(valueKind) && (int)methodSymbol.RefKind == 0)
{
if (checkingReceiver)
{
Error(diagnostics, ErrorCode.ERR_ReturnNotLValue, SyntaxNodeOrToken.op_Implicit(callSyntaxOpt), methodSymbol);
}
else
{
Error(diagnostics, GetStandardLvalueError(valueKind), SyntaxNodeOrToken.op_Implicit(node));
}
return false;
}
if (RequiresAssignableVariable(valueKind) && (int)methodSymbol.RefKind == 3)
{
ReportReadOnlyError(methodSymbol, node, valueKind, checkingReceiver, diagnostics);
return false;
}
if (RequiresRefAssignableVariable(valueKind))
{
Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, SyntaxNodeOrToken.op_Implicit(node));
return false;
}
return true;
}
private bool CheckPropertyValueKind(SyntaxNode node, BoundExpression expr, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Invalid comparison between Unknown and I4
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Invalid comparison between Unknown and I4
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Invalid comparison between Unknown and I4
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0427: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_033f: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
//IL_038e: Unknown result type (might be due to invalid IL or missing references)
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
BoundExpression receiver;
SyntaxNode propertySyntax;
PropertySymbol propertySymbol = GetPropertySymbol(expr, out receiver, out propertySyntax);
if ((RequiresReferenceToLocation(valueKind) || checkingReceiver) && (int)propertySymbol.RefKind == 0)
{
if (checkingReceiver)
{
Error(diagnostics, ErrorCode.ERR_ReturnNotLValue, SyntaxNodeOrToken.op_Implicit(expr.Syntax), propertySymbol);
}
else if (valueKind == BindValueKind.RefOrOut)
{
Error(diagnostics, ErrorCode.ERR_RefProperty, SyntaxNodeOrToken.op_Implicit(node));
}
else
{
Error(diagnostics, GetStandardLvalueError(valueKind), SyntaxNodeOrToken.op_Implicit(node));
}
return false;
}
if (RequiresAssignableVariable(valueKind) && (int)propertySymbol.RefKind == 3)
{
ReportReadOnlyError(propertySymbol, node, valueKind, checkingReceiver, diagnostics);
return false;
}
if (RequiresAssignableVariable(valueKind) && (int)propertySymbol.RefKind == 0)
{
MethodSymbol ownOrInheritedSetMethod = propertySymbol.GetOwnOrInheritedSetMethod();
if ((object)ownOrInheritedSetMethod == null)
{
Symbol containingMemberOrLambda = ContainingMemberOrLambda;
if (!AccessingAutoPropertyFromConstructor(receiver, propertySymbol, containingMemberOrLambda) && !isAllowedDespiteReadonly(receiver))
{
Error(diagnostics, ErrorCode.ERR_AssgReadonlyProp, SyntaxNodeOrToken.op_Implicit(node), propertySymbol);
return false;
}
}
else
{
if (ownOrInheritedSetMethod.IsInitOnly)
{
if (!isAllowedInitOnlySet(receiver))
{
Error(diagnostics, ErrorCode.ERR_AssignmentInitOnly, SyntaxNodeOrToken.op_Implicit(node), propertySymbol);
return false;
}
if (ownOrInheritedSetMethod.DeclaringCompilation != Compilation)
{
CheckFeatureAvailability(node, MessageID.IDS_FeatureInitOnlySetters, diagnostics);
}
}
TypeSymbol accessThroughType = GetAccessThroughType(receiver);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
bool failedThroughTypeCheck;
bool num = IsAccessible(ownOrInheritedSetMethod, accessThroughType, out failedThroughTypeCheck, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
if (!num)
{
if (failedThroughTypeCheck)
{
Error(diagnostics, ErrorCode.ERR_BadProtectedAccess, SyntaxNodeOrToken.op_Implicit(node), propertySymbol, accessThroughType, ContainingType);
}
else
{
Error(diagnostics, ErrorCode.ERR_InaccessibleSetter, SyntaxNodeOrToken.op_Implicit(node), propertySymbol);
}
return false;
}
ReportDiagnosticsIfObsolete(diagnostics, ownOrInheritedSetMethod, SyntaxNodeOrToken.op_Implicit(node), receiver != null && receiver.Kind == BoundKind.BaseReference);
BindValueKind kind = (ownOrInheritedSetMethod.IsEffectivelyReadOnly ? BindValueKind.RValue : BindValueKind.Assignable);
if (RequiresVariableReceiver(receiver, ownOrInheritedSetMethod) && !CheckIsValidReceiverForVariable(node, receiver, kind, diagnostics))
{
return false;
}
if (IsBadBaseAccess(node, receiver, ownOrInheritedSetMethod, diagnostics, propertySymbol) || reportUseSite(ownOrInheritedSetMethod))
{
return false;
}
CheckReceiverAndRuntimeSupportForSymbolAccess(node, receiver, ownOrInheritedSetMethod, diagnostics);
}
}
if (!RequiresAssignmentOnly(valueKind) || (int)propertySymbol.RefKind > 0)
{
MethodSymbol ownOrInheritedGetMethod = propertySymbol.GetOwnOrInheritedGetMethod();
if ((object)ownOrInheritedGetMethod == null)
{
Error(diagnostics, ErrorCode.ERR_PropertyLacksGet, SyntaxNodeOrToken.op_Implicit(node), propertySymbol);
return false;
}
TypeSymbol accessThroughType2 = GetAccessThroughType(receiver);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo2 = GetNewCompoundUseSiteInfo(diagnostics);
bool failedThroughTypeCheck2;
bool num2 = IsAccessible(ownOrInheritedGetMethod, accessThroughType2, out failedThroughTypeCheck2, ref useSiteInfo2);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo2);
if (!num2)
{
if (failedThroughTypeCheck2)
{
Error(diagnostics, ErrorCode.ERR_BadProtectedAccess, SyntaxNodeOrToken.op_Implicit(node), propertySymbol, accessThroughType2, ContainingType);
}
else
{
Error(diagnostics, ErrorCode.ERR_InaccessibleGetter, SyntaxNodeOrToken.op_Implicit(node), propertySymbol);
}
return false;
}
CheckImplicitThisCopyInReadOnlyMember(receiver, ownOrInheritedGetMethod, diagnostics);
ReportDiagnosticsIfObsolete(diagnostics, ownOrInheritedGetMethod, SyntaxNodeOrToken.op_Implicit(node), receiver != null && receiver.Kind == BoundKind.BaseReference);
if (IsBadBaseAccess(node, receiver, ownOrInheritedGetMethod, diagnostics, propertySymbol) || reportUseSite(ownOrInheritedGetMethod))
{
return false;
}
CheckReceiverAndRuntimeSupportForSymbolAccess(node, receiver, ownOrInheritedGetMethod, diagnostics);
}
if (RequiresRefAssignableVariable(valueKind))
{
Error(diagnostics, ErrorCode.ERR_RefLocalOrParamExpected, SyntaxNodeOrToken.op_Implicit(node));
return false;
}
return true;
static bool isAllowedDespiteReadonly(BoundExpression boundExpression)
{
if (boundExpression is BoundObjectOrCollectionValuePlaceholder && boundExpression.Type.IsAnonymousType)
{
return true;
}
return false;
}
bool isAllowedInitOnlySet(BoundExpression boundExpression)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Invalid comparison between Unknown and I4
if (boundExpression is BoundObjectOrCollectionValuePlaceholder boundObjectOrCollectionValuePlaceholder)
{
return boundObjectOrCollectionValuePlaceholder.IsNewInstance;
}
if (!(boundExpression is BoundThisReference) && !(boundExpression is BoundBaseReference))
{
return false;
}
if (!(ContainingMemberOrLambda is MethodSymbol methodSymbol))
{
return false;
}
if ((int)methodSymbol.MethodKind == 1 || methodSymbol.IsInitOnly)
{
return true;
}
return false;
}
bool reportUseSite(MethodSymbol accessor)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
UseSiteInfo<AssemblySymbol> useSiteInfo3 = accessor.GetUseSiteInfo();
if (!object.Equals(useSiteInfo3.DiagnosticInfo, propertySymbol.GetUseSiteInfo().DiagnosticInfo))
{
return ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(useSiteInfo3, propertySyntax);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddDependencies(useSiteInfo3);
return false;
}
}
private bool IsBadBaseAccess(SyntaxNode node, BoundExpression receiverOpt, Symbol member, BindingDiagnosticBag diagnostics, Symbol propertyOrEventSymbolOpt = null)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (receiverOpt != null && receiverOpt.Kind == BoundKind.BaseReference && member.IsAbstract)
{
Error(diagnostics, ErrorCode.ERR_AbstractBaseCall, SyntaxNodeOrToken.op_Implicit(node), propertyOrEventSymbolOpt ?? member);
return true;
}
return false;
}
private static void ReportReadonlyLocalError(SyntaxNode node, LocalSymbol local, BindValueKind kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
MessageID id;
if (local.IsForEach)
{
id = MessageID.IDS_FOREACHLOCAL;
}
else if (local.IsUsing)
{
id = MessageID.IDS_USINGLOCAL;
}
else
{
if (!local.IsFixed)
{
Error(diagnostics, GetStandardLvalueError(kind), SyntaxNodeOrToken.op_Implicit(node));
return;
}
id = MessageID.IDS_FIXEDLOCAL;
}
ErrorCode[] array = new ErrorCode[4]
{
ErrorCode.ERR_RefReadonlyLocalCause,
ErrorCode.ERR_AssgReadonlyLocalCause,
ErrorCode.ERR_RefReadonlyLocal2Cause,
ErrorCode.ERR_AssgReadonlyLocal2Cause
};
int num = (checkingReceiver ? 2 : 0) + ((!RequiresRefOrOut(kind)) ? 1 : 0);
Error(diagnostics, array[num], SyntaxNodeOrToken.op_Implicit(node), local, id.Localize());
}
private static ErrorCode GetThisLvalueError(BindValueKind kind, bool isValueType, bool isPrimaryConstructorParameter)
{
switch (kind)
{
case BindValueKind.Assignable:
case BindValueKind.CompoundAssignment:
return ErrorCode.ERR_AssgReadonlyLocal;
case BindValueKind.RefOrOut:
return ErrorCode.ERR_RefReadonlyLocal;
case BindValueKind.AddressOf:
return ErrorCode.ERR_InvalidAddrOp;
case BindValueKind.IncrementDecrement:
if (!isValueType)
{
return ErrorCode.ERR_IncrementLvalueExpected;
}
return ErrorCode.ERR_AssgReadonlyLocal;
case BindValueKind.ReadonlyRef:
case BindValueKind.RefReturn:
if (!isPrimaryConstructorParameter)
{
return ErrorCode.ERR_RefReturnThis;
}
return ErrorCode.ERR_RefReturnPrimaryConstructorParameter;
case BindValueKind.RefAssignable:
return ErrorCode.ERR_RefLocalOrParamExpected;
default:
if (RequiresReferenceToLocation(kind))
{
return ErrorCode.ERR_RefLvalueExpected;
}
throw ExceptionUtilities.UnexpectedValue((object)kind);
}
}
private static ErrorCode GetRangeLvalueError(BindValueKind kind)
{
switch (kind)
{
case BindValueKind.Assignable:
case BindValueKind.CompoundAssignment:
case BindValueKind.IncrementDecrement:
return ErrorCode.ERR_QueryRangeVariableReadOnly;
case BindValueKind.AddressOf:
return ErrorCode.ERR_InvalidAddrOp;
case BindValueKind.ReadonlyRef:
case BindValueKind.RefReturn:
return ErrorCode.ERR_RefReturnRangeVariable;
case BindValueKind.RefAssignable:
return ErrorCode.ERR_RefLocalOrParamExpected;
default:
if (RequiresReferenceToLocation(kind))
{
return ErrorCode.ERR_QueryOutRefRangeVariable;
}
throw ExceptionUtilities.UnexpectedValue((object)kind);
}
}
private static ErrorCode GetMethodGroupOrFunctionPointerLvalueError(BindValueKind valueKind)
{
if (RequiresReferenceToLocation(valueKind))
{
return ErrorCode.ERR_RefReadonlyLocalCause;
}
return ErrorCode.ERR_AssgReadonlyLocalCause;
}
private static ErrorCode GetStandardLvalueError(BindValueKind kind)
{
switch (kind)
{
case BindValueKind.Assignable:
case BindValueKind.CompoundAssignment:
return ErrorCode.ERR_AssgLvalueExpected;
case BindValueKind.AddressOf:
return ErrorCode.ERR_InvalidAddrOp;
case BindValueKind.IncrementDecrement:
return ErrorCode.ERR_IncrementLvalueExpected;
case BindValueKind.FixedReceiver:
return ErrorCode.ERR_FixedNeedsLvalue;
case BindValueKind.ReadonlyRef:
case BindValueKind.RefReturn:
return ErrorCode.ERR_RefReturnLvalueExpected;
case BindValueKind.RefAssignable:
return ErrorCode.ERR_RefLocalOrParamExpected;
default:
if (RequiresReferenceToLocation(kind))
{
return ErrorCode.ERR_RefLvalueExpected;
}
throw ExceptionUtilities.UnexpectedValue((object)kind);
}
}
private static void ReportReadOnlyFieldError(FieldSymbol field, SyntaxNode node, BindValueKind kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
ErrorCode[] array = new ErrorCode[12]
{
ErrorCode.ERR_RefReturnReadonly,
ErrorCode.ERR_RefReadonly,
ErrorCode.ERR_AssgReadonly,
ErrorCode.ERR_RefReturnReadonlyStatic,
ErrorCode.ERR_RefReadonlyStatic,
ErrorCode.ERR_AssgReadonlyStatic,
ErrorCode.ERR_RefReturnReadonly2,
ErrorCode.ERR_RefReadonly2,
ErrorCode.ERR_AssgReadonly2,
ErrorCode.ERR_RefReturnReadonlyStatic2,
ErrorCode.ERR_RefReadonlyStatic2,
ErrorCode.ERR_AssgReadonlyStatic2
};
int num = (checkingReceiver ? 6 : 0) + (field.IsStatic ? 3 : 0) + ((kind != BindValueKind.RefReturn) ? (RequiresRefOrOut(kind) ? 1 : 2) : 0);
if (checkingReceiver)
{
Error(diagnostics, array[num], SyntaxNodeOrToken.op_Implicit(node), field);
}
else
{
Error(diagnostics, array[num], SyntaxNodeOrToken.op_Implicit(node));
}
}
private static void ReportReadOnlyError(Symbol symbol, SyntaxNode node, BindValueKind kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
if (kind == BindValueKind.AddressOf)
{
Error(diagnostics, ErrorCode.ERR_InvalidAddrOp, SyntaxNodeOrToken.op_Implicit(node));
return;
}
LocalizableErrorArgument localizableErrorArgument = symbol.Kind.Localize();
ErrorCode[] array = new ErrorCode[6]
{
ErrorCode.ERR_RefReturnReadonlyNotField,
ErrorCode.ERR_RefReadonlyNotField,
ErrorCode.ERR_AssignReadonlyNotField,
ErrorCode.ERR_RefReturnReadonlyNotField2,
ErrorCode.ERR_RefReadonlyNotField2,
ErrorCode.ERR_AssignReadonlyNotField2
};
int num = (checkingReceiver ? 3 : 0) + ((kind != BindValueKind.RefReturn) ? (RequiresRefOrOut(kind) ? 1 : 2) : 0);
Error(diagnostics, array[num], SyntaxNodeOrToken.op_Implicit(node), localizableErrorArgument, (object)new FormattedSymbol((ISymbolInternal)(object)symbol, SymbolDisplayFormat.ShortFormat));
}
internal static bool IsAnyReadOnly(AddressKind addressKind)
{
return addressKind >= AddressKind.ReadOnly;
}
internal static bool HasHome(BoundExpression expression, AddressKind addressKind, Symbol containingSymbol, bool peVerifyCompatEnabled, HashSet<LocalSymbol> stackLocalsOpt)
{
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Invalid comparison between Unknown and I4
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Invalid comparison between Unknown and I4
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Invalid comparison between Unknown and I4
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Invalid comparison between Unknown and I4
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Invalid comparison between Unknown and I4
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Invalid comparison between Unknown and I4
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Invalid comparison between Unknown and I4
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Invalid comparison between Unknown and I4
switch (expression.Kind)
{
case BoundKind.ArrayAccess:
if (addressKind == AddressKind.ReadOnly && !expression.Type.IsValueType && peVerifyCompatEnabled)
{
return false;
}
return true;
case BoundKind.PointerIndirectionOperator:
case BoundKind.RefValueOperator:
return true;
case BoundKind.ThisReference:
if (expression.Type.IsReferenceType)
{
return true;
}
if (!IsAnyReadOnly(addressKind) && containingSymbol is MethodSymbol methodSymbol && containingSymbol.ContainingSymbol is NamedTypeSymbol && methodSymbol.IsEffectivelyReadOnly)
{
return false;
}
return true;
case BoundKind.ThrowExpression:
return true;
case BoundKind.Parameter:
{
bool flag = IsAnyReadOnly(addressKind);
if (!flag)
{
RefKind refKind4 = ((BoundParameter)expression).ParameterSymbol.RefKind;
bool flag2 = refKind4 - 3 <= 1;
flag = !flag2;
}
return flag;
}
case BoundKind.Local:
{
LocalSymbol localSymbol = ((BoundLocal)expression).LocalSymbol;
if (!CodeGenerator.IsStackLocal(localSymbol, stackLocalsOpt) || (int)localSymbol.RefKind != 0)
{
if (!IsAnyReadOnly(addressKind))
{
return (int)localSymbol.RefKind != 3;
}
return true;
}
return false;
}
case BoundKind.Call:
{
RefKind refKind = ((BoundCall)expression).Method.RefKind;
if ((int)refKind != 1)
{
if (IsAnyReadOnly(addressKind))
{
return (int)refKind == 3;
}
return false;
}
return true;
}
case BoundKind.Dup:
{
RefKind refKind3 = ((BoundDup)expression).RefKind;
if ((int)refKind3 != 1)
{
if (IsAnyReadOnly(addressKind))
{
return (int)refKind3 == 3;
}
return false;
}
return true;
}
case BoundKind.FieldAccess:
return FieldAccessHasHome((BoundFieldAccess)expression, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt);
case BoundKind.Sequence:
return HasHome(((BoundSequence)expression).Value, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt);
case BoundKind.AssignmentOperator:
{
BoundAssignmentOperator boundAssignmentOperator = (BoundAssignmentOperator)expression;
if (!boundAssignmentOperator.IsRef)
{
return false;
}
RefKind refKind2 = boundAssignmentOperator.Left.GetRefKind();
bool flag = (int)refKind2 == 1;
if (!flag)
{
bool flag2 = IsAnyReadOnly(addressKind);
if (flag2)
{
bool flag3 = refKind2 - 3 <= 1;
flag2 = flag3;
}
flag = flag2;
}
return flag;
}
case BoundKind.ConditionalReceiver:
case BoundKind.ComplexConditionalReceiver:
return true;
case BoundKind.ConditionalOperator:
{
BoundConditionalOperator boundConditionalOperator = (BoundConditionalOperator)expression;
if (!boundConditionalOperator.IsRef)
{
return false;
}
if (HasHome(boundConditionalOperator.Consequence, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt))
{
return HasHome(boundConditionalOperator.Alternative, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt);
}
return false;
}
default:
return false;
}
}
private static bool FieldAccessHasHome(BoundFieldAccess fieldAccess, AddressKind addressKind, Symbol containingSymbol, bool peVerifyCompatEnabled, HashSet<LocalSymbol> stackLocalsOpt)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Invalid comparison between Unknown and I4
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Invalid comparison between Unknown and I4
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Invalid comparison between Unknown and I4
FieldSymbol fieldSymbol = fieldAccess.FieldSymbol;
if (fieldSymbol.IsConst)
{
return false;
}
if ((int)fieldSymbol.RefKind == 1)
{
return true;
}
switch (addressKind)
{
case AddressKind.ReadOnlyStrict:
return true;
case AddressKind.ReadOnly:
if (!peVerifyCompatEnabled)
{
return true;
}
break;
}
if (fieldAccess.IsByValue)
{
return false;
}
if ((int)fieldSymbol.RefKind == 3)
{
return false;
}
if (!fieldSymbol.IsReadOnly)
{
if (!peVerifyCompatEnabled)
{
BoundExpression receiverOpt = fieldAccess.ReceiverOpt;
if (receiverOpt != null && receiverOpt.Type.IsValueType)
{
if (!HasHome(receiverOpt, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt))
{
return !HasHome(receiverOpt, AddressKind.ReadOnly, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt);
}
return true;
}
}
return true;
}
if (!TypeSymbol.Equals(fieldSymbol.ContainingType, containingSymbol.ContainingSymbol as NamedTypeSymbol, (TypeCompareKind)63))
{
return false;
}
if (fieldSymbol.IsStatic)
{
if (containingSymbol is MethodSymbol methodSymbol)
{
if ((int)methodSymbol.MethodKind == 14)
{
goto IL_00cc;
}
}
else if (containingSymbol is FieldSymbol && containingSymbol.IsStatic)
{
goto IL_00cc;
}
return false;
}
if (containingSymbol is MethodSymbol methodSymbol2)
{
if ((int)methodSymbol2.MethodKind == 1 || methodSymbol2.IsInitOnly)
{
goto IL_0101;
}
}
else if (containingSymbol is FieldSymbol && !containingSymbol.IsStatic)
{
goto IL_0101;
}
bool flag = false;
goto IL_0107;
IL_00cc:
return true;
IL_0101:
flag = true;
goto IL_0107;
IL_0107:
if (flag)
{
return fieldAccess.ReceiverOpt.Kind == BoundKind.ThisReference;
}
return false;
}
private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Invalid comparison between Unknown and I4
MessageID.IDS_FeatureAnonymousTypes.CheckFeatureAvailability(diagnostics, node.NewKeyword);
SeparatedSyntaxList<AnonymousObjectMemberDeclaratorSyntax> initializers = node.Initializers;
int count = initializers.Count;
bool hasError = false;
BoundExpression[] array = new BoundExpression[count];
AnonymousTypeField[] array2 = new AnonymousTypeField[count];
CSharpSyntaxNode[] array3 = new CSharpSyntaxNode[count];
PooledHashSet<string> instance = PooledHashSet<string>.GetInstance();
for (int i = 0; i < count; i++)
{
AnonymousObjectMemberDeclaratorSyntax anonymousObjectMemberDeclaratorSyntax = initializers[i];
NameEqualsSyntax nameEquals = anonymousObjectMemberDeclaratorSyntax.NameEquals;
ExpressionSyntax expression = anonymousObjectMemberDeclaratorSyntax.Expression;
SyntaxToken token = default(SyntaxToken);
if (nameEquals != null)
{
token = nameEquals.Name.Identifier;
}
else
{
if (!IsAnonymousTypeMemberExpression(expression))
{
hasError = true;
diagnostics.Add(ErrorCode.ERR_InvalidAnonymousTypeMemberDeclarator, expression.GetLocation());
}
token = expression.ExtractAnonymousTypeMemberName();
}
hasError |= ((SyntaxNode)expression).HasErrors;
array[i] = BindRValueWithoutTargetType(expression, diagnostics);
string text = null;
if (token.Kind() == SyntaxKind.IdentifierToken)
{
text = ((SyntaxToken)(ref token)).ValueText;
if (!((HashSet<string>)(object)instance).Add(text))
{
Error(diagnostics, ErrorCode.ERR_AnonymousTypeDuplicatePropertyName, (CSharpSyntaxNode)anonymousObjectMemberDeclaratorSyntax);
hasError = true;
text = null;
}
}
else
{
hasError = true;
}
TypeSymbol anonymousTypeFieldType = GetAnonymousTypeFieldType(array[i], anonymousObjectMemberDeclaratorSyntax, diagnostics, ref hasError);
array3[i] = ((token.Kind() == SyntaxKind.IdentifierToken) ? ((CSharpSyntaxNode)(object)((SyntaxToken)(ref token)).Parent) : anonymousObjectMemberDeclaratorSyntax);
array2[i] = new AnonymousTypeField((text == null) ? ("$" + i) : text, ((SyntaxNode)array3[i]).Location, TypeWithAnnotations.Create(anonymousTypeFieldType), (RefKind)0, (ScopedKind)0);
}
instance.Free();
AnonymousTypeManager anonymousTypeManager = Compilation.AnonymousTypeManager;
ImmutableArray<AnonymousTypeField> fields = ImmutableArrayExtensions.AsImmutableOrNull<AnonymousTypeField>(array2);
SyntaxToken newKeyword = node.NewKeyword;
AnonymousTypeDescriptor typeDescr = new AnonymousTypeDescriptor(fields, ((SyntaxToken)(ref newKeyword)).GetLocation());
NamedTypeSymbol namedTypeSymbol = anonymousTypeManager.ConstructAnonymousTypeSymbol(typeDescr);
ArrayBuilder<BoundAnonymousPropertyDeclaration> instance2 = ArrayBuilder<BoundAnonymousPropertyDeclaration>.GetInstance();
for (int j = 0; j < count; j++)
{
if (initializers[j].NameEquals == null)
{
continue;
}
AnonymousTypeField anonymousTypeField = array2[j];
if (anonymousTypeField.Name == null)
{
continue;
}
ImmutableArray<Symbol>.Enumerator enumerator = namedTypeSymbol.GetMembers(anonymousTypeField.Name).GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
if ((int)current.Kind == 15)
{
instance2.Add(new BoundAnonymousPropertyDeclaration((SyntaxNode)(object)array3[j], (PropertySymbol)current, anonymousTypeField.Type));
break;
}
}
}
if (!IsAnonymousTypesAllowed())
{
Error(diagnostics, ErrorCode.ERR_AnonymousTypeNotAvailable, node.NewKeyword);
hasError = true;
}
return new BoundAnonymousObjectCreationExpression((SyntaxNode)(object)node, namedTypeSymbol.InstanceConstructors[0], ImmutableArrayExtensions.AsImmutableOrNull<BoundExpression>(array), instance2.ToImmutableAndFree(), namedTypeSymbol, hasError);
}
private static bool IsAnonymousTypeMemberExpression(ExpressionSyntax expr)
{
while (true)
{
switch (expr.Kind())
{
case SyntaxKind.QualifiedName:
expr = ((QualifiedNameSyntax)expr).Right;
break;
case SyntaxKind.ConditionalAccessExpression:
expr = ((ConditionalAccessExpressionSyntax)expr).WhenNotNull;
if (expr.Kind() == SyntaxKind.MemberBindingExpression)
{
return true;
}
break;
case SyntaxKind.IdentifierName:
case SyntaxKind.SimpleMemberAccessExpression:
return true;
default:
return false;
}
}
}
private bool IsAnonymousTypesAllowed()
{
//IL_000d: 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_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Invalid comparison between Unknown and I4
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
Symbol containingMemberOrLambda = ContainingMemberOrLambda;
if ((object)containingMemberOrLambda == null)
{
return false;
}
SymbolKind kind = containingMemberOrLambda.Kind;
if ((int)kind != 6)
{
if ((int)kind != 9)
{
if ((int)kind == 11)
{
return ((NamedTypeSymbol)containingMemberOrLambda).IsScriptClass;
}
return false;
}
return true;
}
return !((FieldSymbol)containingMemberOrLambda).IsConst;
}
private TypeSymbol GetAnonymousTypeFieldType(BoundExpression expression, CSharpSyntaxNode errorSyntax, BindingDiagnosticBag diagnostics, ref bool hasError)
{
object obj = null;
TypeSymbol typeSymbol = expression.Type;
if (!expression.HasAnyErrors)
{
if (expression.HasExpressionType())
{
if (typeSymbol.IsVoidType())
{
obj = typeSymbol;
typeSymbol = CreateErrorType(SyntaxFacts.GetText(SyntaxKind.VoidKeyword));
}
else if (typeSymbol.IsPointerOrFunctionPointer())
{
obj = typeSymbol;
}
else if (typeSymbol.IsRestrictedType())
{
obj = typeSymbol;
}
}
else
{
obj = expression.Display;
}
}
if ((object)typeSymbol == null)
{
typeSymbol = CreateErrorType("error");
}
if (obj != null)
{
hasError = true;
Error(diagnostics, ErrorCode.ERR_AnonymousTypePropertyAssignedBadValue, errorSyntax, obj);
}
return typeSymbol;
}
internal static void BindAttributeTypes(ImmutableArray<Binder> binders, ImmutableArray<AttributeSyntax> attributesToBind, Symbol ownerSymbol, NamedTypeSymbol[] boundAttributeTypes, Action<AttributeSyntax>? beforeAttributePartBound, Action<AttributeSyntax>? afterAttributePartBound, BindingDiagnosticBag diagnostics)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Invalid comparison between Unknown and I4
for (int i = 0; i < attributesToBind.Length; i++)
{
if ((object)boundAttributeTypes[i] == null)
{
Binder binder = binders[i];
AttributeSyntax attributeSyntax = attributesToBind[i];
beforeAttributePartBound?.Invoke(attributeSyntax);
TypeWithAnnotations typeArgument = binder.BindType(attributeSyntax.Name, diagnostics);
NamedTypeSymbol namedTypeSymbol = (NamedTypeSymbol)typeArgument.Type;
if ((int)namedTypeSymbol.TypeKind != 6)
{
binder.CheckDisallowedAttributeDependentType(typeArgument, attributeSyntax.Name, diagnostics);
}
boundAttributeTypes[i] = namedTypeSymbol;
afterAttributePartBound?.Invoke(attributeSyntax);
}
}
}
internal static void GetAttributes(ImmutableArray<Binder> binders, ImmutableArray<AttributeSyntax> attributesToBind, ImmutableArray<NamedTypeSymbol> boundAttributeTypes, CSharpAttributeData?[] attributeDataArray, BoundAttribute?[]? boundAttributeArray, Action<AttributeSyntax>? beforeAttributePartBound, Action<AttributeSyntax>? afterAttributePartBound, BindingDiagnosticBag diagnostics)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < attributesToBind.Length; i++)
{
AttributeSyntax attributeSyntax = attributesToBind[i];
NamedTypeSymbol boundAttributeType = boundAttributeTypes[i];
Binder binder = binders[i];
SourceAttributeData sourceAttributeData = (SourceAttributeData)attributeDataArray[i];
if (sourceAttributeData == null)
{
int num = i;
(CSharpAttributeData, BoundAttribute) attribute = binder.GetAttribute(attributeSyntax, boundAttributeType, beforeAttributePartBound, afterAttributePartBound, diagnostics);
attributeDataArray[num] = attribute.Item1;
BoundAttribute item = attribute.Item2;
if (boundAttributeArray != null)
{
boundAttributeArray[i] = item;
}
}
else
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = binder.GetNewCompoundUseSiteInfo(diagnostics);
bool isConditionallyOmitted = binder.IsAttributeConditionallyOmitted(sourceAttributeData.AttributeClass, attributeSyntax.SyntaxTree, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)attributeSyntax, useSiteInfo);
attributeDataArray[i] = sourceAttributeData.WithOmittedCondition(isConditionallyOmitted);
}
}
}
internal (CSharpAttributeData, BoundAttribute) GetAttribute(AttributeSyntax node, NamedTypeSymbol boundAttributeType, Action<AttributeSyntax>? beforeAttributePartBound, Action<AttributeSyntax>? afterAttributePartBound, BindingDiagnosticBag diagnostics)
{
beforeAttributePartBound?.Invoke(node);
BoundAttribute boundAttribute = new ExecutableCodeBinder((SyntaxNode)(object)node, ContainingMemberOrLambda, this).BindAttribute(node, boundAttributeType, (this as ContextualAttributeBinder)?.AttributedMember, diagnostics);
afterAttributePartBound?.Invoke(node);
return (GetAttribute(boundAttribute, diagnostics), boundAttribute);
}
internal BoundAttribute BindAttribute(AttributeSyntax node, NamedTypeSymbol attributeType, Symbol? attributedMember, BindingDiagnosticBag diagnostics)
{
return GetRequiredBinder((SyntaxNode)(object)node).BindAttributeCore(node, attributeType, attributedMember, diagnostics);
}
private Binder SkipSemanticModelBinder()
{
Binder binder = this;
while (binder.IsSemanticModelBinder)
{
binder = binder.Next;
}
return binder;
}
private BoundAttribute BindAttributeCore(AttributeSyntax node, NamedTypeSymbol attributeType, Symbol? attributedMember, BindingDiagnosticBag diagnostics)
{
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol namedTypeSymbol = attributeType;
LookupResultKind lookupResultKind = LookupResultKind.Viable;
if (namedTypeSymbol.IsErrorType())
{
ErrorTypeSymbol errorTypeSymbol = (ErrorTypeSymbol)namedTypeSymbol;
lookupResultKind = errorTypeSymbol.ResultKind;
if (errorTypeSymbol.CandidateSymbols.Length == 1 && errorTypeSymbol.CandidateSymbols[0] is NamedTypeSymbol)
{
namedTypeSymbol = (NamedTypeSymbol)errorTypeSymbol.CandidateSymbols[0];
}
}
AttributeArgumentListSyntax argumentList = node.ArgumentList;
Binder binder = WithAdditionalFlags(BinderFlags.AttributeArgument);
AnalyzedAttributeArguments analyzedAttributeArguments = binder.BindAttributeArguments(argumentList, namedTypeSymbol, diagnostics);
ImmutableArray<int> argsToParamsOpt = default(ImmutableArray<int>);
bool flag = false;
BitVector defaultArguments = default(BitVector);
MethodSymbol methodSymbol = null;
ImmutableArray<BoundExpression> constructorArguments;
if (namedTypeSymbol.IsErrorType())
{
constructorArguments = ArrayBuilderExtensions.SelectAsArray<BoundExpression, Binder, BoundExpression>(analyzedAttributeArguments.ConstructorArguments.Arguments, (Func<BoundExpression, Binder, BoundExpression>)((BoundExpression arg, Binder attributeArgumentBinder) => attributeArgumentBinder.BindToTypeForErrorRecovery(arg)), binder);
}
else
{
MemberResolutionResult<MethodSymbol> memberResolutionResult;
ImmutableArray<MethodSymbol> candidateConstructors;
bool num = binder.TryPerformConstructorOverloadResolution(namedTypeSymbol, analyzedAttributeArguments.ConstructorArguments, namedTypeSymbol.Name, ((SyntaxNode)node).Location, attributeType.IsErrorType(), diagnostics, out memberResolutionResult, out candidateConstructors, allowProtectedConstructorsOfBaseType: true, suppressUnsupportedRequiredMembersError: false);
methodSymbol = memberResolutionResult.Member;
flag = memberResolutionResult.Resolution == MemberResolutionKind.ApplicableInExpandedForm;
argsToParamsOpt = memberResolutionResult.Result.ArgsToParamsOpt;
if (!num)
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = binder.GetNewCompoundUseSiteInfo(diagnostics);
lookupResultKind = lookupResultKind.WorseResultKind((memberResolutionResult.IsValid && !binder.IsConstructorAccessible(memberResolutionResult.Member, ref useSiteInfo)) ? LookupResultKind.Inaccessible : LookupResultKind.OverloadResolutionFailure);
constructorArguments = binder.BuildArgumentsForErrorRecovery(analyzedAttributeArguments.ConstructorArguments, candidateConstructors);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
}
else
{
binder.BindDefaultArguments((SyntaxNode)(object)node, methodSymbol.Parameters, analyzedAttributeArguments.ConstructorArguments.Arguments, null, ref argsToParamsOpt, out defaultArguments, flag, !IsEarlyAttributeBinder, diagnostics, assertMissingParametersAreOptional: true, attributedMember);
constructorArguments = analyzedAttributeArguments.ConstructorArguments.Arguments.ToImmutable();
binder.ReportDiagnosticsIfObsolete(diagnostics, methodSymbol, SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)node), hasBaseReceiver: false);
if (methodSymbol.Parameters.Any(delegate(ParameterSymbol p)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
RefKind refKind = p.RefKind;
return refKind - 3 <= 1;
}))
{
Error(diagnostics, ErrorCode.ERR_AttributeCtorInParameter, (CSharpSyntaxNode)node, new object[1] { methodSymbol.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat) });
}
}
}
ImmutableArray<string> names = analyzedAttributeArguments.ConstructorArguments.GetNames();
ImmutableArray<BoundAssignmentOperator> immutableArray = analyzedAttributeArguments.NamedArguments?.ToImmutableAndFree() ?? ImmutableArray<BoundAssignmentOperator>.Empty;
if ((object)methodSymbol != null)
{
CheckRequiredMembersInObjectInitializer(methodSymbol, ImmutableArray<BoundExpression>.CastUp(immutableArray), (SyntaxNode)(object)node, diagnostics);
}
analyzedAttributeArguments.ConstructorArguments.Free();
return new BoundAttribute((SyntaxNode)(object)node, methodSymbol, constructorArguments, names, argsToParamsOpt, flag, defaultArguments, immutableArray, lookupResultKind, attributeType, lookupResultKind != LookupResultKind.Viable);
}
private CSharpAttributeData GetAttribute(BoundAttribute boundAttribute, BindingDiagnosticBag diagnostics)
{
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol namedTypeSymbol = (NamedTypeSymbol)boundAttribute.Type;
MethodSymbol constructor = boundAttribute.Constructor;
bool hasErrors = boundAttribute.HasAnyErrors;
if (namedTypeSymbol.IsErrorType() || namedTypeSymbol.IsAbstract || (object)constructor == null)
{
return new SourceAttributeData(boundAttribute.Syntax.GetReference(), namedTypeSymbol, constructor, hasErrors);
}
ValidateTypeForAttributeParameters(constructor.Parameters, ((AttributeSyntax)(object)boundAttribute.Syntax).Name, diagnostics, ref hasErrors);
AttributeExpressionVisitor attributeExpressionVisitor = new AttributeExpressionVisitor(this);
ImmutableArray<BoundExpression> arguments = boundAttribute.ConstructorArguments;
ImmutableArray<TypedConstant> immutableArray = attributeExpressionVisitor.VisitArguments(arguments, diagnostics, ref hasErrors);
ImmutableArray<KeyValuePair<string, TypedConstant>> namedArguments = attributeExpressionVisitor.VisitNamedArguments(boundAttribute.NamedArguments, diagnostics, ref hasErrors);
ImmutableArray<int> argsToParamsOpt = boundAttribute.ConstructorArgumentsToParamsOpt;
ImmutableArray<TypedConstant> rewrittenArguments;
if (hasErrors || constructor.ParameterCount == 0)
{
rewrittenArguments = immutableArray;
}
else
{
rewrittenArguments = GetRewrittenAttributeConstructorArguments(constructor, immutableArray, boundAttribute.ConstructorArgumentNamesOpt, (AttributeSyntax)(object)boundAttribute.Syntax, argsToParamsOpt, diagnostics, boundAttribute.ConstructorExpanded, ref hasErrors);
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
bool isConditionallyOmitted = IsAttributeConditionallyOmitted(namedTypeSymbol, boundAttribute.SyntaxTree, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(boundAttribute.Syntax, useSiteInfo);
return new SourceAttributeData(boundAttribute.Syntax.GetReference(), namedTypeSymbol, constructor, rewrittenArguments, makeSourceIndices(), namedArguments, hasErrors, isConditionallyOmitted);
ImmutableArray<int> makeSourceIndices()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
int length = rewrittenArguments.Length;
if (length == 0 || hasErrors)
{
return default(ImmutableArray<int>);
}
BitVector constructorDefaultArguments = boundAttribute.ConstructorDefaultArguments;
if (argsToParamsOpt.IsDefault && !boundAttribute.ConstructorExpanded)
{
bool flag = false;
int length2 = arguments.Length;
for (int i = 0; i < length2; i++)
{
if (((BitVector)(ref constructorDefaultArguments))[i])
{
flag = true;
break;
}
}
if (!flag)
{
return default(ImmutableArray<int>);
}
}
ArrayBuilder<int> instance = ArrayBuilder<int>.GetInstance(length);
instance.Count = length;
for (int j = 0; j < length; j++)
{
int num = ((argsToParamsOpt.IsDefault || j >= argsToParamsOpt.Length) ? j : argsToParamsOpt[j]);
instance[num] = (((BitVector)(ref constructorDefaultArguments))[j] ? (-1) : j);
}
return instance.ToImmutableAndFree();
}
}
private void ValidateTypeForAttributeParameters(ImmutableArray<ParameterSymbol> parameters, CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics, ref bool hasErrors)
{
ImmutableArray<ParameterSymbol>.Enumerator enumerator = parameters.GetEnumerator();
while (enumerator.MoveNext())
{
ParameterSymbol current = enumerator.Current;
TypeWithAnnotations typeWithAnnotations = current.TypeWithAnnotations;
if (!typeWithAnnotations.Type.IsValidAttributeParameterType(Compilation))
{
Error(diagnostics, ErrorCode.ERR_BadAttributeParamType, syntax, current.Name, typeWithAnnotations.Type);
hasErrors = true;
}
}
}
protected bool IsAttributeConditionallyOmitted(NamedTypeSymbol attributeType, SyntaxTree? syntaxTree, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
if (IsEarlyAttributeBinder)
{
return false;
}
if (attributeType.IsConditional)
{
ImmutableArray<string> appliedConditionalSymbols = attributeType.GetAppliedConditionalSymbols();
if (syntaxTree.IsAnyPreprocessorSymbolDefined(appliedConditionalSymbols))
{
return false;
}
NamedTypeSymbol namedTypeSymbol = attributeType.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteInfo);
if ((object)namedTypeSymbol != null && namedTypeSymbol.IsConditional)
{
return IsAttributeConditionallyOmitted(namedTypeSymbol, syntaxTree, ref useSiteInfo);
}
return true;
}
return false;
}
private AnalyzedAttributeArguments BindAttributeArguments(AttributeArgumentListSyntax? attributeArgumentList, NamedTypeSymbol attributeType, BindingDiagnosticBag diagnostics)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
ArrayBuilder<BoundAssignmentOperator> val = null;
if (attributeArgumentList != null)
{
HashSet<string> hashSet = null;
bool hadLangVersionError = false;
bool flag = false;
Enumerator<AttributeArgumentSyntax> enumerator = attributeArgumentList.Arguments.GetEnumerator();
while (enumerator.MoveNext())
{
AttributeArgumentSyntax current = enumerator.Current;
if (current.NameEquals == null)
{
if (flag)
{
diagnostics.Add(ErrorCode.ERR_NamedArgumentExpected, current.Expression.GetLocation());
}
BindArgumentAndName(instance, diagnostics, ref hadLangVersionError, current, BindArgumentExpression(diagnostics, current.Expression, (RefKind)0, allowArglist: false), current.NameColon, (RefKind)0);
continue;
}
flag = true;
SyntaxToken identifier = current.NameEquals.Name.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
if (val == null)
{
val = ArrayBuilder<BoundAssignmentOperator>.GetInstance();
hashSet = new HashSet<string>();
}
else if (hashSet.Contains(valueText))
{
Error(diagnostics, ErrorCode.ERR_DuplicateNamedAttributeArgument, (CSharpSyntaxNode)current, new object[1] { valueText });
}
BoundAssignmentOperator boundAssignmentOperator = BindNamedAttributeArgument(current, attributeType, diagnostics);
val.Add(boundAssignmentOperator);
hashSet.Add(valueText);
}
}
return new AnalyzedAttributeArguments(instance, val);
}
private BoundAssignmentOperator BindNamedAttributeArgument(AttributeArgumentSyntax namedArgument, NamedTypeSymbol attributeType, BindingDiagnosticBag diagnostics)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Invalid comparison between Unknown and I4
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
IdentifierNameSyntax name = namedArgument.NameEquals.Name;
if (attributeType.IsErrorType())
{
BoundBadExpression left = BadExpression((SyntaxNode)(object)name, LookupResultKind.Empty);
BoundExpression right = BindRValueWithoutTargetType(namedArgument.Expression, diagnostics);
return new BoundAssignmentOperator((SyntaxNode)(object)namedArgument, left, right, CreateErrorType());
}
bool wasError;
LookupResultKind resultKind;
Symbol symbol = BindNamedAttributeArgumentName(namedArgument, attributeType, diagnostics, out wasError, out resultKind);
ReportDiagnosticsIfObsolete(diagnostics, symbol, SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)namedArgument), hasBaseReceiver: false);
if ((int)symbol.Kind == 15)
{
MethodSymbol ownOrInheritedSetMethod = ((PropertySymbol)symbol).GetOwnOrInheritedSetMethod();
if (ownOrInheritedSetMethod != null)
{
ReportDiagnosticsIfObsolete(diagnostics, ownOrInheritedSetMethod, SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)namedArgument), hasBaseReceiver: false);
if (ownOrInheritedSetMethod.IsInitOnly && ownOrInheritedSetMethod.DeclaringCompilation != Compilation)
{
CheckFeatureAvailability((SyntaxNode)(object)namedArgument, MessageID.IDS_FeatureInitOnlySetters, diagnostics);
}
}
}
TypeSymbol typeSymbol = ((!wasError) ? BindNamedAttributeArgumentType(namedArgument, symbol, attributeType, diagnostics) : CreateErrorType());
BoundExpression expression = BindValue(namedArgument.Expression, diagnostics, BindValueKind.RValue);
expression = GenerateConversionForAssignment(typeSymbol, expression, diagnostics);
BoundExpression left2;
if (symbol is FieldSymbol fieldSymbol)
{
(fieldSymbol.ContainingAssembly as SourceAssemblySymbol)?.NoteFieldAccess(fieldSymbol, read: true, write: true);
left2 = new BoundFieldAccess((SyntaxNode)(object)name, null, fieldSymbol, null, resultKind, fieldSymbol.Type);
}
else
{
left2 = ((!(symbol is PropertySymbol propertySymbol)) ? ((BoundExpression)BadExpression((SyntaxNode)(object)name, resultKind)) : ((BoundExpression)new BoundPropertyAccess((SyntaxNode)(object)name, null, (ThreeState)0, propertySymbol, resultKind, typeSymbol)));
}
return new BoundAssignmentOperator((SyntaxNode)(object)namedArgument, left2, expression, typeSymbol);
}
private Symbol BindNamedAttributeArgumentName(AttributeArgumentSyntax namedArgument, NamedTypeSymbol attributeType, BindingDiagnosticBag diagnostics, out bool wasError, out LookupResultKind resultKind)
{
//IL_000d: 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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
IdentifierNameSyntax name = namedArgument.NameEquals.Name;
SyntaxToken identifier = name.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
LookupResult instance = LookupResult.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupMembersWithFallback(instance, attributeType, valueText, 0, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)name, useSiteInfo);
Symbol result = ResultSymbol(instance, valueText, 0, (SyntaxNode)(object)name, diagnostics, suppressUseSiteDiagnostics: false, out wasError, null);
resultKind = instance.Kind;
instance.Free();
return result;
}
private TypeSymbol BindNamedAttributeArgumentType(AttributeArgumentSyntax namedArgument, Symbol namedArgumentNameSymbol, NamedTypeSymbol attributeType, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Invalid comparison between Unknown and I4
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Invalid comparison between Unknown and I4
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Invalid comparison between Unknown and I4
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Invalid comparison between Unknown and I4
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Invalid comparison between Unknown and I4
if ((int)namedArgumentNameSymbol.Kind == 4)
{
return (TypeSymbol)namedArgumentNameSymbol;
}
bool flag = false;
TypeSymbol typeSymbol = null;
flag |= (int)namedArgumentNameSymbol.DeclaredAccessibility != 6;
flag |= namedArgumentNameSymbol.IsStatic;
if (!flag)
{
SymbolKind kind = namedArgumentNameSymbol.Kind;
if ((int)kind != 6)
{
if ((int)kind == 15)
{
PropertySymbol leastOverriddenProperty = ((PropertySymbol)namedArgumentNameSymbol).GetLeastOverriddenProperty(ContainingType);
typeSymbol = leastOverriddenProperty.Type;
flag |= leastOverriddenProperty.IsReadOnly;
MethodSymbol getMethod = leastOverriddenProperty.GetMethod;
MethodSymbol setMethod = leastOverriddenProperty.SetMethod;
flag = flag || (object)getMethod == null || (object)setMethod == null;
if (!flag)
{
flag = (int)getMethod.DeclaredAccessibility != 6 || (int)setMethod.DeclaredAccessibility != 6;
}
}
else
{
flag = true;
}
}
else
{
FieldSymbol fieldSymbol = (FieldSymbol)namedArgumentNameSymbol;
typeSymbol = fieldSymbol.Type;
flag |= fieldSymbol.IsReadOnly;
flag |= fieldSymbol.IsConst;
}
}
if (flag)
{
return new ExtendedErrorTypeSymbol(attributeType, namedArgumentNameSymbol, LookupResultKind.NotAVariable, (DiagnosticInfo)(object)diagnostics.Add(ErrorCode.ERR_BadNamedAttributeArgument, ((SyntaxNode)namedArgument.NameEquals.Name).Location, namedArgumentNameSymbol.Name));
}
if (!typeSymbol.IsValidAttributeParameterType(Compilation))
{
return new ExtendedErrorTypeSymbol(attributeType, namedArgumentNameSymbol, LookupResultKind.NotAVariable, (DiagnosticInfo)(object)diagnostics.Add(ErrorCode.ERR_BadNamedAttributeArgumentType, ((SyntaxNode)namedArgument.NameEquals.Name).Location, namedArgumentNameSymbol.Name));
}
return typeSymbol;
}
private ImmutableArray<TypedConstant> GetRewrittenAttributeConstructorArguments(MethodSymbol attributeConstructor, ImmutableArray<TypedConstant> constructorArgsArray, ImmutableArray<string?> constructorArgumentNamesOpt, AttributeSyntax syntax, ImmutableArray<int> argumentsToParams, BindingDiagnosticBag diagnostics, bool expanded, ref bool hasErrors)
{
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Invalid comparison between Unknown and I4
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Invalid comparison between Unknown and I4
int length = constructorArgsArray.Length;
ImmutableArray<ParameterSymbol> parameters = attributeConstructor.Parameters;
TypedConstant[] array = (TypedConstant[])(object)new TypedConstant[parameters.Length];
for (int i = 0; i < length; i++)
{
int num = (argumentsToParams.IsDefault ? i : argumentsToParams[i]);
ParameterSymbol parameterSymbol = parameters[num];
TypedConstant val = ((!parameterSymbol.IsParams || !parameterSymbol.Type.IsSZArray()) ? constructorArgsArray[i] : GetParamArrayArgument(parameterSymbol, constructorArgsArray, constructorArgumentNamesOpt, length, i, Conversions, out i));
if (!hasErrors)
{
if ((int)((TypedConstant)(ref val)).Kind == 0)
{
hasErrors = true;
}
else if ((int)((TypedConstant)(ref val)).Kind == 4 && (int)parameterSymbol.Type.TypeKind == 1 && !((TypeSymbol)(object)((TypedConstant)(ref val)).TypeInternal).Equals(parameterSymbol.Type, (TypeCompareKind)63))
{
diagnostics.Add(ErrorCode.ERR_BadAttributeArgument, ((SyntaxNode)syntax).Location);
hasErrors = true;
}
}
array[num] = val;
}
if (expanded && (int)((TypedConstant)(ref array[^1])).Kind == 0)
{
ParameterSymbol parameterSymbol2 = parameters[parameters.Length - 1];
array[^1] = new TypedConstant((ITypeSymbolInternal)(object)parameterSymbol2.Type, ImmutableArray<TypedConstant>.Empty);
}
return ImmutableArrayExtensions.AsImmutable<TypedConstant>(array);
}
private static TypedConstant GetParamArrayArgument(ParameterSymbol parameter, ImmutableArray<TypedConstant> constructorArgsArray, ImmutableArray<string?> constructorArgumentNamesOpt, int argumentsCount, int currentArgumentIndex, Conversions conversions, out int endOfParamsArrayIndex)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
if (!constructorArgumentNamesOpt.IsDefault && constructorArgumentNamesOpt.Contains(parameter.Name))
{
endOfParamsArrayIndex = currentArgumentIndex;
if (TryGetNormalParamValue(parameter, constructorArgsArray, currentArgumentIndex, conversions, out var result))
{
return result;
}
return new TypedConstant((ITypeSymbolInternal)(object)parameter.Type, ImmutableArray.Create<TypedConstant>(constructorArgsArray[currentArgumentIndex]));
}
int num = argumentsCount - currentArgumentIndex;
switch (num)
{
case 0:
endOfParamsArrayIndex = argumentsCount - 1;
return new TypedConstant((ITypeSymbolInternal)(object)parameter.Type, ImmutableArray<TypedConstant>.Empty);
case 1:
{
if (TryGetNormalParamValue(parameter, constructorArgsArray, currentArgumentIndex, conversions, out var result2))
{
endOfParamsArrayIndex = argumentsCount - 1;
return result2;
}
break;
}
}
TypedConstant[] array = (TypedConstant[])(object)new TypedConstant[num];
for (int i = 0; i < num; i++)
{
array[i] = constructorArgsArray[currentArgumentIndex++];
}
endOfParamsArrayIndex = currentArgumentIndex + num - 1;
return new TypedConstant((ITypeSymbolInternal)(object)parameter.Type, ImmutableArrayExtensions.AsImmutableOrNull<TypedConstant>(array));
}
private static bool TryGetNormalParamValue(ParameterSymbol parameter, ImmutableArray<TypedConstant> constructorArgsArray, int argIndex, Conversions conversions, out TypedConstant result)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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)
//IL_0011: Invalid comparison between Unknown and I4
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
TypedConstant val = constructorArgsArray[argIndex];
if ((int)((TypedConstant)(ref val)).Kind != 4)
{
result = default(TypedConstant);
return false;
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
Conversion conversion = conversions.ClassifyBuiltInConversion((TypeSymbol)(object)((TypedConstant)(ref val)).TypeInternal, parameter.Type, isChecked: false, ref useSiteInfo);
if (conversion.IsValid && (conversion.Kind == ConversionKind.ImplicitReference || conversion.Kind == ConversionKind.Identity))
{
result = val;
return true;
}
result = default(TypedConstant);
return false;
}
private BoundExpression BindAwait(AwaitExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureAsync.CheckFeatureAvailability(diagnostics, node.AwaitKeyword);
BoundExpression expression = BindRValueWithoutTargetType(node.Expression, diagnostics);
return BindAwait(expression, (SyntaxNode)(object)node, diagnostics);
}
private BoundAwaitExpression BindAwait(BoundExpression expression, SyntaxNode node, BindingDiagnosticBag diagnostics)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
bool hasErrors = false;
BoundAwaitableValuePlaceholder placeholder = new BoundAwaitableValuePlaceholder(expression.Syntax, expression.Type);
ReportBadAwaitDiagnostics(SyntaxNodeOrToken.op_Implicit(node), diagnostics, ref hasErrors);
BoundAwaitableInfo boundAwaitableInfo = BindAwaitInfo(placeholder, node, diagnostics, ref hasErrors, expression);
TypeSymbol type = boundAwaitableInfo.GetResult?.ReturnType ?? (hasErrors ? CreateErrorType() : Compilation.DynamicType);
return new BoundAwaitExpression(node, expression, boundAwaitableInfo, default(BoundAwaitExpressionDebugInfo), type, hasErrors);
}
internal void ReportBadAwaitDiagnostics(SyntaxNodeOrToken nodeOrToken, BindingDiagnosticBag diagnostics, ref bool hasErrors)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
hasErrors |= ReportBadAwaitWithoutAsync(nodeOrToken, diagnostics);
hasErrors |= ReportBadAwaitContext(nodeOrToken, diagnostics);
}
internal BoundAwaitableInfo BindAwaitInfo(BoundAwaitableValuePlaceholder placeholder, SyntaxNode node, BindingDiagnosticBag diagnostics, ref bool hasErrors, BoundExpression? expressionOpt = null)
{
bool isDynamic;
BoundExpression getAwaiter;
PropertySymbol isCompleted;
MethodSymbol getResult;
BoundExpression getAwaiterGetResultCall;
bool flag = !GetAwaitableExpressionInfo(expressionOpt ?? placeholder, placeholder, out isDynamic, out getAwaiter, out isCompleted, out getResult, out getAwaiterGetResultCall, node, diagnostics);
hasErrors |= flag;
return new BoundAwaitableInfo(node, placeholder, isDynamic, getAwaiter, isCompleted, getResult, flag)
{
WasCompilerGenerated = true
};
}
private bool CouldBeAwaited(BoundExpression expression)
{
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
if (expression.Kind != BoundKind.Call || expression.HasAnyErrors)
{
return false;
}
TypeSymbol type = expression.Type;
if ((object)type == null || type.IsDynamic() || type.IsVoidType())
{
return false;
}
BoundCall boundCall = (BoundCall)expression;
if ((object)boundCall.Method != null && boundCall.Method.IsAsync)
{
return true;
}
if (ImplementsWinRTAsyncInterface(boundCall.Type))
{
return true;
}
if (!(ContainingMemberOrLambda is MethodSymbol methodSymbol) || (!methodSymbol.IsAsync && !(methodSymbol is SynthesizedSimpleProgramEntryPointSymbol)))
{
return false;
}
if (ContextForbidsAwait)
{
return false;
}
SyntaxNode syntax = expression.Syntax;
if (ReportBadAwaitContext(SyntaxNodeOrToken.op_Implicit(syntax), BindingDiagnosticBag.Discarded))
{
return false;
}
BoundExpression getAwaiterGetResultCall;
return GetAwaitableExpressionInfo(expression, out getAwaiterGetResultCall, syntax, BindingDiagnosticBag.Discarded);
}
private bool ReportBadAwaitWithoutAsync(SyntaxNodeOrToken nodeOrToken, BindingDiagnosticBag diagnostics)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Invalid comparison between Unknown and I4
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
DiagnosticInfo val = null;
Symbol containingMemberOrLambda = ContainingMemberOrLambda;
if ((object)containingMemberOrLambda != null)
{
SymbolKind kind = containingMemberOrLambda.Kind;
if ((int)kind != 6)
{
if ((int)kind == 9)
{
MethodSymbol methodSymbol = (MethodSymbol)containingMemberOrLambda;
if (methodSymbol.IsAsync)
{
return false;
}
val = (DiagnosticInfo)(object)(((int)methodSymbol.MethodKind != 0) ? (methodSymbol.ReturnsVoid ? new CSDiagnosticInfo(ErrorCode.ERR_BadAwaitWithoutVoidAsyncMethod) : new CSDiagnosticInfo(ErrorCode.ERR_BadAwaitWithoutAsyncMethod, methodSymbol.ReturnType)) : (methodSymbol.IsImplicitlyDeclared ? new CSDiagnosticInfo(ErrorCode.ERR_BadAwaitInQuery) : new CSDiagnosticInfo(ErrorCode.ERR_BadAwaitWithoutAsyncLambda, ((LambdaSymbol)methodSymbol).MessageID.Localize())));
}
}
else if (containingMemberOrLambda.ContainingType.IsScriptClass)
{
if (!((FieldSymbol)containingMemberOrLambda).IsStatic)
{
return false;
}
val = (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_BadAwaitInStaticVariableInitializer);
}
}
if (val == null)
{
val = (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_BadAwaitWithoutAsync);
}
Error(diagnostics, val, ((SyntaxNodeOrToken)(ref nodeOrToken)).GetLocation());
return true;
}
private bool ReportBadAwaitContext(SyntaxNodeOrToken nodeOrToken, BindingDiagnosticBag diagnostics)
{
if (InUnsafeRegion && !Flags.Includes(BinderFlags.AllowAwaitInUnsafeContext))
{
Error(diagnostics, ErrorCode.ERR_AwaitInUnsafeContext, ((SyntaxNodeOrToken)(ref nodeOrToken)).GetLocation());
return true;
}
if (Flags.Includes(BinderFlags.InLockBody))
{
Error(diagnostics, ErrorCode.ERR_BadAwaitInLock, ((SyntaxNodeOrToken)(ref nodeOrToken)).GetLocation());
return true;
}
if (Flags.Includes(BinderFlags.InCatchFilter))
{
Error(diagnostics, ErrorCode.ERR_BadAwaitInCatchFilter, ((SyntaxNodeOrToken)(ref nodeOrToken)).GetLocation());
return true;
}
if (Flags.Includes(BinderFlags.InFinallyBlock))
{
CSharpSyntaxTree obj = ((SyntaxNodeOrToken)(ref nodeOrToken)).SyntaxTree as CSharpSyntaxTree;
if (obj != null && obj.Options?.IsFeatureEnabled(MessageID.IDS_AwaitInCatchAndFinally) == false)
{
Error(diagnostics, ErrorCode.ERR_BadAwaitInFinally, ((SyntaxNodeOrToken)(ref nodeOrToken)).GetLocation());
return true;
}
}
if (Flags.Includes(BinderFlags.InCatchBlock))
{
CSharpSyntaxTree obj2 = ((SyntaxNodeOrToken)(ref nodeOrToken)).SyntaxTree as CSharpSyntaxTree;
if (obj2 != null && obj2.Options?.IsFeatureEnabled(MessageID.IDS_AwaitInCatchAndFinally) == false)
{
Error(diagnostics, ErrorCode.ERR_BadAwaitInCatch, ((SyntaxNodeOrToken)(ref nodeOrToken)).GetLocation());
return true;
}
}
return false;
}
internal bool GetAwaitableExpressionInfo(BoundExpression expression, out BoundExpression? getAwaiterGetResultCall, SyntaxNode node, BindingDiagnosticBag diagnostics)
{
bool isDynamic;
BoundExpression getAwaiter;
PropertySymbol isCompleted;
MethodSymbol getResult;
return GetAwaitableExpressionInfo(expression, expression, out isDynamic, out getAwaiter, out isCompleted, out getResult, out getAwaiterGetResultCall, node, diagnostics);
}
private bool GetAwaitableExpressionInfo(BoundExpression expression, BoundExpression getAwaiterArgument, out bool isDynamic, out BoundExpression? getAwaiter, out PropertySymbol? isCompleted, out MethodSymbol? getResult, out BoundExpression? getAwaiterGetResultCall, SyntaxNode node, BindingDiagnosticBag diagnostics)
{
isDynamic = false;
getAwaiter = null;
isCompleted = null;
getResult = null;
getAwaiterGetResultCall = null;
if (!ValidateAwaitedExpression(expression, node, diagnostics))
{
return false;
}
if (expression.HasDynamicType())
{
isDynamic = true;
return true;
}
if (!GetGetAwaiterMethod(getAwaiterArgument, node, diagnostics, out getAwaiter))
{
return false;
}
TypeSymbol type = getAwaiter.Type;
if (GetIsCompletedProperty(type, node, expression.Type, diagnostics, out isCompleted) && AwaiterImplementsINotifyCompletion(type, node, diagnostics))
{
return GetGetResultMethod(getAwaiter, node, expression.Type, diagnostics, out getResult, out getAwaiterGetResultCall);
}
return false;
}
private static bool ValidateAwaitedExpression(BoundExpression expression, SyntaxNode node, BindingDiagnosticBag diagnostics)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
if (expression.HasAnyErrors)
{
return false;
}
if ((object)expression.Type == null)
{
Error(diagnostics, ErrorCode.ERR_BadAwaitArgIntrinsic, SyntaxNodeOrToken.op_Implicit(node), expression.Display);
return false;
}
return true;
}
private bool GetGetAwaiterMethod(BoundExpression expression, SyntaxNode node, BindingDiagnosticBag diagnostics, [NotNullWhen(true)] out BoundExpression? getAwaiterCall)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
if (expression.Type.IsVoidType())
{
Error(diagnostics, ErrorCode.ERR_BadAwaitArgVoidCall, SyntaxNodeOrToken.op_Implicit(node));
getAwaiterCall = null;
return false;
}
getAwaiterCall = MakeInvocationExpression(node, expression, "GetAwaiter", ImmutableArray<BoundExpression>.Empty, diagnostics);
if (getAwaiterCall.HasAnyErrors)
{
getAwaiterCall = null;
return false;
}
if (getAwaiterCall.Kind != BoundKind.Call)
{
Error(diagnostics, ErrorCode.ERR_BadAwaitArg, SyntaxNodeOrToken.op_Implicit(node), expression.Type);
getAwaiterCall = null;
return false;
}
MethodSymbol method = ((BoundCall)getAwaiterCall).Method;
if (method is ErrorMethodSymbol || HasOptionalOrVariableParameters(method) || method.ReturnsVoid)
{
Error(diagnostics, ErrorCode.ERR_BadAwaitArg, SyntaxNodeOrToken.op_Implicit(node), expression.Type);
getAwaiterCall = null;
return false;
}
return true;
}
private bool GetIsCompletedProperty(TypeSymbol awaiterType, SyntaxNode node, TypeSymbol awaitedExpressionType, BindingDiagnosticBag diagnostics, [NotNullWhen(true)] out PropertySymbol? isCompletedProperty)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
BoundLiteral boundLeft = new BoundLiteral(node, ConstantValue.Null, awaiterType);
string rightName = "IsCompleted";
BoundExpression boundExpression = BindInstanceMemberAccess(node, node, boundLeft, rightName, 0, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), invoked: false, indexed: false, diagnostics);
if (boundExpression.HasAnyErrors)
{
isCompletedProperty = null;
return false;
}
if (boundExpression.Kind != BoundKind.PropertyAccess)
{
Error(diagnostics, ErrorCode.ERR_NoSuchMember, SyntaxNodeOrToken.op_Implicit(node), awaiterType, "IsCompleted");
isCompletedProperty = null;
return false;
}
isCompletedProperty = ((BoundPropertyAccess)boundExpression).PropertySymbol;
if (isCompletedProperty.IsWriteOnly)
{
Error(diagnostics, ErrorCode.ERR_PropertyLacksGet, SyntaxNodeOrToken.op_Implicit(node), isCompletedProperty);
isCompletedProperty = null;
return false;
}
if ((int)isCompletedProperty.Type.SpecialType != 7)
{
Error(diagnostics, ErrorCode.ERR_BadAwaiterPattern, SyntaxNodeOrToken.op_Implicit(node), awaiterType, awaitedExpressionType);
isCompletedProperty = null;
return false;
}
return true;
}
private bool AwaiterImplementsINotifyCompletion(TypeSymbol awaiterType, SyntaxNode node, BindingDiagnosticBag diagnostics)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol wellKnownType = GetWellKnownType((WellKnownType)172, diagnostics, node);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
if (!Conversions.ClassifyImplicitConversionFromType(awaiterType, wellKnownType, ref useSiteInfo).IsImplicit)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
Error(diagnostics, ErrorCode.ERR_DoesntImplementAwaitInterface, SyntaxNodeOrToken.op_Implicit(node), awaiterType, wellKnownType);
return false;
}
return true;
}
private bool GetGetResultMethod(BoundExpression awaiterExpression, SyntaxNode node, TypeSymbol awaitedExpressionType, BindingDiagnosticBag diagnostics, out MethodSymbol? getResultMethod, [NotNullWhen(true)] out BoundExpression? getAwaiterGetResultCall)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
TypeSymbol type = awaiterExpression.Type;
getAwaiterGetResultCall = MakeInvocationExpression(node, awaiterExpression, "GetResult", ImmutableArray<BoundExpression>.Empty, diagnostics);
if (getAwaiterGetResultCall.HasAnyErrors)
{
getResultMethod = null;
getAwaiterGetResultCall = null;
return false;
}
if (getAwaiterGetResultCall.Kind != BoundKind.Call)
{
Error(diagnostics, ErrorCode.ERR_NoSuchMember, SyntaxNodeOrToken.op_Implicit(node), type, "GetResult");
getResultMethod = null;
getAwaiterGetResultCall = null;
return false;
}
getResultMethod = ((BoundCall)getAwaiterGetResultCall).Method;
if (getResultMethod.IsExtensionMethod)
{
Error(diagnostics, ErrorCode.ERR_NoSuchMember, SyntaxNodeOrToken.op_Implicit(node), type, "GetResult");
getResultMethod = null;
getAwaiterGetResultCall = null;
return false;
}
if (HasOptionalOrVariableParameters(getResultMethod) || getResultMethod.IsConditional)
{
Error(diagnostics, ErrorCode.ERR_BadAwaiterPattern, SyntaxNodeOrToken.op_Implicit(node), type, awaitedExpressionType);
getResultMethod = null;
getAwaiterGetResultCall = null;
return false;
}
return true;
}
private static bool HasOptionalOrVariableParameters(MethodSymbol method)
{
if (method.ParameterCount != 0)
{
ParameterSymbol parameterSymbol = method.Parameters[method.ParameterCount - 1];
if (!parameterSymbol.IsOptional)
{
return parameterSymbol.IsParams;
}
return true;
}
return false;
}
internal ImmutableArray<TypeParameterConstraintClause> BindTypeParameterConstraintClauses(Symbol containingSymbol, ImmutableArray<TypeParameterSymbol> typeParameters, TypeParameterListSyntax typeParameterList, SyntaxList<TypeParameterConstraintClauseSyntax> clauses, BindingDiagnosticBag diagnostics, bool performOnlyCycleSafeValidation, bool isForOverride = false)
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
int length = typeParameters.Length;
Dictionary<string, int> dictionary = new Dictionary<string, int>(length, (IEqualityComparer<string>?)StringOrdinalComparer.Instance);
ImmutableArray<TypeParameterSymbol>.Enumerator enumerator = typeParameters.GetEnumerator();
while (enumerator.MoveNext())
{
string name = enumerator.Current.Name;
if (!dictionary.ContainsKey(name))
{
dictionary.Add(name, dictionary.Count);
}
}
ArrayBuilder<TypeParameterConstraintClause> instance = ArrayBuilder<TypeParameterConstraintClause>.GetInstance(length, (TypeParameterConstraintClause)null);
ArrayBuilder<ArrayBuilder<TypeConstraintSyntax>> instance2 = ArrayBuilder<ArrayBuilder<TypeConstraintSyntax>>.GetInstance(length, (ArrayBuilder<TypeConstraintSyntax>)null);
Enumerator<TypeParameterConstraintClauseSyntax> enumerator2 = clauses.GetEnumerator();
while (enumerator2.MoveNext())
{
TypeParameterConstraintClauseSyntax current = enumerator2.Current;
SyntaxToken identifier = current.Name.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
if (dictionary.TryGetValue(valueText, out var value))
{
var (typeParameterConstraintClause, val) = BindTypeParameterConstraints(typeParameterList.Parameters[value], current, isForOverride, diagnostics);
if (instance[value] == null)
{
instance[value] = typeParameterConstraintClause;
instance2[value] = val;
}
else
{
diagnostics.Add(ErrorCode.ERR_DuplicateConstraintClause, ((SyntaxNode)current.Name).Location, valueText);
val?.Free();
}
}
else
{
diagnostics.Add(ErrorCode.ERR_TyVarNotFoundInConstraint, ((SyntaxNode)current.Name).Location, valueText, containingSymbol.ConstructedFrom());
}
}
for (int i = 0; i < length; i++)
{
if (instance[i] == null)
{
instance[i] = GetDefaultTypeParameterConstraintClause(typeParameterList.Parameters[i], isForOverride);
}
}
RemoveInvalidConstraints(typeParameters, instance, instance2, performOnlyCycleSafeValidation, diagnostics);
Enumerator<ArrayBuilder<TypeConstraintSyntax>> enumerator3 = instance2.GetEnumerator();
while (enumerator3.MoveNext())
{
enumerator3.Current?.Free();
}
instance2.Free();
return instance.ToImmutableAndFree();
}
private (TypeParameterConstraintClause, ArrayBuilder<TypeConstraintSyntax>?) BindTypeParameterConstraints(TypeParameterSyntax typeParameterSyntax, TypeParameterConstraintClauseSyntax constraintClauseSyntax, bool isForOverride, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
TypeParameterConstraintKind typeParameterConstraintKind = TypeParameterConstraintKind.None;
ArrayBuilder<TypeWithAnnotations> val = null;
ArrayBuilder<TypeConstraintSyntax> val2 = null;
SeparatedSyntaxList<TypeParameterConstraintSyntax> constraints = constraintClauseSyntax.Constraints;
bool flag = false;
bool reportedOverrideWithConstraints = false;
int i = 0;
for (int count = constraints.Count; i < count; i++)
{
TypeParameterConstraintSyntax typeParameterConstraintSyntax = constraints[i];
switch (typeParameterConstraintSyntax.Kind())
{
case SyntaxKind.ClassConstraint:
{
flag = true;
if (i != 0)
{
if (!reportedOverrideWithConstraints)
{
reportTypeConstraintsMustBeUniqueAndFirst(typeParameterConstraintSyntax, diagnostics);
}
if (isForOverride && (typeParameterConstraintKind & (TypeParameterConstraintKind.ReferenceType | TypeParameterConstraintKind.ValueType)) != TypeParameterConstraintKind.None)
{
break;
}
}
ClassOrStructConstraintSyntax classOrStructConstraintSyntax = (ClassOrStructConstraintSyntax)typeParameterConstraintSyntax;
SyntaxToken questionToken = classOrStructConstraintSyntax.QuestionToken;
if (questionToken.IsKind(SyntaxKind.QuestionToken))
{
typeParameterConstraintKind |= TypeParameterConstraintKind.NullableReferenceType;
if (isForOverride)
{
reportOverrideWithConstraints(ref reportedOverrideWithConstraints, typeParameterConstraintSyntax, diagnostics);
break;
}
DiagnosticBag diagnosticBag = ((BindingDiagnosticBag)diagnostics).DiagnosticBag;
if (diagnosticBag != null)
{
LazyMissingNonNullTypesContextDiagnosticInfo.AddAll(this, questionToken, null, diagnosticBag);
}
}
else
{
typeParameterConstraintKind = ((!isForOverride && !AreNullableAnnotationsEnabled(classOrStructConstraintSyntax.ClassOrStructKeyword)) ? (typeParameterConstraintKind | TypeParameterConstraintKind.ReferenceType) : (typeParameterConstraintKind | TypeParameterConstraintKind.NotNullableReferenceType));
}
break;
}
case SyntaxKind.StructConstraint:
flag = true;
if (i != 0)
{
if (!reportedOverrideWithConstraints)
{
reportTypeConstraintsMustBeUniqueAndFirst(typeParameterConstraintSyntax, diagnostics);
}
if (isForOverride && (typeParameterConstraintKind & (TypeParameterConstraintKind.ReferenceType | TypeParameterConstraintKind.ValueType)) != TypeParameterConstraintKind.None)
{
break;
}
}
typeParameterConstraintKind |= TypeParameterConstraintKind.ValueType;
break;
case SyntaxKind.ConstructorConstraint:
{
if (isForOverride)
{
reportOverrideWithConstraints(ref reportedOverrideWithConstraints, typeParameterConstraintSyntax, diagnostics);
break;
}
SyntaxToken firstToken;
if ((typeParameterConstraintKind & TypeParameterConstraintKind.ValueType) != TypeParameterConstraintKind.None)
{
firstToken = typeParameterConstraintSyntax.GetFirstToken();
diagnostics.Add(ErrorCode.ERR_NewBoundWithVal, ((SyntaxToken)(ref firstToken)).GetLocation());
}
if ((typeParameterConstraintKind & TypeParameterConstraintKind.Unmanaged) != TypeParameterConstraintKind.None)
{
firstToken = typeParameterConstraintSyntax.GetFirstToken();
diagnostics.Add(ErrorCode.ERR_NewBoundWithUnmanaged, ((SyntaxToken)(ref firstToken)).GetLocation());
}
if (i != count - 1)
{
firstToken = typeParameterConstraintSyntax.GetFirstToken();
diagnostics.Add(ErrorCode.ERR_NewBoundMustBeLast, ((SyntaxToken)(ref firstToken)).GetLocation());
}
typeParameterConstraintKind |= TypeParameterConstraintKind.Constructor;
break;
}
case SyntaxKind.DefaultConstraint:
CheckFeatureAvailability((SyntaxNode)(object)typeParameterConstraintSyntax, MessageID.IDS_FeatureDefaultTypeParameterConstraint, diagnostics);
if (!isForOverride)
{
diagnostics.Add(ErrorCode.ERR_DefaultConstraintOverrideOnly, typeParameterConstraintSyntax.GetLocation());
}
if (i != 0)
{
if (!reportedOverrideWithConstraints)
{
reportTypeConstraintsMustBeUniqueAndFirst(typeParameterConstraintSyntax, diagnostics);
}
if (isForOverride && (typeParameterConstraintKind & (TypeParameterConstraintKind.ReferenceType | TypeParameterConstraintKind.ValueType)) != TypeParameterConstraintKind.None)
{
break;
}
}
typeParameterConstraintKind |= TypeParameterConstraintKind.Default;
break;
case SyntaxKind.TypeConstraint:
{
if (isForOverride)
{
reportOverrideWithConstraints(ref reportedOverrideWithConstraints, typeParameterConstraintSyntax, diagnostics);
break;
}
flag = true;
if (val == null)
{
val = ArrayBuilder<TypeWithAnnotations>.GetInstance();
val2 = ArrayBuilder<TypeConstraintSyntax>.GetInstance();
}
TypeConstraintSyntax typeConstraintSyntax = (TypeConstraintSyntax)typeParameterConstraintSyntax;
TypeSyntax type = typeConstraintSyntax.Type;
ConstraintContextualKeyword keyword;
TypeWithAnnotations typeWithAnnotations = BindTypeOrConstraintKeyword(type, diagnostics, out keyword);
switch (keyword)
{
case ConstraintContextualKeyword.Unmanaged:
if (i != 0)
{
reportTypeConstraintsMustBeUniqueAndFirst(type, diagnostics);
break;
}
GetWellKnownType((WellKnownType)277, diagnostics, (SyntaxNode)(object)type);
GetSpecialType((SpecialType)5, diagnostics, (SyntaxNode)(object)type);
typeParameterConstraintKind |= TypeParameterConstraintKind.Unmanaged;
break;
case ConstraintContextualKeyword.NotNull:
if (i != 0)
{
reportTypeConstraintsMustBeUniqueAndFirst(type, diagnostics);
}
typeParameterConstraintKind |= TypeParameterConstraintKind.NotNull;
break;
default:
throw ExceptionUtilities.UnexpectedValue((object)keyword);
case ConstraintContextualKeyword.None:
val.Add(typeWithAnnotations);
val2.Add(typeConstraintSyntax);
break;
}
break;
}
default:
throw ExceptionUtilities.UnexpectedValue((object)typeParameterConstraintSyntax.Kind());
}
}
if (!isForOverride && !flag && !AreNullableAnnotationsEnabled(typeParameterSyntax.Identifier))
{
typeParameterConstraintKind |= TypeParameterConstraintKind.ObliviousNullabilityIfReferenceType;
}
return (TypeParameterConstraintClause.Create(typeParameterConstraintKind, val?.ToImmutableAndFree() ?? ImmutableArray<TypeWithAnnotations>.Empty), val2);
static void reportOverrideWithConstraints(ref bool reference, TypeParameterConstraintSyntax syntax, BindingDiagnosticBag bindingDiagnosticBag)
{
if (!reference)
{
bindingDiagnosticBag.Add(ErrorCode.ERR_OverrideWithConstraints, syntax.GetLocation());
reference = true;
}
}
static void reportTypeConstraintsMustBeUniqueAndFirst(CSharpSyntaxNode syntax, BindingDiagnosticBag bindingDiagnosticBag)
{
bindingDiagnosticBag.Add(ErrorCode.ERR_TypeConstraintsMustBeUniqueAndFirst, syntax.GetLocation());
}
}
internal ImmutableArray<TypeParameterConstraintClause> GetDefaultTypeParameterConstraintClauses(TypeParameterListSyntax typeParameterList)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
ArrayBuilder<TypeParameterConstraintClause> instance = ArrayBuilder<TypeParameterConstraintClause>.GetInstance(typeParameterList.Parameters.Count);
Enumerator<TypeParameterSyntax> enumerator = typeParameterList.Parameters.GetEnumerator();
while (enumerator.MoveNext())
{
TypeParameterSyntax current = enumerator.Current;
instance.Add(GetDefaultTypeParameterConstraintClause(current));
}
return instance.ToImmutableAndFree();
}
private TypeParameterConstraintClause GetDefaultTypeParameterConstraintClause(TypeParameterSyntax typeParameterSyntax, bool isForOverride = false)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (!isForOverride && !AreNullableAnnotationsEnabled(typeParameterSyntax.Identifier))
{
return TypeParameterConstraintClause.ObliviousNullabilityIfReferenceType;
}
return TypeParameterConstraintClause.Empty;
}
private static void RemoveInvalidConstraints(ImmutableArray<TypeParameterSymbol> typeParameters, ArrayBuilder<TypeParameterConstraintClause> constraintClauses, ArrayBuilder<ArrayBuilder<TypeConstraintSyntax>?> syntaxNodes, bool performOnlyCycleSafeValidation, BindingDiagnosticBag diagnostics)
{
int length = typeParameters.Length;
for (int i = 0; i < length; i++)
{
constraintClauses[i] = RemoveInvalidConstraints(typeParameters[i], constraintClauses[i], syntaxNodes[i], performOnlyCycleSafeValidation, diagnostics);
}
}
private static TypeParameterConstraintClause RemoveInvalidConstraints(TypeParameterSymbol typeParameter, TypeParameterConstraintClause constraintClause, ArrayBuilder<TypeConstraintSyntax>? syntaxNodesOpt, bool performOnlyCycleSafeValidation, BindingDiagnosticBag diagnostics)
{
if (syntaxNodesOpt != null)
{
ImmutableArray<TypeWithAnnotations> constraintTypes = constraintClause.ConstraintTypes;
Symbol containingSymbol = typeParameter.ContainingSymbol;
ArrayBuilder<TypeWithAnnotations> instance = ArrayBuilder<TypeWithAnnotations>.GetInstance();
int length = constraintTypes.Length;
for (int i = 0; i < length; i++)
{
TypeWithAnnotations typeWithAnnotations = constraintTypes[i];
TypeConstraintSyntax typeConstraintSyntax = syntaxNodesOpt[i];
if (IsValidConstraint(typeParameter, typeConstraintSyntax, typeWithAnnotations, constraintClause.Constraints, instance, performOnlyCycleSafeValidation, diagnostics))
{
if (!performOnlyCycleSafeValidation)
{
CheckConstraintTypeVisibility(containingSymbol, ((SyntaxNode)typeConstraintSyntax).Location, typeWithAnnotations, diagnostics);
}
instance.Add(typeWithAnnotations);
}
}
if (instance.Count < length)
{
return TypeParameterConstraintClause.Create(constraintClause.Constraints, instance.ToImmutableAndFree());
}
instance.Free();
}
return constraintClause;
}
private static void CheckConstraintTypeVisibility(Symbol containingSymbol, Location location, TypeWithAnnotations constraintType, BindingDiagnosticBag diagnostics)
{
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = default(CompoundUseSiteInfo<AssemblySymbol>);
useSiteInfo._002Ector((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics, containingSymbol.ContainingAssembly);
if (!containingSymbol.IsNoMoreVisibleThan(constraintType, ref useSiteInfo))
{
diagnostics.Add(ErrorCode.ERR_BadVisBound, location, containingSymbol, constraintType.Type);
}
if (constraintType.Type.HasFileLocalTypes())
{
TypeSymbol typeSymbol2;
if (!(containingSymbol is TypeSymbol typeSymbol))
{
if (!(containingSymbol is LocalFunctionSymbol))
{
if (!(containingSymbol is MethodSymbol methodSymbol))
{
throw ExceptionUtilities.UnexpectedValue((object)containingSymbol);
}
typeSymbol2 = (TypeSymbol)methodSymbol.ContainingSymbol;
}
else
{
typeSymbol2 = null;
}
}
else
{
typeSymbol2 = typeSymbol;
}
TypeSymbol typeSymbol3 = typeSymbol2;
if ((object)typeSymbol3 != null && !typeSymbol3.HasFileLocalTypes())
{
diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, location, constraintType.Type, containingSymbol);
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(location, useSiteInfo);
}
private static bool IsValidConstraint(TypeParameterSymbol typeParameter, TypeConstraintSyntax syntax, TypeWithAnnotations type, TypeParameterConstraintKind constraints, ArrayBuilder<TypeWithAnnotations> constraintTypes, bool performOnlyCycleSafeValidation, BindingDiagnosticBag diagnostics)
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Invalid comparison between Unknown and I4
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Invalid comparison between Unknown and I4
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Invalid comparison between Unknown and I4
if (!isValidConstraintType(typeParameter, syntax, type, performOnlyCycleSafeValidation, diagnostics))
{
return false;
}
if (!performOnlyCycleSafeValidation && EnumerableExtensions.Contains<TypeWithAnnotations>((IEnumerable<TypeWithAnnotations>)constraintTypes, (Func<TypeWithAnnotations, bool>)((TypeWithAnnotations c) => type.Equals(c, (TypeCompareKind)63))))
{
Error(diagnostics, ErrorCode.ERR_DuplicateBound, (CSharpSyntaxNode)syntax, new object[2]
{
type.Type.SetUnknownNullabilityForReferenceTypes(),
typeParameter.Name
});
return false;
}
if (!type.DefaultType.IsTypeParameter() && (int)type.TypeKind == 2)
{
if (constraintTypes.Count > 0)
{
Error(diagnostics, ErrorCode.ERR_ClassBoundNotFirst, (CSharpSyntaxNode)syntax, new object[1] { type.Type });
return false;
}
if ((constraints & TypeParameterConstraintKind.ReferenceType) != TypeParameterConstraintKind.None)
{
SpecialType specialType = type.SpecialType;
if (specialType - 2 > 2)
{
Error(diagnostics, ErrorCode.ERR_RefValBoundWithClass, (CSharpSyntaxNode)syntax, new object[1] { type.Type });
return false;
}
}
else if ((int)type.SpecialType != 2)
{
if ((constraints & TypeParameterConstraintKind.ValueType) != TypeParameterConstraintKind.None)
{
Error(diagnostics, ErrorCode.ERR_RefValBoundWithClass, (CSharpSyntaxNode)syntax, new object[1] { type.Type });
return false;
}
if ((constraints & TypeParameterConstraintKind.Unmanaged) != TypeParameterConstraintKind.None)
{
Error(diagnostics, ErrorCode.ERR_UnmanagedBoundWithClass, (CSharpSyntaxNode)syntax, new object[1] { type.Type });
return false;
}
}
}
return true;
static bool isValidConstraintType(TypeParameterSymbol typeParameterSymbol2, TypeConstraintSyntax typeConstraintSyntax, TypeWithAnnotations typeWithAnnotations, bool flag, BindingDiagnosticBag diagnostics2)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected I4, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Invalid comparison between Unknown and I4
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected I4, but got Unknown
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
if (typeWithAnnotations.NullableAnnotation == NullableAnnotation.Annotated && flag && typeWithAnnotations.DefaultType is TypeParameterSymbol typeParameterSymbol && (object)typeParameterSymbol.ContainingSymbol == typeParameterSymbol2.ContainingSymbol)
{
return true;
}
TypeSymbol type2 = typeWithAnnotations.Type;
SpecialType specialType2 = type2.SpecialType;
switch (specialType2 - 1)
{
default:
if ((int)specialType2 != 23)
{
break;
}
goto case 0;
case 1:
CheckFeatureAvailability((SyntaxNode)(object)typeConstraintSyntax, MessageID.IDS_FeatureEnumGenericTypeConstraint, diagnostics2);
break;
case 2:
case 3:
CheckFeatureAvailability((SyntaxNode)(object)typeConstraintSyntax, MessageID.IDS_FeatureDelegateGenericTypeConstraint, diagnostics2);
break;
case 0:
case 4:
Error(diagnostics2, ErrorCode.ERR_SpecialTypeAsBound, (CSharpSyntaxNode)typeConstraintSyntax, new object[1] { type2 });
return false;
}
TypeKind typeKind = type2.TypeKind;
switch (typeKind - 1)
{
case 5:
case 10:
return true;
case 3:
Error(diagnostics2, ErrorCode.ERR_DynamicTypeAsBound, (CSharpSyntaxNode)typeConstraintSyntax);
return false;
case 1:
if (!type2.IsSealed)
{
if (type2.IsStatic)
{
Error(diagnostics2, ErrorCode.ERR_ConstraintIsStaticClass, (CSharpSyntaxNode)typeConstraintSyntax, new object[1] { type2 });
return false;
}
break;
}
goto case 2;
case 2:
case 4:
case 9:
Error(diagnostics2, ErrorCode.ERR_BadBoundType, (CSharpSyntaxNode)typeConstraintSyntax, new object[1] { type2 });
return false;
case 0:
case 8:
case 12:
Error(diagnostics2, ErrorCode.ERR_BadConstraintType, typeConstraintSyntax.GetLocation());
return false;
default:
throw ExceptionUtilities.UnexpectedValue((object)type2.TypeKind);
case 6:
break;
}
if (type2.ContainsDynamic())
{
Error(diagnostics2, ErrorCode.ERR_ConstructedDynamicTypeAsBound, (CSharpSyntaxNode)typeConstraintSyntax, new object[1] { type2 });
return false;
}
return true;
}
}
internal BoundExpression CreateConversion(BoundExpression source, TypeSymbol destination, BindingDiagnosticBag diagnostics)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyConversionFromExpression(source, destination, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(source.Syntax, useSiteInfo);
return CreateConversion(source.Syntax, source, conversion, isCast: false, null, destination, diagnostics);
}
internal BoundExpression CreateConversion(BoundExpression source, Conversion conversion, TypeSymbol destination, BindingDiagnosticBag diagnostics)
{
return CreateConversion(source.Syntax, source, conversion, isCast: false, null, destination, diagnostics);
}
internal BoundExpression CreateConversion(SyntaxNode syntax, BoundExpression source, Conversion conversion, bool isCast, ConversionGroup? conversionGroupOpt, TypeSymbol destination, BindingDiagnosticBag diagnostics)
{
return CreateConversion(syntax, source, conversion, isCast, conversionGroupOpt, source.WasCompilerGenerated, destination, diagnostics);
}
protected BoundExpression CreateConversion(SyntaxNode syntax, BoundExpression source, Conversion conversion, bool isCast, ConversionGroup? conversionGroupOpt, bool wasCompilerGenerated, TypeSymbol destination, BindingDiagnosticBag diagnostics, bool hasErrors = false)
{
return createConversion(syntax, source, conversion, isCast, conversionGroupOpt, wasCompilerGenerated, destination, diagnostics, hasErrors);
void checkConstraintLanguageVersionAndRuntimeSupportForConversion(SyntaxNode val, Conversion conversion2, BoundExpression boundExpression, TypeSymbol typeSymbol, BindingDiagnosticBag bindingDiagnosticBag)
{
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
if (conversion2.IsUserDefined)
{
MethodSymbol method = conversion2.Method;
if ((object)method != null && method.IsStatic)
{
if ((method.IsAbstract || method.IsVirtual) && Compilation.SourceModule != method.ContainingModule)
{
CheckFeatureAvailability(val, MessageID.IDS_FeatureStaticAbstractMembersInInterfaces, bindingDiagnosticBag);
if (!Compilation.Assembly.RuntimeSupportsStaticAbstractMembersInInterfaces)
{
Error(bindingDiagnosticBag, ErrorCode.ERR_RuntimeDoesNotSupportStaticAbstractMembersInInterfaces, SyntaxNodeOrToken.op_Implicit(val));
}
}
if (SyntaxFacts.IsCheckedOperator(method.Name) && Compilation.SourceModule != method.ContainingModule)
{
CheckFeatureAvailability(val, MessageID.IDS_FeatureCheckedUserDefinedOperators, bindingDiagnosticBag);
}
}
}
else if (conversion2.IsInlineArray)
{
if (!Compilation.Assembly.RuntimeSupportsInlineArrayTypes)
{
Error(bindingDiagnosticBag, ErrorCode.ERR_RuntimeDoesNotSupportInlineArrayTypes, SyntaxNodeOrToken.op_Implicit(val));
}
CheckFeatureAvailability(val, MessageID.IDS_FeatureInlineArrays, bindingDiagnosticBag);
bindingDiagnosticBag.ReportUseSite(boundExpression.Type.TryGetInlineArrayElementField(), val);
if (typeSymbol.OriginalDefinition.Equals(Compilation.GetWellKnownType((WellKnownType)276), (TypeCompareKind)63))
{
if (CheckValueKind(val, boundExpression, BindValueKind.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
{
GetWellKnownTypeMember((WellKnownMember)100, bindingDiagnosticBag, null, val);
GetWellKnownTypeMember((WellKnownMember)131, bindingDiagnosticBag, null, val);
GetWellKnownTypeMember((WellKnownMember)130, bindingDiagnosticBag, null, val);
}
else
{
Error(bindingDiagnosticBag, ErrorCode.ERR_InlineArrayConversionToReadOnlySpanNotSupported, SyntaxNodeOrToken.op_Implicit(val), typeSymbol);
}
}
else if (CheckValueKind(val, boundExpression, BindValueKind.Assignable | BindValueKind.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
{
GetWellKnownTypeMember((WellKnownMember)99, bindingDiagnosticBag, null, val);
GetWellKnownTypeMember((WellKnownMember)130, bindingDiagnosticBag, null, val);
}
else
{
Error(bindingDiagnosticBag, ErrorCode.ERR_InlineArrayConversionToSpanNotSupported, SyntaxNodeOrToken.op_Implicit(val), typeSymbol);
}
}
}
BoundExpression createConversion(SyntaxNode syntax2, BoundExpression boundExpression, Conversion conversion2, bool flag, ConversionGroup? conversionGroup, bool flag2, TypeSymbol typeSymbol, BindingDiagnosticBag diagnostics2, bool flag3 = false)
{
if (conversion2.IsIdentity)
{
if (boundExpression is BoundTupleLiteral literal)
{
NamedTypeSymbol.ReportTupleNamesMismatchesIfAny(typeSymbol, literal, diagnostics2);
}
boundExpression = BindToNaturalType(boundExpression, diagnostics2);
if (!flag && boundExpression.Type.Equals(typeSymbol, (TypeCompareKind)8))
{
return boundExpression;
}
}
if (conversion2.IsMethodGroup)
{
return CreateMethodGroupConversion(syntax2, boundExpression, conversion2, flag, conversionGroup, typeSymbol, diagnostics2);
}
reportUseSiteDiagnostics(syntax2, conversion2, boundExpression, typeSymbol, diagnostics2);
if (conversion2.IsAnonymousFunction && boundExpression.Kind == BoundKind.UnboundLambda)
{
return CreateAnonymousFunctionConversion(syntax2, boundExpression, conversion2, flag, conversionGroup, typeSymbol, diagnostics2);
}
if (conversion2.Kind == ConversionKind.FunctionType)
{
return CreateFunctionTypeConversion(syntax2, boundExpression, conversion2, flag, conversionGroup, typeSymbol, diagnostics2);
}
if (conversion2.IsStackAlloc)
{
return CreateStackAllocConversion(syntax2, boundExpression, conversion2, flag, conversionGroup, typeSymbol, diagnostics2);
}
if (conversion2.IsTupleLiteralConversion || (conversion2.IsNullable && conversion2.UnderlyingConversions[0].IsTupleLiteralConversion))
{
return CreateTupleLiteralConversion(syntax2, (BoundTupleLiteral)boundExpression, conversion2, flag, conversionGroup, typeSymbol, diagnostics2);
}
if (conversion2.Kind == ConversionKind.SwitchExpression)
{
BoundExpression boundExpression2 = ConvertSwitchExpression((BoundUnconvertedSwitchExpression)boundExpression, typeSymbol, conversion2, diagnostics2);
return new BoundConversion(syntax2, boundExpression2, conversion2, CheckOverflowAtRuntime, flag && !flag2, conversionGroup, boundExpression2.ConstantValueOpt, typeSymbol, flag3);
}
if (conversion2.Kind == ConversionKind.ConditionalExpression)
{
BoundExpression boundExpression3 = ConvertConditionalExpression((BoundUnconvertedConditionalOperator)boundExpression, typeSymbol, conversion2, diagnostics2);
return new BoundConversion(syntax2, boundExpression3, conversion2, CheckOverflowAtRuntime, flag && !flag2, conversionGroup, boundExpression3.ConstantValueOpt, typeSymbol, flag3);
}
if (conversion2.Kind == ConversionKind.InterpolatedString)
{
BoundUnconvertedInterpolatedString boundUnconvertedInterpolatedString = (BoundUnconvertedInterpolatedString)boundExpression;
boundExpression = new BoundInterpolatedString(boundUnconvertedInterpolatedString.Syntax, null, BindInterpolatedStringParts(boundUnconvertedInterpolatedString, diagnostics2), boundUnconvertedInterpolatedString.ConstantValueOpt, boundUnconvertedInterpolatedString.Type, boundUnconvertedInterpolatedString.HasErrors);
}
if (conversion2.Kind == ConversionKind.InterpolatedStringHandler)
{
return new BoundConversion(syntax2, BindUnconvertedInterpolatedExpressionToHandlerType(boundExpression, (NamedTypeSymbol)typeSymbol, diagnostics2), conversion2, CheckOverflowAtRuntime, flag && !flag2, conversionGroup, null, typeSymbol);
}
if (boundExpression.Kind == BoundKind.UnconvertedSwitchExpression)
{
TypeSymbol typeSymbol2 = boundExpression.Type;
if ((object)typeSymbol2 == null)
{
typeSymbol2 = CreateErrorType();
flag3 = true;
}
boundExpression = ConvertSwitchExpression((BoundUnconvertedSwitchExpression)boundExpression, typeSymbol2, null, diagnostics2, flag3);
if (typeSymbol.Equals(typeSymbol2, (TypeCompareKind)0) && flag2)
{
return boundExpression;
}
}
if (conversion2.IsObjectCreation)
{
return ConvertObjectCreationExpression(syntax2, (BoundUnconvertedObjectCreationExpression)boundExpression, conversion2, flag, typeSymbol, conversionGroup, flag2, diagnostics2);
}
if (boundExpression.Kind == BoundKind.UnconvertedCollectionExpression)
{
BoundExpression operand = ConvertCollectionExpression((BoundUnconvertedCollectionExpression)boundExpression, typeSymbol, conversion2, diagnostics2);
return new BoundConversion(syntax2, operand, conversion2, CheckOverflowAtRuntime, flag && !flag2, conversionGroup, null, typeSymbol);
}
if (boundExpression.Kind == BoundKind.UnconvertedConditionalOperator)
{
flag3 = true;
boundExpression = ConvertConditionalExpression((BoundUnconvertedConditionalOperator)boundExpression, CreateErrorType(), null, diagnostics2, flag3);
}
if (conversion2.IsUserDefined)
{
return CreateUserDefinedConversion(syntax2, boundExpression, conversion2, flag, conversionGroup ?? new ConversionGroup(conversion2), typeSymbol, diagnostics2, flag3);
}
ConstantValue constantValueOpt = FoldConstantConversion(syntax2, boundExpression, conversion2, typeSymbol, diagnostics2);
if (conversion2.Kind == ConversionKind.DefaultLiteral)
{
boundExpression = new BoundDefaultExpression(boundExpression.Syntax, null, constantValueOpt, typeSymbol).WithSuppression(boundExpression.IsSuppressed);
}
if (!flag3 && conversion2.Exists)
{
ensureAllUnderlyingConversionsChecked(syntax2, boundExpression, conversion2, flag2, typeSymbol, diagnostics2);
}
return new BoundConversion(syntax2, BindToNaturalType(boundExpression, diagnostics2), conversion2, CheckOverflowAtRuntime, flag && !flag2, conversionGroup, constantValueOpt, typeSymbol, flag3)
{
WasCompilerGenerated = flag2
};
}
void ensureAllUnderlyingConversionsChecked(SyntaxNode syntax2, BoundExpression boundExpression, Conversion conversion2, bool wasCompilerGenerated2, TypeSymbol typeSymbol, BindingDiagnosticBag diagnostics2)
{
if (conversion2.IsNullable)
{
if (typeSymbol.IsNullableType())
{
bool? flag = boundExpression.Type?.IsNullableType();
if (flag.HasValue)
{
if (flag == true)
{
CreateConversion(syntax2, new BoundValuePlaceholder(boundExpression.Syntax, boundExpression.Type.GetNullableUnderlyingType()), conversion2.UnderlyingConversions[0], isCast: false, null, wasCompilerGenerated2, typeSymbol.GetNullableUnderlyingType(), diagnostics2);
}
else
{
CreateConversion(syntax2, boundExpression, conversion2.UnderlyingConversions[0], isCast: false, null, wasCompilerGenerated2, typeSymbol.GetNullableUnderlyingType(), diagnostics2);
}
}
}
else
{
TypeSymbol? type = boundExpression.Type;
if ((object)type != null && type.IsNullableType())
{
CreateConversion(syntax2, new BoundValuePlaceholder(boundExpression.Syntax, boundExpression.Type.GetNullableUnderlyingType()), conversion2.UnderlyingConversions[0], isCast: false, null, wasCompilerGenerated2, typeSymbol, diagnostics2);
}
}
}
else if (conversion2.IsTupleConversion)
{
TypeSymbol? type2 = boundExpression.Type;
if ((object)type2 != null && type2.TryGetElementTypesWithAnnotationsIfTupleType(out var elementTypes) && typeSymbol.TryGetElementTypesWithAnnotationsIfTupleType(out var elementTypes2) && elementTypes.Length == elementTypes2.Length)
{
ImmutableArray<Conversion> underlyingConversions = conversion2.UnderlyingConversions;
for (int i = 0; i < elementTypes.Length; i++)
{
CreateConversion(syntax2, new BoundValuePlaceholder(boundExpression.Syntax, elementTypes[i].Type), underlyingConversions[i], isCast: false, null, wasCompilerGenerated2, elementTypes2[i].Type, diagnostics2);
}
}
}
else
{
_ = conversion2.IsDynamic;
}
}
void reportUseSiteDiagnostics(SyntaxNode val, Conversion conversion2, BoundExpression source2, TypeSymbol destination2, BindingDiagnosticBag diagnostics2)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
ReportDiagnosticsIfObsolete(diagnostics2, conversion2, SyntaxNodeOrToken.op_Implicit(val), hasBaseReceiver: false);
if ((object)conversion2.Method != null)
{
ReportUseSite(conversion2.Method, diagnostics2, val.Location);
}
checkConstraintLanguageVersionAndRuntimeSupportForConversion(val, conversion2, source2, destination2, diagnostics2);
}
}
private static BoundExpression ConvertObjectCreationExpression(SyntaxNode syntax, BoundUnconvertedObjectCreationExpression node, Conversion conversion, bool isCast, TypeSymbol destination, ConversionGroup? conversionGroupOpt, bool wasCompilerGenerated, BindingDiagnosticBag diagnostics)
{
AnalyzedArguments instance = AnalyzedArguments.GetInstance(node.Arguments, node.ArgumentRefKindsOpt, node.ArgumentNamesOpt);
BoundExpression boundExpression = bindObjectCreationExpression(node.Syntax, node.InitializerOpt, node.Binder, destination.StrippedType(), instance, diagnostics);
instance.Free();
if (wasCompilerGenerated)
{
boundExpression.MakeCompilerGenerated();
}
return new BoundConversion(syntax, boundExpression, (boundExpression is BoundBadExpression) ? Conversion.NoConversion : conversion, node.Binder.CheckOverflowAtRuntime, isCast && !wasCompilerGenerated, conversionGroupOpt, boundExpression.ConstantValueOpt, destination)
{
WasCompilerGenerated = wasCompilerGenerated
};
static BoundExpression bindObjectCreationExpression(SyntaxNode val, InitializerExpressionSyntax? initializerOpt, Binder binder, TypeSymbol type, AnalyzedArguments arguments, BindingDiagnosticBag diagnostics2)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected I4, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
TypeKind typeKind = type.TypeKind;
switch (typeKind - 1)
{
case 1:
if (!type.IsAnonymousType)
{
goto case 4;
}
goto case 0;
case 4:
case 9:
return binder.BindClassCreationExpression(val, type.Name, val, (NamedTypeSymbol)type, arguments, diagnostics2, initializerOpt, null, wasTargetTyped: true);
case 10:
return binder.BindTypeParameterCreationExpression(val, (TypeParameterSymbol)type, arguments, initializerOpt, val, wasTargetTyped: true, diagnostics2);
case 2:
return binder.BindDelegateCreationExpression(val, (NamedTypeSymbol)type, arguments, initializerOpt, wasTargetTyped: true, diagnostics2);
case 6:
return binder.BindInterfaceCreationExpression(val, (NamedTypeSymbol)type, diagnostics2, val, arguments, initializerOpt, wasTargetTyped: true);
case 0:
case 3:
Error(diagnostics2, ErrorCode.ERR_ImplicitObjectCreationIllegalTargetType, SyntaxNodeOrToken.op_Implicit(val), type);
goto case 5;
case 8:
case 12:
Error(diagnostics2, ErrorCode.ERR_UnsafeTypeInObjectCreation, SyntaxNodeOrToken.op_Implicit(val), type);
goto case 5;
case 5:
return binder.MakeBadExpressionForObjectCreation(val, type, arguments, initializerOpt, val, diagnostics2);
default:
throw ExceptionUtilities.UnexpectedValue((object)typeKind);
}
}
}
private BoundExpression ConvertCollectionExpression(BoundUnconvertedCollectionExpression node, TypeSymbol targetType, Conversion conversion, BindingDiagnosticBag diagnostics)
{
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
if (conversion.IsNullable)
{
targetType = targetType.GetNullableUnderlyingType();
conversion = conversion.UnderlyingConversions[0];
GetSpecialTypeMember((SpecialMember)117, diagnostics, node.Syntax);
}
TypeSymbol elementType;
CollectionExpressionTypeKind collectionExpressionTypeKind = conversion.GetCollectionExpressionTypeKind(out elementType);
if (collectionExpressionTypeKind == CollectionExpressionTypeKind.None)
{
return BindCollectionExpressionForErrorRecovery(node, targetType, diagnostics);
}
ExpressionSyntax syntax = (ExpressionSyntax)(object)node.Syntax;
MethodSymbol methodSymbol = null;
BoundValuePlaceholder boundValuePlaceholder = null;
BoundExpression collectionBuilderInvocationConversion = null;
switch (collectionExpressionTypeKind)
{
case CollectionExpressionTypeKind.Span:
GetWellKnownTypeMember((WellKnownMember)399, diagnostics, null, (SyntaxNode)(object)syntax);
break;
case CollectionExpressionTypeKind.ReadOnlySpan:
GetWellKnownTypeMember((WellKnownMember)404, diagnostics, null, (SyntaxNode)(object)syntax);
break;
case CollectionExpressionTypeKind.CollectionBuilder:
{
NamedTypeSymbol namedTypeSymbol = (NamedTypeSymbol)targetType;
namedTypeSymbol.HasCollectionBuilderAttribute(out TypeSymbol builderType, out string methodName);
TypeSymbol originalDefinition = targetType.OriginalDefinition;
TryGetCollectionIterationType(syntax, originalDefinition, out var iterationType);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
methodSymbol = GetCollectionBuilderMethod(namedTypeSymbol, iterationType.Type, builderType, methodName, ref useSiteInfo, out var _);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)syntax, useSiteInfo);
if ((object)methodSymbol == null)
{
diagnostics.Add(ErrorCode.ERR_CollectionBuilderAttributeMethodNotFound, (SyntaxNode)(object)syntax, methodName ?? "", iterationType, originalDefinition);
return BindCollectionExpressionForErrorRecovery(node, targetType, diagnostics);
}
boundValuePlaceholder = new BoundValuePlaceholder((SyntaxNode)(object)syntax, methodSymbol.ReturnType);
collectionBuilderInvocationConversion = CreateConversion(boundValuePlaceholder, targetType, diagnostics);
ReportUseSite(methodSymbol, diagnostics, ((SyntaxNode)syntax).Location);
elementType = ((NamedTypeSymbol)methodSymbol.Parameters[0].Type).TypeArgumentsWithAnnotationsNoUseSiteDiagnostics[0].Type;
methodSymbol.CheckConstraints(new ConstraintsHelper.CheckConstraintsArgs(Compilation, Conversions, ((SyntaxNode)syntax).Location, diagnostics));
ReportDiagnosticsIfObsolete(diagnostics, methodSymbol.ContainingType, SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)syntax), hasBaseReceiver: false);
ReportDiagnosticsIfObsolete(diagnostics, methodSymbol, SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)syntax), hasBaseReceiver: false);
ReportDiagnosticsIfUnmanagedCallersOnly(diagnostics, methodSymbol, SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)syntax), isDelegateConversion: false);
break;
}
case CollectionExpressionTypeKind.ImplementsIEnumerableT:
case CollectionExpressionTypeKind.ImplementsIEnumerable:
if (targetType.OriginalDefinition.Equals(Compilation.GetWellKnownType((WellKnownType)204), (TypeCompareKind)0))
{
diagnostics.Add(ErrorCode.ERR_CollectionExpressionImmutableArray, (SyntaxNode)(object)syntax, targetType.OriginalDefinition);
return BindCollectionExpressionForErrorRecovery(node, targetType, diagnostics);
}
break;
}
ImmutableArray<BoundExpression> elements = node.Elements;
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(elements.Length);
BoundExpression boundExpression = null;
BoundObjectOrCollectionValuePlaceholder boundObjectOrCollectionValuePlaceholder = null;
bool hasErrors = (uint)(collectionExpressionTypeKind - 7) <= 1u;
if (hasErrors)
{
boundObjectOrCollectionValuePlaceholder = new BoundObjectOrCollectionValuePlaceholder((SyntaxNode)(object)syntax, isNewInstance: true, targetType)
{
WasCompilerGenerated = true
};
if (targetType is NamedTypeSymbol namedTypeSymbol2)
{
AnalyzedArguments instance2 = AnalyzedArguments.GetInstance();
boundExpression = BindClassCreationExpression((SyntaxNode)(object)syntax, namedTypeSymbol2.Name, (SyntaxNode)(object)syntax, namedTypeSymbol2, instance2, diagnostics);
boundExpression.WasCompilerGenerated = true;
instance2.Free();
}
else if (targetType is TypeParameterSymbol typeParameter)
{
AnalyzedArguments instance3 = AnalyzedArguments.GetInstance();
boundExpression = BindTypeParameterCreationExpression((SyntaxNode)(object)syntax, typeParameter, instance3, null, (SyntaxNode)(object)syntax, wasTargetTyped: true, diagnostics);
instance3.Free();
}
else
{
boundExpression = new BoundBadExpression((SyntaxNode)(object)syntax, LookupResultKind.NotCreatable, ImmutableArray<Symbol>.Empty, ImmutableArray<BoundExpression>.Empty, targetType);
}
Binder collectionInitializerAddMethodBinder = WithAdditionalFlags(BinderFlags.CollectionInitializerAddMethod);
ImmutableArray<BoundExpression>.Enumerator enumerator = elements.GetEnumerator();
while (enumerator.MoveNext())
{
BoundExpression current = enumerator.Current;
BoundExpression boundExpression2 = BindCollectionExpressionElementAddMethod(current, collectionInitializerAddMethodBinder, boundObjectOrCollectionValuePlaceholder, diagnostics, out hasErrors);
instance.Add(boundExpression2);
}
}
else
{
hasErrors = ((collectionExpressionTypeKind == CollectionExpressionTypeKind.List || collectionExpressionTypeKind == CollectionExpressionTypeKind.ArrayInterface) ? true : false);
if (hasErrors || node.HasSpreadElements(out var _, out var _))
{
GetWellKnownTypeMember((WellKnownMember)494, diagnostics, null, (SyntaxNode)(object)syntax);
GetWellKnownTypeMember((WellKnownMember)495, diagnostics, null, (SyntaxNode)(object)syntax);
GetWellKnownTypeMember((WellKnownMember)496, diagnostics, null, (SyntaxNode)(object)syntax);
if (collectionExpressionTypeKind != CollectionExpressionTypeKind.List)
{
GetWellKnownTypeMember((WellKnownMember)502, diagnostics, null, (SyntaxNode)(object)syntax);
}
}
ImmutableArray<Conversion> underlyingConversions = conversion.UnderlyingConversions;
for (int i = 0; i < elements.Length; i++)
{
BoundExpression boundExpression3 = elements[i];
Conversion conversion2 = underlyingConversions[i];
BoundExpression boundExpression4 = ((boundExpression3 is BoundCollectionExpressionSpreadElement element) ? bindSpreadElement(element, elementType, conversion2, diagnostics) : CreateConversion(boundExpression3.Syntax, boundExpression3, conversion2, isCast: false, null, wasCompilerGenerated: true, elementType, diagnostics));
instance.Add(boundExpression4);
}
}
return new BoundCollectionExpression((SyntaxNode)(object)syntax, collectionExpressionTypeKind, boundObjectOrCollectionValuePlaceholder, boundExpression, methodSymbol, boundValuePlaceholder, collectionBuilderInvocationConversion, instance.ToImmutableAndFree(), targetType);
BoundExpression bindSpreadElement(BoundCollectionExpressionSpreadElement boundCollectionExpressionSpreadElement, TypeSymbol destination, Conversion elementConversion, BindingDiagnosticBag diagnostics2)
{
ForEachEnumeratorInfo enumeratorInfoOpt = boundCollectionExpressionSpreadElement.EnumeratorInfoOpt;
BoundValuePlaceholder boundValuePlaceholder2 = new BoundValuePlaceholder((SyntaxNode)(object)syntax, enumeratorInfoOpt.ElementType);
BoundExpression expression = CreateConversion(boundCollectionExpressionSpreadElement.Syntax, boundValuePlaceholder2, elementConversion, isCast: false, null, wasCompilerGenerated: true, destination, diagnostics2);
return boundCollectionExpressionSpreadElement.Update(boundCollectionExpressionSpreadElement.Expression, boundCollectionExpressionSpreadElement.ExpressionPlaceholder, boundCollectionExpressionSpreadElement.Conversion, enumeratorInfoOpt, elementPlaceholder: boundValuePlaceholder2, iteratorBody: new BoundExpressionStatement((SyntaxNode)(object)syntax, expression)
{
WasCompilerGenerated = true
}, lengthOrCount: boundCollectionExpressionSpreadElement.LengthOrCount);
}
}
internal bool TryGetCollectionIterationType(ExpressionSyntax syntax, TypeSymbol collectionType, out TypeWithAnnotations iterationType)
{
BoundExpression collectionExpr = new BoundValuePlaceholder((SyntaxNode)(object)syntax, collectionType);
ForEachEnumeratorInfo.Builder builder;
return GetEnumeratorInfoAndInferCollectionElementType((SyntaxNode)(object)syntax, syntax, ref collectionExpr, isAsync: false, BindingDiagnosticBag.Discarded, out iterationType, out builder);
}
private BoundCollectionExpression BindCollectionExpressionForErrorRecovery(BoundUnconvertedCollectionExpression node, TypeSymbol targetType, BindingDiagnosticBag diagnostics)
{
SyntaxNode syntax = node.Syntax;
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(node.Elements.Length);
ImmutableArray<BoundExpression>.Enumerator enumerator = node.Elements.GetEnumerator();
while (enumerator.MoveNext())
{
BoundExpression current = enumerator.Current;
instance.Add(BindToNaturalType(current, diagnostics, !targetType.IsErrorType()));
}
return new BoundCollectionExpression(syntax, CollectionExpressionTypeKind.None, null, null, null, null, null, instance.ToImmutableAndFree(), targetType, hasErrors: true);
}
private void GenerateImplicitConversionErrorForCollectionExpression(BoundUnconvertedCollectionExpression node, TypeSymbol targetType, BindingDiagnosticBag diagnostics)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
TypeWithAnnotations elementType;
CollectionExpressionTypeKind collectionExpressionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, targetType, out elementType);
if (collectionExpressionTypeKind == CollectionExpressionTypeKind.CollectionBuilder && !TryGetCollectionIterationType((ExpressionSyntax)(object)node.Syntax, targetType, out elementType))
{
Error(diagnostics, ErrorCode.ERR_CollectionBuilderNoElementType, SyntaxNodeOrToken.op_Implicit(node.Syntax), targetType);
return;
}
TypeSymbol type = elementType.Type;
if (collectionExpressionTypeKind == CollectionExpressionTypeKind.ImplementsIEnumerableT)
{
NamedTypeSymbol namedTypeSymbol = findSingleIEnumerableTImplementation(targetType, Compilation);
if ((object)namedTypeSymbol != null)
{
type = namedTypeSymbol.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics[0].Type;
}
}
bool flag = false;
if (collectionExpressionTypeKind != CollectionExpressionTypeKind.None && (object)type != null)
{
ImmutableArray<BoundExpression> elements = node.Elements;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
ImmutableArray<BoundExpression>.Enumerator enumerator = elements.GetEnumerator();
while (enumerator.MoveNext())
{
BoundExpression current = enumerator.Current;
if (current is BoundCollectionExpressionSpreadElement boundCollectionExpressionSpreadElement)
{
ForEachEnumeratorInfo enumeratorInfoOpt = boundCollectionExpressionSpreadElement.EnumeratorInfoOpt;
if (enumeratorInfoOpt == null)
{
Error(diagnostics, ErrorCode.ERR_NoImplicitConv, SyntaxNodeOrToken.op_Implicit(boundCollectionExpressionSpreadElement.Expression.Syntax), boundCollectionExpressionSpreadElement.Expression.Display, type);
flag = true;
continue;
}
Conversion collectionExpressionSpreadElementConversion = Conversions.GetCollectionExpressionSpreadElementConversion(boundCollectionExpressionSpreadElement, type, ref useSiteInfo);
if (!collectionExpressionSpreadElementConversion.Exists)
{
GenerateImplicitConversionError(diagnostics, Compilation, boundCollectionExpressionSpreadElement.Expression.Syntax, collectionExpressionSpreadElementConversion, enumeratorInfoOpt.ElementType, type);
flag = true;
}
}
else
{
Conversion conversion = Conversions.ClassifyImplicitConversionFromExpression(current, type, ref useSiteInfo);
if (!conversion.Exists)
{
GenerateImplicitConversionError(diagnostics, current.Syntax, conversion, current, type);
flag = true;
}
}
}
}
if (!flag)
{
Error(diagnostics, ErrorCode.ERR_CollectionExpressionTargetTypeNotConstructible, SyntaxNodeOrToken.op_Implicit(node.Syntax), targetType);
}
static NamedTypeSymbol? findSingleIEnumerableTImplementation(TypeSymbol type2, CSharpCompilation compilation)
{
ImmutableArray<NamedTypeSymbol> allInterfacesOrEffectiveInterfaces = type2.GetAllInterfacesOrEffectiveInterfaces();
NamedTypeSymbol specialType = compilation.GetSpecialType((SpecialType)25);
NamedTypeSymbol namedTypeSymbol2 = null;
ImmutableArray<NamedTypeSymbol>.Enumerator enumerator2 = allInterfacesOrEffectiveInterfaces.GetEnumerator();
while (enumerator2.MoveNext())
{
NamedTypeSymbol current2 = enumerator2.Current;
if ((object)current2.OriginalDefinition == specialType)
{
if ((object)namedTypeSymbol2 != null)
{
return null;
}
namedTypeSymbol2 = current2;
}
}
return namedTypeSymbol2;
}
}
private MethodSymbol? GetCollectionBuilderMethod(NamedTypeSymbol targetType, TypeSymbol elementTypeOriginalDefinition, TypeSymbol? builderType, string? methodName, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out Conversion returnTypeConversion)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Invalid comparison between Unknown and I4
returnTypeConversion = default(Conversion);
if (!SourceNamedTypeSymbol.IsValidCollectionBuilderType(builderType))
{
return null;
}
if (string.IsNullOrEmpty(methodName))
{
return null;
}
NamedTypeSymbol wellKnownType = Compilation.GetWellKnownType((WellKnownType)276);
ImmutableArray<Symbol>.Enumerator enumerator = builderType.GetMembers(methodName).GetEnumerator();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo2 = default(CompoundUseSiteInfo<AssemblySymbol>);
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
MethodSymbol methodSymbol = current as MethodSymbol;
if ((object)methodSymbol == null || !current.IsStatic)
{
continue;
}
useSiteInfo2._002Ector(useSiteInfo);
if (!IsAccessible(methodSymbol, ref useSiteInfo2))
{
continue;
}
ArrayBuilder<TypeWithAnnotations> instance = ArrayBuilder<TypeWithAnnotations>.GetInstance();
targetType.GetAllTypeArgumentsNoUseSiteDiagnostics(instance);
ImmutableArray<TypeWithAnnotations> typeArguments = instance.ToImmutableAndFree();
if (methodSymbol.Arity != typeArguments.Length)
{
continue;
}
ImmutableArray<ParameterSymbol> parameters = methodSymbol.Parameters;
if (parameters.Length != 1)
{
continue;
}
ParameterSymbol parameterSymbol = parameters[0];
if ((object)parameterSymbol == null || (int)parameterSymbol.RefKind != 0)
{
continue;
}
TypeSymbol type = parameterSymbol.Type;
if (!wellKnownType.Equals(type.OriginalDefinition, (TypeCompareKind)63))
{
continue;
}
MethodSymbol methodSymbol2;
if (typeArguments.Length > 0)
{
ImmutableArray<TypeWithAnnotations> typeArguments2 = TypeMap.TypeParametersAsTypeSymbolsWithAnnotations(targetType.OriginalDefinition.GetAllTypeParameters());
methodSymbol2 = methodSymbol.OriginalDefinition.Construct(typeArguments2);
methodSymbol = methodSymbol.Construct(typeArguments);
}
else
{
methodSymbol2 = methodSymbol;
}
TypeSymbol type2 = ((NamedTypeSymbol)methodSymbol2.Parameters[0].Type).TypeArgumentsWithAnnotationsNoUseSiteDiagnostics[0].Type;
if (Conversions.ClassifyImplicitConversionFromType(elementTypeOriginalDefinition, type2, ref useSiteInfo2).IsIdentity)
{
Conversion conversion = Conversions.ClassifyImplicitConversionFromType(methodSymbol2.ReturnType, targetType.OriginalDefinition, ref useSiteInfo2);
ConversionKind kind = conversion.Kind;
if (kind == ConversionKind.Identity || kind - 12 <= ConversionKind.NoConversion)
{
useSiteInfo.AddDiagnostics(useSiteInfo2.Diagnostics);
returnTypeConversion = conversion;
return methodSymbol;
}
}
}
return null;
}
private BoundExpression ConvertConditionalExpression(BoundUnconvertedConditionalOperator source, TypeSymbol destination, Conversion? conversionIfTargetTyped, BindingDiagnosticBag diagnostics, bool hasErrors = false)
{
bool hasValue = conversionIfTargetTyped.HasValue;
ImmutableArray<Conversion> underlyingConversions = conversionIfTargetTyped.GetValueOrDefault().UnderlyingConversions;
BoundExpression condition = source.Condition;
hasErrors |= source.HasErrors || destination.IsErrorType();
BoundExpression boundExpression = (hasValue ? CreateConversion(source.Consequence.Syntax, source.Consequence, underlyingConversions[0], isCast: false, null, destination, diagnostics) : GenerateConversionForAssignment(destination, source.Consequence, diagnostics));
BoundExpression boundExpression2 = (hasValue ? CreateConversion(source.Alternative.Syntax, source.Alternative, underlyingConversions[1], isCast: false, null, destination, diagnostics) : GenerateConversionForAssignment(destination, source.Alternative, diagnostics));
ConstantValue val = FoldConditionalOperator(condition, boundExpression, boundExpression2);
hasErrors |= val != null && val.IsBad;
if (hasValue && !destination.IsErrorType() && !Compilation.IsFeatureEnabled(MessageID.IDS_FeatureTargetTypedConditional))
{
diagnostics.Add(ErrorCode.ERR_NoImplicitConvTargetTypedConditional, source.Syntax.Location, Compilation.LanguageVersion.ToDisplayString(), source.Consequence.Display, source.Alternative.Display, new CSharpRequiredLanguageVersion(MessageID.IDS_FeatureTargetTypedConditional.RequiredVersion()));
}
return new BoundConditionalOperator(source.Syntax, isRef: false, condition, boundExpression, boundExpression2, val, source.Type, hasValue, destination, hasErrors).WithSuppression(source.IsSuppressed);
}
private BoundExpression ConvertSwitchExpression(BoundUnconvertedSwitchExpression source, TypeSymbol destination, Conversion? conversionIfTargetTyped, BindingDiagnosticBag diagnostics, bool hasErrors = false)
{
bool hasValue = conversionIfTargetTyped.HasValue;
ImmutableArray<Conversion> underlyingConversions = (conversionIfTargetTyped ?? Conversion.Identity).UnderlyingConversions;
ArrayBuilder<BoundSwitchExpressionArm> instance = ArrayBuilder<BoundSwitchExpressionArm>.GetInstance(source.SwitchArms.Length);
int i = 0;
for (int length = source.SwitchArms.Length; i < length; i++)
{
BoundSwitchExpressionArm boundSwitchExpressionArm = source.SwitchArms[i];
BoundExpression value = boundSwitchExpressionArm.Value;
BoundExpression boundExpression = (hasValue ? CreateConversion(value.Syntax, value, underlyingConversions[i], isCast: false, null, destination, diagnostics) : GenerateConversionForAssignment(destination, value, diagnostics));
BoundSwitchExpressionArm boundSwitchExpressionArm2 = ((value == boundExpression) ? boundSwitchExpressionArm : new BoundSwitchExpressionArm(boundSwitchExpressionArm.Syntax, boundSwitchExpressionArm.Locals, boundSwitchExpressionArm.Pattern, boundSwitchExpressionArm.WhenClause, boundExpression, boundSwitchExpressionArm.Label, boundSwitchExpressionArm.HasErrors));
instance.Add(boundSwitchExpressionArm2);
}
ImmutableArray<BoundSwitchExpressionArm> switchArms = instance.ToImmutableAndFree();
return new BoundConvertedSwitchExpression(source.Syntax, source.Type, hasValue, source.Expression, switchArms, source.ReachabilityDecisionDag, source.DefaultLabel, source.ReportedNotExhaustive, destination, hasErrors || source.HasErrors).WithSuppression(source.IsSuppressed);
}
private BoundExpression CreateUserDefinedConversion(SyntaxNode syntax, BoundExpression source, Conversion conversion, bool isCast, ConversionGroup conversionGroup, TypeSymbol destination, BindingDiagnosticBag diagnostics, bool hasErrors)
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
if (!conversion.IsValid)
{
if (!hasErrors)
{
GenerateImplicitConversionError(diagnostics, syntax, conversion, source, destination);
}
return new BoundConversion(syntax, source, conversion, CheckOverflowAtRuntime, isCast, conversionGroup, null, destination, hasErrors: true)
{
WasCompilerGenerated = source.WasCompilerGenerated
};
}
BoundExpression boundExpression = CreateConversion(source.Syntax, source, conversion.UserDefinedFromConversion, isCast: false, conversionGroup, wasCompilerGenerated: false, conversion.BestUserDefinedConversionAnalysis.FromType, diagnostics);
TypeSymbol parameterType = conversion.BestUserDefinedConversionAnalysis.Operator.GetParameterType(0);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
if (conversion.BestUserDefinedConversionAnalysis.Kind == UserDefinedConversionAnalysisKind.ApplicableInNormalForm && !TypeSymbol.Equals(conversion.BestUserDefinedConversionAnalysis.FromType, parameterType, (TypeCompareKind)0))
{
boundExpression = CreateConversion(syntax, boundExpression, Conversions.ClassifyStandardConversion(boundExpression.Type, parameterType, ref useSiteInfo), isCast: false, conversionGroup, wasCompilerGenerated: true, parameterType, diagnostics);
}
TypeSymbol returnType = conversion.BestUserDefinedConversionAnalysis.Operator.ReturnType;
TypeSymbol toType = conversion.BestUserDefinedConversionAnalysis.ToType;
Conversion conversion2 = conversion.UserDefinedToConversion;
BoundExpression source2;
if (conversion.BestUserDefinedConversionAnalysis.Kind == UserDefinedConversionAnalysisKind.ApplicableInNormalForm && !TypeSymbol.Equals(toType, returnType, (TypeCompareKind)0))
{
source2 = new BoundConversion(syntax, boundExpression, conversion, CheckOverflowAtRuntime, isCast, conversionGroup, null, returnType)
{
WasCompilerGenerated = true
};
if (toType.IsNullableType() && TypeSymbol.Equals(toType.GetNullableUnderlyingType(), returnType, (TypeCompareKind)0))
{
conversion2 = Conversions.ClassifyConversionFromType(returnType, destination, CheckOverflowAtRuntime, ref useSiteInfo);
}
else
{
source2 = CreateConversion(syntax, source2, Conversions.ClassifyStandardConversion(returnType, toType, ref useSiteInfo), isCast: false, conversionGroup, wasCompilerGenerated: true, toType, diagnostics);
}
}
else
{
source2 = new BoundConversion(syntax, boundExpression, conversion, CheckOverflowAtRuntime, isCast, conversionGroup, null, toType)
{
WasCompilerGenerated = true
};
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(syntax, useSiteInfo);
BoundExpression boundExpression2 = CreateConversion(syntax, source2, conversion2, isCast: false, conversionGroup, wasCompilerGenerated: true, destination, diagnostics);
boundExpression2.ResetCompilerGenerated(source.WasCompilerGenerated);
return boundExpression2;
}
private BoundExpression CreateFunctionTypeConversion(SyntaxNode syntax, BoundExpression source, Conversion conversion, bool isCast, ConversionGroup? conversionGroup, TypeSymbol destination, BindingDiagnosticBag diagnostics)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Invalid comparison between Unknown and I4
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
NamedTypeSymbol namedTypeSymbol = source.GetInferredDelegateType(ref useSiteInfo);
if (source.Kind == BoundKind.UnboundLambda && destination.IsNonGenericExpressionType())
{
namedTypeSymbol = Compilation.GetWellKnownType((WellKnownType)217).Construct(namedTypeSymbol);
namedTypeSymbol.AddUseSiteInfo(ref useSiteInfo);
}
conversion = Conversions.ClassifyConversionFromExpression(source, namedTypeSymbol, CheckOverflowAtRuntime, ref useSiteInfo);
bool flag = source.Kind == BoundKind.MethodGroup && !isCast && conversion.Exists && (int)destination.SpecialType == 1;
BoundExpression boundExpression;
if (!conversion.Exists)
{
GenerateImplicitConversionError(diagnostics, syntax, conversion, source, namedTypeSymbol);
boundExpression = new BoundConversion(syntax, source, conversion, @checked: false, isCast, conversionGroup, null, namedTypeSymbol, hasErrors: true)
{
WasCompilerGenerated = source.WasCompilerGenerated
};
}
else
{
boundExpression = CreateConversion(syntax, source, conversion, isCast, conversionGroup, namedTypeSymbol, diagnostics);
}
conversion = Conversions.ClassifyConversionFromExpression(boundExpression, destination, CheckOverflowAtRuntime, ref useSiteInfo);
if (!conversion.Exists)
{
GenerateImplicitConversionError(diagnostics, syntax, conversion, source, destination);
}
else if (flag)
{
Error(diagnostics, ErrorCode.WRN_MethGrpToNonDel, SyntaxNodeOrToken.op_Implicit(syntax), ((BoundMethodGroup)source).Name, destination);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(syntax, useSiteInfo);
return CreateConversion(syntax, boundExpression, conversion, isCast, conversionGroup, destination, diagnostics);
}
private BoundExpression CreateAnonymousFunctionConversion(SyntaxNode syntax, BoundExpression source, Conversion conversion, bool isCast, ConversionGroup? conversionGroup, TypeSymbol destination, BindingDiagnosticBag diagnostics)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
bool isGenericType;
BoundLambda boundLambda = ((UnboundLambda)source).Bind((NamedTypeSymbol)destination, destination.IsGenericOrNonGenericExpressionType(out isGenericType)).WithInAnonymousFunctionConversion();
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(boundLambda.Diagnostics, false);
CheckParameterModifierMismatchMethodConversion(syntax, boundLambda.Symbol, destination, invokedAsExtensionMethod: false, diagnostics);
CheckLambdaConversion(boundLambda.Symbol, destination, diagnostics);
return new BoundConversion(syntax, boundLambda, conversion, @checked: false, isCast, conversionGroup, null, destination)
{
WasCompilerGenerated = source.WasCompilerGenerated
};
}
private BoundExpression CreateMethodGroupConversion(SyntaxNode syntax, BoundExpression source, Conversion conversion, bool isCast, ConversionGroup? conversionGroup, TypeSymbol destination, BindingDiagnosticBag diagnostics)
{
(BoundMethodGroup, bool) tuple;
if (!(source is BoundMethodGroup item))
{
if (source is BoundUnconvertedAddressOfOperator boundUnconvertedAddressOfOperator)
{
BoundMethodGroup operand = boundUnconvertedAddressOfOperator.Operand;
if (operand != null)
{
tuple = (operand, true);
goto IL_0046;
}
}
throw ExceptionUtilities.UnexpectedValue((object)source);
}
tuple = (item, false);
goto IL_0046;
IL_0046:
(BoundMethodGroup, bool) tuple2 = tuple;
BoundMethodGroup item2 = tuple2.Item1;
bool item3 = tuple2.Item2;
BoundMethodGroup boundMethodGroup = FixMethodGroupWithTypeOrValue(item2, conversion, diagnostics);
bool hasErrors = false;
if (MethodGroupConversionHasErrors(syntax, conversion, boundMethodGroup.ReceiverOpt, conversion.IsExtensionMethod, item3, destination, diagnostics))
{
hasErrors = true;
}
return new BoundConversion(syntax, boundMethodGroup, conversion, @checked: false, isCast, conversionGroup, null, destination, hasErrors)
{
WasCompilerGenerated = boundMethodGroup.WasCompilerGenerated
};
}
private static void CheckParameterModifierMismatchMethodConversion(SyntaxNode syntax, MethodSymbol lambdaOrMethod, TypeSymbol targetType, bool invokedAsExtensionMethod, BindingDiagnosticBag diagnostics)
{
NamedTypeSymbol delegateType = targetType.GetDelegateType();
MethodSymbol methodSymbol;
if ((object)delegateType != null)
{
methodSymbol = delegateType.DelegateInvokeMethod;
}
else
{
if (!(targetType is FunctionPointerTypeSymbol functionPointerTypeSymbol))
{
return;
}
methodSymbol = functionPointerTypeSymbol.Signature;
}
if (SourceMemberContainerTypeSymbol.RequiresValidScopedOverrideForRefSafety(methodSymbol))
{
SourceMemberContainerTypeSymbol.CheckValidScopedOverride(methodSymbol, lambdaOrMethod, diagnostics, delegate(BindingDiagnosticBag bindingDiagnosticBag, MethodSymbol delegateMethod, MethodSymbol overrideMethod, ParameterSymbol parameter, bool _, (TypeSymbol Type, SyntaxNode Syntax) typeAndSyntax)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
bindingDiagnosticBag.Add(SourceMemberContainerTypeSymbol.ReportInvalidScopedOverrideAsError(delegateMethod, overrideMethod) ? ErrorCode.ERR_ScopedMismatchInParameterOfTarget : ErrorCode.WRN_ScopedMismatchInParameterOfTarget, typeAndSyntax.Syntax.Location, (object)new FormattedSymbol((ISymbolInternal)(object)parameter, SymbolDisplayFormat.ShortFormat), typeAndSyntax.Type);
}, (targetType, syntax), allowVariance: true, invokedAsExtensionMethod);
}
SourceMemberContainerTypeSymbol.CheckRefReadonlyInMismatch(methodSymbol, lambdaOrMethod, diagnostics, delegate(BindingDiagnosticBag bindingDiagnosticBag, MethodSymbol delegateMethod, MethodSymbol methodSymbol2, ParameterSymbol lambdaOrMethodParameter, bool _, (ParameterSymbol BaseParameter, Location Arg) arg)
{
var (parameterSymbol, location) = arg;
bindingDiagnosticBag.Add(ErrorCode.WRN_TargetDifferentRefness, location, lambdaOrMethodParameter, parameterSymbol);
}, syntax.Location, invokedAsExtensionMethod);
}
private static void CheckLambdaConversion(LambdaSymbol lambdaSymbol, TypeSymbol targetType, BindingDiagnosticBag diagnostics)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Invalid comparison between Unknown and I4
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol? delegateType = targetType.GetDelegateType();
bool flag = delegateType.DelegateInvokeMethod?.OriginalDefinition is SynthesizedDelegateInvokeMethod;
ImmutableArray<ParameterSymbol> immutableArray = delegateType.DelegateParameters();
for (int num = 0; num < lambdaSymbol.ParameterCount; num++)
{
ParameterSymbol parameterSymbol = lambdaSymbol.Parameters[num];
ParameterSymbol parameterSymbol2 = immutableArray[num];
if (flag)
{
ConstantValue explicitDefaultConstantValue = parameterSymbol2.ExplicitDefaultConstantValue;
if (explicitDefaultConstantValue != null)
{
if (parameterSymbol is SourceComplexParameterSymbolBase sourceComplexParameterSymbolBase)
{
ConstantValue explicitDefaultConstantValue2 = sourceComplexParameterSymbolBase.ExplicitDefaultConstantValue;
if (explicitDefaultConstantValue2 != null && explicitDefaultConstantValue2.IsDecimal && sourceComplexParameterSymbolBase.DefaultValueFromAttributes == null)
{
goto IL_00df;
}
}
SpecialType specialType = explicitDefaultConstantValue.SpecialType;
WellKnownMember? val = (((int)specialType == 17) ? new WellKnownMember?((WellKnownMember)109) : (((int)specialType != 33) ? ((WellKnownMember?)null) : new WellKnownMember?((WellKnownMember)108)));
WellKnownMember? val2 = val;
if (val2.HasValue)
{
reportUseSiteDiagnosticForSynthesizedAttribute(lambdaSymbol, parameterSymbol, val2.GetValueOrDefault(), diagnostics);
}
}
goto IL_00df;
}
goto IL_00f5;
IL_00df:
if (parameterSymbol2.HasUnscopedRefAttribute)
{
reportUseSiteDiagnosticForSynthesizedAttribute(lambdaSymbol, parameterSymbol, (WellKnownMember)477, diagnostics);
}
goto IL_00f5;
IL_00f5:
if (!((SyntaxNode?)(object)lambdaSymbol.SyntaxNode).IsKind(SyntaxKind.AnonymousMethodExpression))
{
if (parameterSymbol.HasExplicitDefaultValue)
{
ConstantValue explicitDefaultConstantValue3 = parameterSymbol.ExplicitDefaultConstantValue;
if (explicitDefaultConstantValue3 != null && !explicitDefaultConstantValue3.IsBad)
{
ConstantValue val3 = (parameterSymbol2.HasExplicitDefaultValue ? parameterSymbol2.ExplicitDefaultConstantValue : null);
if ((val3 == null || !val3.IsBad) && explicitDefaultConstantValue3 != val3)
{
Error(diagnostics, ErrorCode.WRN_OptionalParamValueMismatch, parameterSymbol.GetFirstLocation(), num + 1, explicitDefaultConstantValue3, val3 ?? ((object)MessageID.IDS_Missing.Localize()));
}
}
}
if (parameterSymbol.IsParams && !parameterSymbol2.IsParams && num == lambdaSymbol.ParameterCount - 1 && parameterSymbol.Type.IsSZArray())
{
Error(diagnostics, ErrorCode.WRN_ParamsArrayInLambdaOnly, parameterSymbol.GetFirstLocation(), num + 1);
}
}
}
static void reportUseSiteDiagnosticForSynthesizedAttribute(LambdaSymbol lambdaSymbol2, ParameterSymbol lambdaParameter, WellKnownMember member, BindingDiagnosticBag diagnostics2)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ReportUseSiteDiagnosticForSynthesizedAttribute(lambdaSymbol2.DeclaringCompilation, member, diagnostics2, lambdaParameter.TryGetFirstLocation() ?? ((SyntaxNode)lambdaSymbol2.SyntaxNode).Location);
}
}
private BoundExpression CreateStackAllocConversion(SyntaxNode syntax, BoundExpression source, Conversion conversion, bool isCast, ConversionGroup? conversionGroup, TypeSymbol destination, BindingDiagnosticBag diagnostics)
{
BoundStackAllocArrayCreation boundStackAllocArrayCreation = (BoundStackAllocArrayCreation)source;
TypeSymbol elementType = boundStackAllocArrayCreation.ElementType;
TypeSymbol type;
switch (conversion.Kind)
{
case ConversionKind.StackAllocToPointerType:
ReportUnsafeIfNotAllowed(syntax.Location, diagnostics);
type = new PointerTypeSymbol(TypeWithAnnotations.Create(elementType));
break;
case ConversionKind.StackAllocToSpanType:
CheckFeatureAvailability(syntax, MessageID.IDS_FeatureRefStructs, diagnostics);
type = Compilation.GetWellKnownType((WellKnownType)275).Construct(elementType);
break;
default:
throw ExceptionUtilities.UnexpectedValue((object)conversion.Kind);
}
BoundConvertedStackAllocExpression source2 = new BoundConvertedStackAllocExpression(syntax, elementType, boundStackAllocArrayCreation.Count, boundStackAllocArrayCreation.InitializerOpt, type, boundStackAllocArrayCreation.HasErrors);
Conversion conversion2 = conversion.UnderlyingConversions.Single();
return CreateConversion(syntax, source2, conversion2, isCast, conversionGroup, destination, diagnostics);
}
private BoundExpression CreateTupleLiteralConversion(SyntaxNode syntax, BoundTupleLiteral sourceTuple, Conversion conversion, bool isCast, ConversionGroup? conversionGroup, TypeSymbol destination, BindingDiagnosticBag diagnostics)
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
TypeSymbol typeSymbol = destination;
Conversion conversion2 = conversion;
if (conversion.IsNullable)
{
typeSymbol = destination.GetNullableUnderlyingType();
conversion2 = conversion.UnderlyingConversions[0];
}
NamedTypeSymbol namedTypeSymbol = (NamedTypeSymbol)typeSymbol;
if (namedTypeSymbol.IsTupleType)
{
NamedTypeSymbol.ReportTupleNamesMismatchesIfAny(namedTypeSymbol, sourceTuple, diagnostics);
if (sourceTuple.Type is NamedTypeSymbol { IsTupleType: not false } namedTypeSymbol2)
{
namedTypeSymbol = namedTypeSymbol.WithTupleDataFrom(namedTypeSymbol2);
}
else
{
TupleExpressionSyntax tupleExpressionSyntax = (TupleExpressionSyntax)(object)sourceTuple.Syntax;
ArrayBuilder<Location> instance = ArrayBuilder<Location>.GetInstance();
Enumerator<ArgumentSyntax> enumerator = tupleExpressionSyntax.Arguments.GetEnumerator();
while (enumerator.MoveNext())
{
ArgumentSyntax current = enumerator.Current;
NameColonSyntax? nameColon = current.NameColon;
instance.Add((nameColon != null) ? ((SyntaxNode)nameColon.Name).Location : null);
}
namedTypeSymbol = namedTypeSymbol.WithElementNames(sourceTuple.ArgumentNamesOpt, instance.ToImmutableAndFree(), default(ImmutableArray<bool>), ImmutableArray.Create<Location>(((SyntaxNode)tupleExpressionSyntax).Location));
}
}
ImmutableArray<BoundExpression> arguments = sourceTuple.Arguments;
ArrayBuilder<BoundExpression> instance2 = ArrayBuilder<BoundExpression>.GetInstance(arguments.Length);
ImmutableArray<TypeWithAnnotations> tupleElementTypesWithAnnotations = namedTypeSymbol.TupleElementTypesWithAnnotations;
ImmutableArray<Conversion> underlyingConversions = conversion2.UnderlyingConversions;
for (int i = 0; i < arguments.Length; i++)
{
BoundExpression boundExpression = arguments[i];
TypeWithAnnotations explicitType = tupleElementTypesWithAnnotations[i];
Conversion conversion3 = underlyingConversions[i];
ConversionGroup conversionGroupOpt = (isCast ? new ConversionGroup(conversion3, explicitType) : null);
instance2.Add(CreateConversion(boundExpression.Syntax, boundExpression, conversion3, isCast, conversionGroupOpt, explicitType.Type, diagnostics));
}
BoundExpression boundExpression2 = new BoundConvertedTupleLiteral(sourceTuple.Syntax, sourceTuple, wasTargetTyped: true, instance2.ToImmutableAndFree(), sourceTuple.ArgumentNamesOpt, sourceTuple.InferredNamesOpt, namedTypeSymbol).WithSuppression(sourceTuple.IsSuppressed);
if (!TypeSymbol.Equals(sourceTuple.Type, destination, (TypeCompareKind)0))
{
boundExpression2 = new BoundConversion(sourceTuple.Syntax, boundExpression2, conversion, @checked: false, isCast, conversionGroup, null, destination);
}
if (isCast)
{
boundExpression2 = new BoundConversion(syntax, boundExpression2, Conversion.Identity, @checked: false, isCast, conversionGroup, null, destination);
}
return boundExpression2;
}
private static bool IsMethodGroupWithTypeOrValueReceiver(BoundNode node)
{
if (node.Kind != BoundKind.MethodGroup)
{
return false;
}
return IsTypeOrValueExpression(((BoundMethodGroup)node).ReceiverOpt);
}
private BoundMethodGroup FixMethodGroupWithTypeOrValue(BoundMethodGroup group, Conversion conversion, BindingDiagnosticBag diagnostics)
{
if (!IsMethodGroupWithTypeOrValueReceiver(group))
{
return group;
}
BoundExpression receiverOpt = group.ReceiverOpt;
BoundExpression receiver = receiverOpt;
MethodSymbol? method = conversion.Method;
receiverOpt = ReplaceTypeOrValueReceiver(receiver, (object)method != null && !method.RequiresInstanceReceiver && !conversion.IsExtensionMethod, diagnostics);
return group.Update(group.TypeArgumentsOpt, group.Name, group.Methods, group.LookupSymbolOpt, group.LookupError, group.Flags, group.FunctionType, receiverOpt, group.ResultKind);
}
private bool MemberGroupFinalValidation(BoundExpression? receiverOpt, MethodSymbol methodSymbol, SyntaxNode node, BindingDiagnosticBag diagnostics, bool invokedAsExtensionMethod)
{
if (!IsBadBaseAccess(node, receiverOpt, methodSymbol, diagnostics))
{
CheckReceiverAndRuntimeSupportForSymbolAccess(node, receiverOpt, methodSymbol, diagnostics);
}
if (MemberGroupFinalValidationAccessibilityChecks(receiverOpt, methodSymbol, node, diagnostics, invokedAsExtensionMethod))
{
return true;
}
return !methodSymbol.CheckConstraints(new ConstraintsHelper.CheckConstraintsArgs(Compilation, Conversions, includeNullability: false, node.Location, diagnostics));
}
private bool MemberGroupFinalValidationAccessibilityChecks(BoundExpression? receiverOpt, Symbol memberSymbol, SyntaxNode node, BindingDiagnosticBag diagnostics, bool invokedAsExtensionMethod)
{
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
if (!IsTypeOrValueExpression(receiverOpt))
{
if (!memberSymbol.RequiresInstanceReceiver())
{
if (invokedAsExtensionMethod)
{
if (IsMemberAccessedThroughType(receiverOpt))
{
if (receiverOpt.Kind == BoundKind.QueryClause)
{
diagnostics.Add(ErrorCode.ERR_QueryNoProvider, node.Location, receiverOpt.Type, memberSymbol.Name);
}
else
{
diagnostics.Add(ErrorCode.ERR_ObjectRequired, node.Location, memberSymbol);
}
return true;
}
}
else if (!WasImplicitReceiver(receiverOpt) && IsMemberAccessedThroughVariableOrValue(receiverOpt))
{
if (Flags.Includes(BinderFlags.CollectionInitializerAddMethod))
{
diagnostics.Add(ErrorCode.ERR_InitializerAddHasWrongSignature, node.Location, memberSymbol);
}
else if (node.Kind() == SyntaxKind.AwaitExpression && memberSymbol.Name == "GetAwaiter")
{
diagnostics.Add(ErrorCode.ERR_BadAwaitArg, node.Location, receiverOpt.Type);
}
else
{
diagnostics.Add(ErrorCode.ERR_ObjectProhibited, node.Location, memberSymbol);
}
return true;
}
}
else
{
if (IsMemberAccessedThroughType(receiverOpt))
{
diagnostics.Add(ErrorCode.ERR_ObjectRequired, node.Location, memberSymbol);
return true;
}
if (WasImplicitReceiver(receiverOpt))
{
if ((InFieldInitializer && !ContainingType.IsScriptClass) || InConstructorInitializer || InAttributeArgument)
{
SyntaxNode val = node;
if (node.Parent != null && node.Parent.Kind() == SyntaxKind.InvocationExpression)
{
val = node.Parent;
}
ErrorCode code = (InFieldInitializer ? ErrorCode.ERR_FieldInitRefNonstatic : ErrorCode.ERR_ObjectRequired);
diagnostics.Add(code, val.Location, memberSymbol);
return true;
}
if (receiverOpt == null || ContainingMember().IsStatic)
{
Error(diagnostics, ErrorCode.ERR_ObjectRequired, SyntaxNodeOrToken.op_Implicit(node), memberSymbol);
return true;
}
}
}
}
NamedTypeSymbol containingType = ContainingType;
if ((object)containingType != null)
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
bool num = IsSymbolAccessibleConditional(memberSymbol.GetTypeOrReturnType().Type, containingType, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
if (!num)
{
Error(diagnostics, ErrorCode.ERR_BadAccess, SyntaxNodeOrToken.op_Implicit(node), memberSymbol);
return true;
}
}
return false;
}
private static bool IsMemberAccessedThroughVariableOrValue(BoundExpression? receiverOpt)
{
if (receiverOpt == null)
{
return false;
}
return !IsMemberAccessedThroughType(receiverOpt);
}
internal static bool IsMemberAccessedThroughType([NotNullWhen(true)] BoundExpression? receiverOpt)
{
if (receiverOpt == null)
{
return false;
}
while (receiverOpt.Kind == BoundKind.QueryClause)
{
receiverOpt = ((BoundQueryClause)receiverOpt).Value;
}
return receiverOpt.Kind == BoundKind.TypeExpression;
}
internal static bool WasImplicitReceiver([NotNullWhen(false)] BoundExpression? receiverOpt)
{
if (receiverOpt == null)
{
return true;
}
if (!receiverOpt.WasCompilerGenerated)
{
return false;
}
BoundKind kind = receiverOpt.Kind;
if (kind - 110 <= BoundKind.ParameterEqualsValue)
{
return true;
}
return false;
}
internal bool MethodIsCompatibleWithDelegateOrFunctionPointer(BoundExpression? receiverOpt, bool isExtensionMethod, MethodSymbol method, TypeSymbol delegateType, Location errorLocation, BindingDiagnosticBag diagnostics)
{
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Invalid comparison between Unknown and I4
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
MethodSymbol methodSymbol;
if (delegateType is NamedTypeSymbol namedTypeSymbol)
{
MethodSymbol delegateInvokeMethod = namedTypeSymbol.DelegateInvokeMethod;
if ((object)delegateInvokeMethod != null)
{
methodSymbol = delegateInvokeMethod;
goto IL_004c;
}
}
else if (delegateType is FunctionPointerTypeSymbol functionPointerTypeSymbol)
{
FunctionPointerMethodSymbol signature = functionPointerTypeSymbol.Signature;
if ((object)signature != null)
{
methodSymbol = signature;
goto IL_004c;
}
}
throw ExceptionUtilities.UnexpectedValue((object)delegateType);
IL_004c:
MethodSymbol methodSymbol2 = methodSymbol;
ImmutableArray<ParameterSymbol> parameters = methodSymbol2.Parameters;
ImmutableArray<ParameterSymbol> parameters2 = method.Parameters;
int length = parameters.Length;
if (parameters2.Length != length + (isExtensionMethod ? 1 : 0))
{
Error(diagnostics, getMethodMismatchErrorCode(delegateType.TypeKind), errorLocation, method, delegateType);
return false;
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
useSiteInfo._002Ector(useSiteInfo);
for (int i = 0; i < length; i++)
{
ParameterSymbol parameterSymbol = parameters[i];
ParameterSymbol parameterSymbol2 = parameters2[isExtensionMethod ? (i + 1) : i];
if (!hasConversion(this, delegateType.TypeKind, Conversions, parameterSymbol.Type, parameterSymbol2.Type, parameterSymbol.RefKind, parameterSymbol2.RefKind, ref useSiteInfo))
{
Error(diagnostics, getMethodMismatchErrorCode(delegateType.TypeKind), errorLocation, method, delegateType);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(errorLocation, useSiteInfo);
return false;
}
}
if (methodSymbol2.RefKind != method.RefKind)
{
Error(diagnostics, getRefMismatchErrorCode(delegateType.TypeKind), errorLocation, method, delegateType);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(errorLocation, useSiteInfo);
return false;
}
TypeSymbol returnType = method.ReturnType;
TypeSymbol returnType2 = methodSymbol2.ReturnType;
bool flag = default(bool);
if ((object)methodSymbol2 != null)
{
RefKind refKind = methodSymbol2.RefKind;
flag = (((int)refKind != 0 || !methodSymbol2.ReturnsVoid) ? hasConversion(this, delegateType.TypeKind, Conversions, returnType, returnType2, method.RefKind, refKind, ref useSiteInfo) : method.ReturnsVoid);
}
else
{
global::_003CPrivateImplementationDetails_003E.ThrowInvalidOperationException();
}
if (!flag)
{
Error(diagnostics, ErrorCode.ERR_BadRetType, errorLocation, method, method.ReturnType);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(errorLocation, useSiteInfo);
return false;
}
if (delegateType.IsFunctionPointer())
{
if (isExtensionMethod)
{
Error(diagnostics, ErrorCode.ERR_CannotUseReducedExtensionMethodInAddressOf, errorLocation);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(errorLocation, useSiteInfo);
return false;
}
if (!method.IsStatic)
{
Error(diagnostics, ErrorCode.ERR_FuncPtrMethMustBeStatic, errorLocation, method);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(errorLocation, useSiteInfo);
return false;
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(errorLocation, useSiteInfo);
return true;
static ErrorCode getMethodMismatchErrorCode(TypeKind type)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if ((int)type == 3)
{
return ErrorCode.ERR_MethDelegateMismatch;
}
if ((int)type != 13)
{
throw ExceptionUtilities.UnexpectedValue((object)type);
}
return ErrorCode.ERR_MethFuncPtrMismatch;
}
static ErrorCode getRefMismatchErrorCode(TypeKind type)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
if ((int)type == 3)
{
return ErrorCode.ERR_DelegateRefMismatch;
}
if ((int)type != 13)
{
throw ExceptionUtilities.UnexpectedValue((object)type);
}
return ErrorCode.ERR_FuncPtrRefMismatch;
}
static bool hasConversion(Binder binder, TypeKind targetKind, Conversions conversions, TypeSymbol source, TypeSymbol destination, RefKind sourceRefKind, RefKind destinationRefKind, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo2)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Invalid comparison between Unknown and I4
if (!Microsoft.CodeAnalysis.CSharp.OverloadResolution.AreRefsCompatibleForMethodConversion(sourceRefKind, destinationRefKind, binder.Compilation))
{
return false;
}
if ((int)sourceRefKind != 0)
{
return ConversionsBase.HasIdentityConversion(source, destination);
}
if (conversions.HasIdentityOrImplicitReferenceConversion(source, destination, ref useSiteInfo2))
{
return true;
}
if ((int)targetKind == 13)
{
if (!ConversionsBase.HasImplicitPointerToVoidConversion(source, destination))
{
return conversions.HasImplicitPointerConversion(source, destination, ref useSiteInfo2);
}
return true;
}
return false;
}
}
private bool MethodGroupConversionHasErrors(SyntaxNode syntax, Conversion conversion, BoundExpression? receiverOpt, bool isExtensionMethod, bool isAddressOf, TypeSymbol delegateOrFuncPtrType, BindingDiagnosticBag diagnostics)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
MethodSymbol method = conversion.Method;
if (!Conversions.IsAssignableFromMulticastDelegate(delegateOrFuncPtrType, ref useSiteInfo) && (!MethodIsCompatibleWithDelegateOrFunctionPointer(receiverOpt, isExtensionMethod, method, delegateOrFuncPtrType, syntax.Location, diagnostics) || MemberGroupFinalValidation(receiverOpt, method, syntax, diagnostics, isExtensionMethod)))
{
return true;
}
if (method.IsConditional)
{
Error(diagnostics, ErrorCode.ERR_DelegateOnConditional, syntax.Location, method);
return true;
}
if (method is SourceOrdinaryMethodSymbol { IsPartialWithoutImplementation: not false })
{
Error(diagnostics, ErrorCode.ERR_PartialMethodToDelegate, syntax.Location, method);
return true;
}
if ((method.HasParameterContainingPointerType() || method.ReturnType.ContainsPointer()) && ReportUnsafeIfNotAllowed(syntax, diagnostics))
{
return true;
}
CheckParameterModifierMismatchMethodConversion(syntax, method, delegateOrFuncPtrType, isExtensionMethod, diagnostics);
if (!isAddressOf)
{
ReportDiagnosticsIfUnmanagedCallersOnly(diagnostics, method, SyntaxNodeOrToken.op_Implicit(syntax), isDelegateConversion: true);
}
ReportDiagnosticsIfObsolete(diagnostics, method, SyntaxNodeOrToken.op_Implicit(syntax), hasBaseReceiver: false);
return false;
}
private bool MethodGroupConversionDoesNotExistOrHasErrors(BoundMethodGroup boundMethodGroup, NamedTypeSymbol delegateType, Location delegateMismatchLocation, BindingDiagnosticBag diagnostics, out Conversion conversion)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
if (ReportDelegateInvokeUseSiteDiagnostic(diagnostics, delegateType, delegateMismatchLocation))
{
conversion = Conversion.NoConversion;
return true;
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
conversion = Conversions.GetMethodGroupDelegateConversion(boundMethodGroup, delegateType, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(delegateMismatchLocation, useSiteInfo);
if (!conversion.Exists)
{
if (!Microsoft.CodeAnalysis.CSharp.Conversions.ReportDelegateOrFunctionPointerMethodGroupDiagnostics(this, boundMethodGroup, delegateType, diagnostics))
{
diagnostics.Add(ErrorCode.ERR_MethDelegateMismatch, delegateMismatchLocation, boundMethodGroup.Name, delegateType);
}
return true;
}
return MethodGroupConversionHasErrors(boundMethodGroup.Syntax, conversion, boundMethodGroup.ReceiverOpt, conversion.IsExtensionMethod, isAddressOf: false, delegateType, diagnostics);
}
public ConstantValue? FoldConstantConversion(SyntaxNode syntax, BoundExpression source, Conversion conversion, TypeSymbol destination, BindingDiagnosticBag diagnostics)
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Invalid comparison between Unknown and I4
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Invalid comparison between Unknown and I4
ConstantValue constantValueOpt = source.ConstantValueOpt;
if (constantValueOpt == (ConstantValue)null)
{
if (conversion.Kind == ConversionKind.DefaultLiteral)
{
return destination.GetDefaultValue();
}
return constantValueOpt;
}
if (constantValueOpt.IsBad)
{
return constantValueOpt;
}
if (source.HasAnyErrors)
{
return null;
}
switch (conversion.Kind)
{
case ConversionKind.Identity:
{
SpecialType specialType = destination.SpecialType;
if ((int)specialType != 18)
{
if ((int)specialType == 19)
{
return ConstantValue.Create(constantValueOpt.DoubleValue);
}
return constantValueOpt;
}
return ConstantValue.Create(constantValueOpt.SingleValue);
}
case ConversionKind.NullLiteral:
return constantValueOpt;
case ConversionKind.ImplicitConstant:
return FoldConstantNumericConversion(syntax, constantValueOpt, destination, diagnostics);
case ConversionKind.ImplicitNumeric:
case ConversionKind.ImplicitEnumeration:
case ConversionKind.ExplicitNumeric:
case ConversionKind.ExplicitEnumeration:
if (destination.IsNullableType())
{
return null;
}
return FoldConstantNumericConversion(syntax, constantValueOpt, destination, diagnostics);
case ConversionKind.ImplicitReference:
case ConversionKind.ExplicitReference:
if (!constantValueOpt.IsNull)
{
return null;
}
return constantValueOpt;
default:
return null;
}
}
private ConstantValue? FoldConstantNumericConversion(SyntaxNode syntax, ConstantValue sourceValue, TypeSymbol destination, BindingDiagnosticBag diagnostics)
{
//IL_001f: 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_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Invalid comparison between Unknown and I4
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Invalid comparison between Unknown and I4
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Invalid comparison between Unknown and I4
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
SpecialType val = (((object)destination == null || !destination.IsEnumType()) ? destination.GetSpecialTypeSafe() : ((NamedTypeSymbol)destination).EnumUnderlyingType.SpecialType);
bool maySucceedAtRuntime;
if (sourceValue.IsDecimal)
{
if (!CheckConstantBounds(val, sourceValue, out maySucceedAtRuntime))
{
Error(diagnostics, ErrorCode.ERR_ConstOutOfRange, SyntaxNodeOrToken.op_Implicit(syntax), sourceValue.Value?.ToString() + "M", destination);
return ConstantValue.Bad;
}
}
else if ((int)val == 17)
{
if (!CheckConstantBounds(val, sourceValue, out maySucceedAtRuntime))
{
Error(diagnostics, ErrorCode.ERR_ConstOutOfRange, SyntaxNodeOrToken.op_Implicit(syntax), sourceValue.Value, destination);
return ConstantValue.Bad;
}
}
else if (CheckOverflowAtCompileTime)
{
if (!CheckConstantBounds(val, sourceValue, out var maySucceedAtRuntime2))
{
if (maySucceedAtRuntime2)
{
Error(diagnostics, ErrorCode.WRN_ConstOutOfRangeChecked, SyntaxNodeOrToken.op_Implicit(syntax), sourceValue.Value, destination);
return null;
}
Error(diagnostics, ErrorCode.ERR_ConstOutOfRangeChecked, SyntaxNodeOrToken.op_Implicit(syntax), sourceValue.Value, destination);
return ConstantValue.Bad;
}
}
else if (((int)val == 21 || (int)val == 22) && !CheckConstantBounds(val, sourceValue, out maySucceedAtRuntime))
{
return null;
}
return ConstantValue.Create(DoUncheckedConversion(val, sourceValue), val);
}
private static object DoUncheckedConversion(SpecialType destinationType, ConstantValue value)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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)
//IL_0051: Expected I4, but got Unknown
//IL_0514: Unknown result type (might be due to invalid IL or missing references)
//IL_0516: Unknown result type (might be due to invalid IL or missing references)
//IL_0558: Expected I4, but got Unknown
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected I4, but got Unknown
//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0625: Expected I4, but got Unknown
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Expected I4, but got Unknown
//IL_06af: Unknown result type (might be due to invalid IL or missing references)
//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
//IL_06f3: Expected I4, but got Unknown
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Expected I4, but got Unknown
//IL_0788: Unknown result type (might be due to invalid IL or missing references)
//IL_078a: Unknown result type (might be due to invalid IL or missing references)
//IL_07cc: Expected I4, but got Unknown
//IL_0365: Unknown result type (might be due to invalid IL or missing references)
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_03a9: Expected I4, but got Unknown
//IL_0866: Unknown result type (might be due to invalid IL or missing references)
//IL_0868: Unknown result type (might be due to invalid IL or missing references)
//IL_08aa: Expected I4, but got Unknown
//IL_0445: Unknown result type (might be due to invalid IL or missing references)
//IL_0447: Unknown result type (might be due to invalid IL or missing references)
//IL_0485: Expected I4, but got Unknown
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Expected I4, but got Unknown
//IL_0b6f: Unknown result type (might be due to invalid IL or missing references)
//IL_0937: Unknown result type (might be due to invalid IL or missing references)
//IL_0a46: Unknown result type (might be due to invalid IL or missing references)
//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_069b: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_0774: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Unknown result type (might be due to invalid IL or missing references)
//IL_0852: Unknown result type (might be due to invalid IL or missing references)
//IL_0431: Unknown result type (might be due to invalid IL or missing references)
//IL_092b: Unknown result type (might be due to invalid IL or missing references)
//IL_0500: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_095a: Unknown result type (might be due to invalid IL or missing references)
//IL_095c: Unknown result type (might be due to invalid IL or missing references)
//IL_099e: Expected I4, but got Unknown
//IL_0a65: Unknown result type (might be due to invalid IL or missing references)
//IL_0a67: Unknown result type (might be due to invalid IL or missing references)
//IL_0aa9: Expected I4, but got Unknown
//IL_0a1a: Unknown result type (might be due to invalid IL or missing references)
//IL_0a21: Invalid comparison between Unknown and I4
//IL_0a3a: Unknown result type (might be due to invalid IL or missing references)
//IL_0b62: Unknown result type (might be due to invalid IL or missing references)
ConstantValueTypeDiscriminator discriminator = value.Discriminator;
bool maySucceedAtRuntime;
switch (discriminator - 2)
{
case 1:
{
byte byteValue = value.ByteValue;
switch (destinationType - 8)
{
case 2:
return byteValue;
case 0:
return (char)byteValue;
case 4:
return (ushort)byteValue;
case 6:
return (uint)byteValue;
case 8:
return (ulong)byteValue;
case 1:
return (sbyte)byteValue;
case 3:
return (short)byteValue;
case 5:
return (int)byteValue;
case 7:
return (long)byteValue;
case 13:
return (int)byteValue;
case 14:
return (uint)byteValue;
case 10:
case 11:
return (double)(int)byteValue;
case 9:
return (decimal)byteValue;
default:
throw ExceptionUtilities.UnexpectedValue((object)destinationType);
}
}
case 10:
{
char charValue = value.CharValue;
switch (destinationType - 8)
{
case 2:
return (byte)charValue;
case 0:
return charValue;
case 4:
return (ushort)charValue;
case 6:
return (uint)charValue;
case 8:
return (ulong)charValue;
case 1:
return (sbyte)charValue;
case 3:
return (short)charValue;
case 5:
return (int)charValue;
case 7:
return (long)charValue;
case 13:
return (int)charValue;
case 14:
return (uint)charValue;
case 10:
case 11:
return (double)(int)charValue;
case 9:
return (decimal)charValue;
default:
throw ExceptionUtilities.UnexpectedValue((object)destinationType);
}
}
case 3:
{
ushort uInt16Value = value.UInt16Value;
switch (destinationType - 8)
{
case 2:
return (byte)uInt16Value;
case 0:
return (char)uInt16Value;
case 4:
return uInt16Value;
case 6:
return (uint)uInt16Value;
case 8:
return (ulong)uInt16Value;
case 1:
return (sbyte)uInt16Value;
case 3:
return (short)uInt16Value;
case 5:
return (int)uInt16Value;
case 7:
return (long)uInt16Value;
case 13:
return (int)uInt16Value;
case 14:
return (uint)uInt16Value;
case 10:
case 11:
return (double)(int)uInt16Value;
case 9:
return (decimal)uInt16Value;
default:
throw ExceptionUtilities.UnexpectedValue((object)destinationType);
}
}
case 5:
{
uint uInt32Value = value.UInt32Value;
return (destinationType - 8) switch
{
2 => (byte)uInt32Value,
0 => (char)uInt32Value,
4 => (ushort)uInt32Value,
6 => uInt32Value,
8 => (ulong)uInt32Value,
1 => (sbyte)uInt32Value,
3 => (short)uInt32Value,
5 => (int)uInt32Value,
7 => (long)uInt32Value,
13 => (int)uInt32Value,
14 => uInt32Value,
10 => (double)(float)uInt32Value,
11 => (double)uInt32Value,
9 => (decimal)uInt32Value,
_ => throw ExceptionUtilities.UnexpectedValue((object)destinationType),
};
}
case 7:
{
ulong uInt64Value = value.UInt64Value;
return (destinationType - 8) switch
{
2 => (byte)uInt64Value,
0 => (char)uInt64Value,
4 => (ushort)uInt64Value,
6 => (uint)uInt64Value,
8 => uInt64Value,
1 => (sbyte)uInt64Value,
3 => (short)uInt64Value,
5 => (int)uInt64Value,
7 => (long)uInt64Value,
13 => (int)uInt64Value,
14 => (uint)uInt64Value,
10 => (double)(float)uInt64Value,
11 => (double)uInt64Value,
9 => (decimal)uInt64Value,
_ => throw ExceptionUtilities.UnexpectedValue((object)destinationType),
};
}
case 9:
{
uint uInt32Value2 = value.UInt32Value;
return (destinationType - 8) switch
{
2 => (byte)uInt32Value2,
0 => (char)uInt32Value2,
4 => (ushort)uInt32Value2,
6 => uInt32Value2,
8 => (ulong)uInt32Value2,
1 => (sbyte)uInt32Value2,
3 => (short)uInt32Value2,
5 => (int)uInt32Value2,
7 => (long)uInt32Value2,
13 => (int)uInt32Value2,
10 => (double)(float)uInt32Value2,
11 => (double)uInt32Value2,
9 => (decimal)uInt32Value2,
_ => throw ExceptionUtilities.UnexpectedValue((object)destinationType),
};
}
case 0:
{
sbyte sByteValue = value.SByteValue;
switch (destinationType - 8)
{
case 2:
return (byte)sByteValue;
case 0:
return (char)sByteValue;
case 4:
return (ushort)sByteValue;
case 6:
return (uint)sByteValue;
case 8:
return (ulong)sByteValue;
case 1:
return sByteValue;
case 3:
return (short)sByteValue;
case 5:
return (int)sByteValue;
case 7:
return (long)sByteValue;
case 13:
return (int)sByteValue;
case 14:
return (uint)sByteValue;
case 10:
case 11:
return (double)sByteValue;
case 9:
return (decimal)sByteValue;
default:
throw ExceptionUtilities.UnexpectedValue((object)destinationType);
}
}
case 2:
{
short int16Value = value.Int16Value;
switch (destinationType - 8)
{
case 2:
return (byte)int16Value;
case 0:
return (char)int16Value;
case 4:
return (ushort)int16Value;
case 6:
return (uint)int16Value;
case 8:
return (ulong)int16Value;
case 1:
return (sbyte)int16Value;
case 3:
return int16Value;
case 5:
return (int)int16Value;
case 7:
return (long)int16Value;
case 13:
return (int)int16Value;
case 14:
return (uint)int16Value;
case 10:
case 11:
return (double)int16Value;
case 9:
return (decimal)int16Value;
default:
throw ExceptionUtilities.UnexpectedValue((object)destinationType);
}
}
case 4:
{
int int32Value2 = value.Int32Value;
return (destinationType - 8) switch
{
2 => (byte)int32Value2,
0 => (char)int32Value2,
4 => (ushort)int32Value2,
6 => (uint)int32Value2,
8 => (ulong)int32Value2,
1 => (sbyte)int32Value2,
3 => (short)int32Value2,
5 => int32Value2,
7 => (long)int32Value2,
13 => int32Value2,
14 => (uint)int32Value2,
10 => (double)(float)int32Value2,
11 => (double)int32Value2,
9 => (decimal)int32Value2,
_ => throw ExceptionUtilities.UnexpectedValue((object)destinationType),
};
}
case 6:
{
long int64Value = value.Int64Value;
return (destinationType - 8) switch
{
2 => (byte)int64Value,
0 => (char)int64Value,
4 => (ushort)int64Value,
6 => (uint)int64Value,
8 => (ulong)int64Value,
1 => (sbyte)int64Value,
3 => (short)int64Value,
5 => (int)int64Value,
7 => int64Value,
13 => (int)int64Value,
14 => (uint)int64Value,
10 => (double)(float)int64Value,
11 => (double)int64Value,
9 => (decimal)int64Value,
_ => throw ExceptionUtilities.UnexpectedValue((object)destinationType),
};
}
case 8:
{
int int32Value = value.Int32Value;
return (destinationType - 8) switch
{
2 => (byte)int32Value,
0 => (char)int32Value,
4 => (ushort)int32Value,
6 => (uint)int32Value,
8 => (ulong)int32Value,
1 => (sbyte)int32Value,
3 => (short)int32Value,
5 => int32Value,
7 => (long)int32Value,
13 => int32Value,
14 => (uint)int32Value,
10 => (double)(float)int32Value,
11 => (double)int32Value,
9 => (decimal)int32Value,
_ => throw ExceptionUtilities.UnexpectedValue((object)destinationType),
};
}
case 12:
case 13:
{
double num2 = (CheckConstantBounds(destinationType, value.DoubleValue, out maySucceedAtRuntime) ? value.DoubleValue : 0.0);
return (destinationType - 8) switch
{
2 => (byte)num2,
0 => (char)num2,
4 => (ushort)num2,
6 => (uint)num2,
8 => (ulong)num2,
1 => (sbyte)num2,
3 => (short)num2,
5 => (int)num2,
7 => (long)num2,
13 => (int)num2,
14 => (uint)num2,
10 => (double)(float)num2,
11 => num2,
9 => ((int)value.Discriminator == 14) ? ((decimal)(float)num2) : ((decimal)num2),
_ => throw ExceptionUtilities.UnexpectedValue((object)destinationType),
};
}
case 15:
{
decimal num = (CheckConstantBounds(destinationType, value.DecimalValue, out maySucceedAtRuntime) ? value.DecimalValue : 0m);
return (destinationType - 8) switch
{
2 => (byte)num,
0 => (char)num,
4 => (ushort)num,
6 => (uint)num,
8 => (ulong)num,
1 => (sbyte)num,
3 => (short)num,
5 => (int)num,
7 => (long)num,
13 => (int)num,
14 => (uint)num,
10 => (double)(float)num,
11 => (double)num,
9 => num,
_ => throw ExceptionUtilities.UnexpectedValue((object)destinationType),
};
}
default:
throw ExceptionUtilities.UnexpectedValue((object)value.Discriminator);
}
}
public static bool CheckConstantBounds(SpecialType destinationType, ConstantValue value, out bool maySucceedAtRuntime)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
if (value.IsBad)
{
maySucceedAtRuntime = false;
return true;
}
object obj = CanonicalizeConstant(value);
if (!(obj is decimal))
{
return CheckConstantBounds(destinationType, (double)obj, out maySucceedAtRuntime);
}
return CheckConstantBounds(destinationType, (decimal)obj, out maySucceedAtRuntime);
}
private static bool CheckConstantBounds(SpecialType destinationType, double value, out bool maySucceedAtRuntime)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected I4, but got Unknown
maySucceedAtRuntime = false;
switch (destinationType - 8)
{
case 2:
if (-1.0 < value)
{
return value < 256.0;
}
return false;
case 0:
if (-1.0 < value)
{
return value < 65536.0;
}
return false;
case 4:
if (-1.0 < value)
{
return value < 65536.0;
}
return false;
case 6:
if (-1.0 < value)
{
return value < 4294967296.0;
}
return false;
case 8:
if (-1.0 < value)
{
return value < 1.8446744073709552E+19;
}
return false;
case 1:
if (-129.0 < value)
{
return value < 128.0;
}
return false;
case 3:
if (-32769.0 < value)
{
return value < 32768.0;
}
return false;
case 5:
if (-2147483649.0 < value)
{
return value < 2147483648.0;
}
return false;
case 7:
if (-9.223372036854776E+18 <= value)
{
return value < 9.223372036854776E+18;
}
return false;
case 9:
if (-7.922816251426434E+28 < value)
{
return value < 7.922816251426434E+28;
}
return false;
case 13:
maySucceedAtRuntime = -9.223372036854776E+18 < value && value < 9.223372036854776E+18;
if (-2147483649.0 < value)
{
return value < 2147483648.0;
}
return false;
case 14:
maySucceedAtRuntime = -1.0 < value && value < 1.8446744073709552E+19;
if (-1.0 < value)
{
return value < 4294967296.0;
}
return false;
default:
return true;
}
}
private static bool CheckConstantBounds(SpecialType destinationType, decimal value, out bool maySucceedAtRuntime)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected I4, but got Unknown
maySucceedAtRuntime = false;
switch (destinationType - 8)
{
case 2:
if (-1m < value)
{
return value < 256m;
}
return false;
case 0:
if (-1m < value)
{
return value < 65536m;
}
return false;
case 4:
if (-1m < value)
{
return value < 65536m;
}
return false;
case 6:
if (-1m < value)
{
return value < 4294967296m;
}
return false;
case 8:
if (-1m < value)
{
return value < 18446744073709551616m;
}
return false;
case 1:
if (-129m < value)
{
return value < 128m;
}
return false;
case 3:
if (-32769m < value)
{
return value < 32768m;
}
return false;
case 5:
if (-2147483649m < value)
{
return value < 2147483648m;
}
return false;
case 7:
if (-9223372036854775809m < value)
{
return value < 9223372036854775808m;
}
return false;
case 13:
maySucceedAtRuntime = -9223372036854775809m < value && value < 9223372036854775808m;
if (-2147483649m < value)
{
return value < 2147483648m;
}
return false;
case 14:
maySucceedAtRuntime = -1m < value && value < 18446744073709551616m;
if (-1m < value)
{
return value < 4294967296m;
}
return false;
default:
return true;
}
}
private static object CanonicalizeConstant(ConstantValue value)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected I4, but got Unknown
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
ConstantValueTypeDiscriminator discriminator = value.Discriminator;
switch (discriminator - 2)
{
case 0:
return (decimal)value.SByteValue;
case 2:
return (decimal)value.Int16Value;
case 4:
return (decimal)value.Int32Value;
case 6:
return (decimal)value.Int64Value;
case 8:
return (decimal)value.Int32Value;
case 1:
return (decimal)value.ByteValue;
case 10:
return (decimal)value.CharValue;
case 3:
return (decimal)value.UInt16Value;
case 5:
return (decimal)value.UInt32Value;
case 7:
return (decimal)value.UInt64Value;
case 9:
return (decimal)value.UInt32Value;
case 12:
case 13:
return value.DoubleValue;
case 15:
return value.DecimalValue;
default:
throw ExceptionUtilities.UnexpectedValue((object)value.Discriminator);
}
}
internal ImmutableArray<Symbol> BindCref(CrefSyntax syntax, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
{
return BindCrefInternal(syntax, out ambiguityWinner, diagnostics);
}
private ImmutableArray<Symbol> BindCrefInternal(CrefSyntax syntax, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
{
switch (syntax.Kind())
{
case SyntaxKind.TypeCref:
return BindTypeCref((TypeCrefSyntax)syntax, out ambiguityWinner, diagnostics);
case SyntaxKind.QualifiedCref:
return BindQualifiedCref((QualifiedCrefSyntax)syntax, out ambiguityWinner, diagnostics);
case SyntaxKind.NameMemberCref:
case SyntaxKind.IndexerMemberCref:
case SyntaxKind.OperatorMemberCref:
case SyntaxKind.ConversionOperatorMemberCref:
return BindMemberCref((MemberCrefSyntax)syntax, null, out ambiguityWinner, diagnostics);
default:
throw ExceptionUtilities.UnexpectedValue((object)syntax.Kind());
}
}
private ImmutableArray<Symbol> BindTypeCref(TypeCrefSyntax syntax, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Invalid comparison between Unknown and I4
NamespaceOrTypeSymbol namespaceOrTypeSymbol = BindNamespaceOrTypeSymbolInCref(syntax.Type);
if ((int)namespaceOrTypeSymbol.Kind == 4)
{
TypeCrefSyntax typeCrefSyntax = SyntaxNodeExtensions.WithTrailingTrivia<TypeCrefSyntax>(SyntaxNodeExtensions.WithLeadingTrivia<TypeCrefSyntax>(syntax, (SyntaxTrivia[])null), (SyntaxTrivia[])null);
diagnostics.Add(ErrorCode.WRN_BadXMLRef, ((SyntaxNode)syntax).Location, ((SyntaxNode)typeCrefSyntax).ToFullString());
}
ambiguityWinner = null;
return ImmutableArray.Create((Symbol)namespaceOrTypeSymbol);
}
private ImmutableArray<Symbol> BindQualifiedCref(QualifiedCrefSyntax syntax, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
{
NamespaceOrTypeSymbol containerOpt = BindNamespaceOrTypeSymbolInCref(syntax.Container);
return BindMemberCref(syntax.Member, containerOpt, out ambiguityWinner, diagnostics);
}
private NamespaceOrTypeSymbol BindNamespaceOrTypeSymbolInCref(TypeSyntax syntax)
{
return BindNamespaceOrTypeSymbol(syntax, BindingDiagnosticBag.Discarded).NamespaceOrTypeSymbol;
}
private ImmutableArray<Symbol> BindMemberCref(MemberCrefSyntax syntax, NamespaceOrTypeSymbol? containerOpt, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
if ((object)containerOpt != null && (int)containerOpt.Kind == 17)
{
CrefSyntax rootCrefSyntax = GetRootCrefSyntax(syntax);
MemberCrefSyntax memberCrefSyntax = SyntaxNodeExtensions.WithTrailingTrivia<MemberCrefSyntax>(SyntaxNodeExtensions.WithLeadingTrivia<MemberCrefSyntax>(syntax, (SyntaxTrivia[])null), (SyntaxTrivia[])null);
diagnostics.Add(ErrorCode.WRN_BadXMLRef, ((SyntaxNode)rootCrefSyntax).Location, ((SyntaxNode)memberCrefSyntax).ToFullString());
ambiguityWinner = null;
return ImmutableArray<Symbol>.Empty;
}
ImmutableArray<Symbol> immutableArray = syntax.Kind() switch
{
SyntaxKind.NameMemberCref => BindNameMemberCref((NameMemberCrefSyntax)syntax, containerOpt, out ambiguityWinner, diagnostics),
SyntaxKind.IndexerMemberCref => BindIndexerMemberCref((IndexerMemberCrefSyntax)syntax, containerOpt, out ambiguityWinner, diagnostics),
SyntaxKind.OperatorMemberCref => BindOperatorMemberCref((OperatorMemberCrefSyntax)syntax, containerOpt, out ambiguityWinner, diagnostics),
SyntaxKind.ConversionOperatorMemberCref => BindConversionOperatorMemberCref((ConversionOperatorMemberCrefSyntax)syntax, containerOpt, out ambiguityWinner, diagnostics),
_ => throw ExceptionUtilities.UnexpectedValue((object)syntax.Kind()),
};
if (!immutableArray.Any())
{
CrefSyntax rootCrefSyntax2 = GetRootCrefSyntax(syntax);
MemberCrefSyntax memberCrefSyntax2 = SyntaxNodeExtensions.WithTrailingTrivia<MemberCrefSyntax>(SyntaxNodeExtensions.WithLeadingTrivia<MemberCrefSyntax>(syntax, (SyntaxTrivia[])null), (SyntaxTrivia[])null);
diagnostics.Add(ErrorCode.WRN_BadXMLRef, ((SyntaxNode)rootCrefSyntax2).Location, ((SyntaxNode)memberCrefSyntax2).ToFullString());
}
return immutableArray;
}
private ImmutableArray<Symbol> BindNameMemberCref(NameMemberCrefSyntax syntax, NamespaceOrTypeSymbol? containerOpt, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
SimpleNameSyntax simpleNameSyntax = syntax.Name as SimpleNameSyntax;
int num;
string text;
string memberNameText;
if (simpleNameSyntax != null)
{
num = simpleNameSyntax.Arity;
SyntaxToken identifier = simpleNameSyntax.Identifier;
text = ((SyntaxToken)(ref identifier)).ValueText;
identifier = simpleNameSyntax.Identifier;
memberNameText = ((SyntaxToken)(ref identifier)).Text;
}
else
{
containerOpt = BindNamespaceOrTypeSymbolInCref(syntax.Name);
num = 0;
text = (memberNameText = ".ctor");
}
if (string.IsNullOrEmpty(text))
{
ambiguityWinner = null;
return ImmutableArray<Symbol>.Empty;
}
ImmutableArray<Symbol> symbols = ComputeSortedCrefMembers(syntax, containerOpt, text, memberNameText, num, syntax.Parameters != null, diagnostics);
if (symbols.IsEmpty)
{
ambiguityWinner = null;
return ImmutableArray<Symbol>.Empty;
}
return ProcessCrefMemberLookupResults(symbols, num, syntax, (num == 0) ? null : ((GenericNameSyntax)simpleNameSyntax).TypeArgumentList, syntax.Parameters, out ambiguityWinner, diagnostics);
}
private ImmutableArray<Symbol> BindIndexerMemberCref(IndexerMemberCrefSyntax syntax, NamespaceOrTypeSymbol? containerOpt, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
{
ImmutableArray<Symbol> symbols = ComputeSortedCrefMembers(syntax, containerOpt, "this[]", "this[]", 0, syntax.Parameters != null, diagnostics);
if (symbols.IsEmpty)
{
ambiguityWinner = null;
return ImmutableArray<Symbol>.Empty;
}
return ProcessCrefMemberLookupResults(symbols, 0, syntax, null, syntax.Parameters, out ambiguityWinner, diagnostics);
}
private ImmutableArray<Symbol> BindOperatorMemberCref(OperatorMemberCrefSyntax syntax, NamespaceOrTypeSymbol? containerOpt, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
CrefParameterListSyntax parameters = syntax.Parameters;
bool flag = syntax.CheckedKeyword.IsKind(SyntaxKind.CheckedKeyword);
SyntaxKind kind = syntax.OperatorToken.Kind();
string text = ((parameters != null && parameters.Parameters.Count == 1) ? null : OperatorFacts.BinaryOperatorNameFromSyntaxKindIfAny(kind, flag));
text = text ?? OperatorFacts.UnaryOperatorNameFromSyntaxKindIfAny(kind, flag);
if (text != null)
{
if (flag)
{
SyntaxToken operatorToken = syntax.OperatorToken;
if (!((SyntaxToken)(ref operatorToken)).IsMissing && !SyntaxFacts.IsCheckedOperator(text))
{
goto IL_0070;
}
}
ImmutableArray<Symbol> symbols = ComputeSortedCrefMembers(syntax, containerOpt, text, text, 0, syntax.Parameters != null, diagnostics);
if (symbols.IsEmpty)
{
ambiguityWinner = null;
return ImmutableArray<Symbol>.Empty;
}
return ProcessCrefMemberLookupResults(symbols, 0, syntax, null, parameters, out ambiguityWinner, diagnostics);
}
goto IL_0070;
IL_0070:
ambiguityWinner = null;
return ImmutableArray<Symbol>.Empty;
}
private ImmutableArray<Symbol> BindConversionOperatorMemberCref(ConversionOperatorMemberCrefSyntax syntax, NamespaceOrTypeSymbol? containerOpt, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
{
//IL_0001: 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)
bool flag = syntax.CheckedKeyword.IsKind(SyntaxKind.CheckedKeyword);
string text;
if (syntax.ImplicitOrExplicitKeyword.Kind() != SyntaxKind.ImplicitKeyword)
{
text = ((!flag) ? "op_Explicit" : "op_CheckedExplicit");
}
else
{
if (flag)
{
ambiguityWinner = null;
return ImmutableArray<Symbol>.Empty;
}
text = "op_Implicit";
}
ImmutableArray<Symbol> immutableArray = ComputeSortedCrefMembers(syntax, containerOpt, text, text, 0, syntax.Parameters != null, diagnostics);
if (immutableArray.IsEmpty)
{
ambiguityWinner = null;
return ImmutableArray<Symbol>.Empty;
}
TypeSymbol typeSymbol = BindCrefParameterOrReturnType(syntax.Type, syntax, diagnostics);
immutableArray = ImmutableArrayExtensions.WhereAsArray<Symbol, TypeSymbol>(immutableArray, (Func<Symbol, TypeSymbol, bool>)((Symbol symbol, TypeSymbol returnType) => (int)symbol.Kind != 9 || TypeSymbol.Equals(((MethodSymbol)symbol).ReturnType, returnType, (TypeCompareKind)0)), typeSymbol);
if (!immutableArray.Any())
{
ambiguityWinner = null;
return ImmutableArray<Symbol>.Empty;
}
return ProcessCrefMemberLookupResults(immutableArray, 0, syntax, null, syntax.Parameters, out ambiguityWinner, diagnostics);
}
private ImmutableArray<Symbol> ComputeSortedCrefMembers(CSharpSyntaxNode syntax, NamespaceOrTypeSymbol? containerOpt, string memberName, string memberNameText, int arity, bool hasParameterList, BindingDiagnosticBag diagnostics)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
ImmutableArray<Symbol> result = ComputeSortedCrefMembers(containerOpt, memberName, memberNameText, arity, hasParameterList, syntax, diagnostics, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)syntax, useSiteInfo);
return result;
}
private ImmutableArray<Symbol> ComputeSortedCrefMembers(NamespaceOrTypeSymbol? containerOpt, string memberName, string memberNameText, int arity, bool hasParameterList, CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
LookupResult instance = LookupResult.GetInstance();
LookupSymbolsOrMembersInternal(instance, containerOpt, memberName, arity, null, LookupOptions.AllMethodsOnArityZero | LookupOptions.MustNotBeParameter, diagnose: false, ref useSiteInfo);
ArrayBuilder<Symbol> instance2;
if (instance.IsMultiViable)
{
instance2 = ArrayBuilder<Symbol>.GetInstance();
instance2.AddRange(instance.Symbols);
instance.Free();
}
else
{
bool flag = ((memberNameText == "nint" || memberNameText == "nuint") ? true : false);
if (flag && (object)containerOpt == null && arity == 0 && !hasParameterList)
{
instance.Free();
CheckFeatureAvailability((SyntaxNode)(object)syntax, MessageID.IDS_FeatureNativeInt, diagnostics);
instance2 = ArrayBuilder<Symbol>.GetInstance();
instance2.Add((Symbol)GetSpecialType((SpecialType)((memberName == "nint") ? 21 : 22), diagnostics, (SyntaxNode)(object)syntax).AsNativeInteger());
}
else
{
instance.Free();
NamedTypeSymbol namedTypeSymbol = null;
if (arity == 0)
{
if (containerOpt is NamedTypeSymbol namedTypeSymbol2)
{
if (namedTypeSymbol2.Name == memberName && (hasParameterList || namedTypeSymbol2.Arity == 0 || !TypeSymbol.Equals(ContainingType, namedTypeSymbol2.OriginalDefinition, (TypeCompareKind)0)))
{
namedTypeSymbol = namedTypeSymbol2;
}
}
else if ((object)containerOpt == null && hasParameterList)
{
NamedTypeSymbol containingType = ContainingType;
if ((object)containingType != null && memberName == containingType.Name)
{
namedTypeSymbol = containingType;
}
}
}
if ((object)namedTypeSymbol == null)
{
return ImmutableArray<Symbol>.Empty;
}
ImmutableArray<MethodSymbol> instanceConstructors = namedTypeSymbol.InstanceConstructors;
int length = instanceConstructors.Length;
if (length == 0)
{
return ImmutableArray<Symbol>.Empty;
}
instance2 = ArrayBuilder<Symbol>.GetInstance(length);
instance2.AddRange<MethodSymbol>(instanceConstructors);
}
}
if (instance2.Count > 1)
{
instance2.Sort((IComparer<Symbol>)ConsistentSymbolOrder.Instance);
}
return instance2.ToImmutableAndFree();
}
private ImmutableArray<Symbol> ProcessCrefMemberLookupResults(ImmutableArray<Symbol> symbols, int arity, MemberCrefSyntax memberSyntax, TypeArgumentListSyntax? typeArgumentListSyntax, BaseCrefParameterListSyntax? parameterListSyntax, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
if (parameterListSyntax == null)
{
return ProcessParameterlessCrefMemberLookupResults(symbols, arity, memberSyntax, typeArgumentListSyntax, out ambiguityWinner, diagnostics);
}
ArrayBuilder<Symbol> instance = ArrayBuilder<Symbol>.GetInstance();
GetCrefOverloadResolutionCandidates(symbols, arity, typeArgumentListSyntax, instance);
ImmutableArray<ParameterSymbol> parameterSymbols = BindCrefParameters(parameterListSyntax, diagnostics);
ImmutableArray<Symbol> result = PerformCrefOverloadResolution(instance, parameterSymbols, arity, memberSyntax, out ambiguityWinner, diagnostics);
instance.Free();
if (result.Length == 0)
{
for (int i = 0; i < parameterSymbols.Length; i++)
{
if (ContainsNestedTypeOfUnconstructedGenericType(parameterSymbols[i].Type))
{
diagnostics.Add(ErrorCode.WRN_UnqualifiedNestedTypeInCref, ((SyntaxNode)parameterListSyntax.Parameters[i]).Location);
break;
}
}
}
return result;
}
private static bool ContainsNestedTypeOfUnconstructedGenericType(TypeSymbol type)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected I4, but got Unknown
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
TypeKind typeKind = type.TypeKind;
switch (typeKind - 1)
{
case 0:
return ContainsNestedTypeOfUnconstructedGenericType(((ArrayTypeSymbol)type).ElementType);
case 8:
return ContainsNestedTypeOfUnconstructedGenericType(((PointerTypeSymbol)type).PointedAtType);
case 12:
{
MethodSymbol signature = ((FunctionPointerTypeSymbol)type).Signature;
if (ContainsNestedTypeOfUnconstructedGenericType(signature.ReturnType))
{
return true;
}
ImmutableArray<ParameterSymbol>.Enumerator enumerator2 = signature.Parameters.GetEnumerator();
while (enumerator2.MoveNext())
{
if (ContainsNestedTypeOfUnconstructedGenericType(enumerator2.Current.Type))
{
return true;
}
}
return false;
}
case 1:
case 2:
case 4:
case 5:
case 6:
case 9:
{
NamedTypeSymbol namedTypeSymbol = (NamedTypeSymbol)type;
if (IsNestedTypeOfUnconstructedGenericType(namedTypeSymbol))
{
return true;
}
ImmutableArray<TypeWithAnnotations>.Enumerator enumerator = namedTypeSymbol.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics.GetEnumerator();
while (enumerator.MoveNext())
{
if (ContainsNestedTypeOfUnconstructedGenericType(enumerator.Current.Type))
{
return true;
}
}
return false;
}
case 3:
case 10:
return false;
default:
throw ExceptionUtilities.UnexpectedValue((object)type.TypeKind);
}
}
private static bool IsNestedTypeOfUnconstructedGenericType(NamedTypeSymbol type)
{
NamedTypeSymbol containingType = type.ContainingType;
while ((object)containingType != null)
{
if (containingType.Arity > 0 && containingType.IsDefinition)
{
return true;
}
containingType = containingType.ContainingType;
}
return false;
}
private ImmutableArray<Symbol> ProcessParameterlessCrefMemberLookupResults(ImmutableArray<Symbol> symbols, int arity, MemberCrefSyntax memberSyntax, TypeArgumentListSyntax? typeArgumentListSyntax, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
{
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Invalid comparison between Unknown and I4
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Invalid comparison between Unknown and I4
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Invalid comparison between Unknown and I4
if (symbols.Length > 1 && arity == 0)
{
bool flag = false;
bool flag2 = false;
ImmutableArray<Symbol>.Enumerator enumerator = symbols.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
if ((int)current.Kind == 9)
{
if (((MethodSymbol)current).Arity == 0)
{
flag = true;
}
else
{
flag2 = true;
}
if (flag2 && flag)
{
break;
}
}
}
if (flag && flag2)
{
symbols = ImmutableArrayExtensions.WhereAsArray<Symbol>(symbols, (Func<Symbol, bool>)((Symbol s) => (int)s.Kind != 9 || ((MethodSymbol)s).Arity == 0));
}
}
Symbol symbol = symbols[0];
if (symbols.Length > 1)
{
ArrayBuilder<Symbol> instance = ArrayBuilder<Symbol>.GetInstance(symbols.Length);
ImmutableArray<Symbol>.Enumerator enumerator = symbols.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current2 = enumerator.Current;
instance.Add(UnwrapAliasNoDiagnostics(current2));
}
BestSymbolInfo secondBest;
BestSymbolInfo bestSymbolInfo = GetBestSymbolInfo(instance, out secondBest);
instance.Free();
int num = 0;
if (bestSymbolInfo.IsFromCompilation)
{
num = bestSymbolInfo.Index;
symbol = symbols[num];
}
if ((int)symbol.Kind == 17)
{
CrefSyntax rootCrefSyntax = GetRootCrefSyntax(memberSyntax);
diagnostics.Add(ErrorCode.WRN_BadXMLRefTypeVar, ((SyntaxNode)rootCrefSyntax).Location, ((object)rootCrefSyntax).ToString());
}
else if (secondBest.IsFromCompilation == bestSymbolInfo.IsFromCompilation)
{
CrefSyntax rootCrefSyntax2 = GetRootCrefSyntax(memberSyntax);
int index = ((num == 0) ? 1 : 0);
diagnostics.Add(ErrorCode.WRN_AmbiguousXMLReference, ((SyntaxNode)rootCrefSyntax2).Location, ((object)rootCrefSyntax2).ToString(), symbol, symbols[index]);
ambiguityWinner = ConstructWithCrefTypeParameters(arity, typeArgumentListSyntax, symbol);
return ImmutableArrayExtensions.SelectAsArray<Symbol, Symbol>(symbols, (Func<Symbol, Symbol>)((Symbol sym) => ConstructWithCrefTypeParameters(arity, typeArgumentListSyntax, sym)));
}
}
else if ((int)symbol.Kind == 17)
{
CrefSyntax rootCrefSyntax3 = GetRootCrefSyntax(memberSyntax);
diagnostics.Add(ErrorCode.WRN_BadXMLRefTypeVar, ((SyntaxNode)rootCrefSyntax3).Location, ((object)rootCrefSyntax3).ToString());
}
ambiguityWinner = null;
return ImmutableArray.Create(ConstructWithCrefTypeParameters(arity, typeArgumentListSyntax, symbol));
}
private void GetCrefOverloadResolutionCandidates(ImmutableArray<Symbol> symbols, int arity, TypeArgumentListSyntax? typeArgumentListSyntax, ArrayBuilder<Symbol> candidates)
{
ImmutableArray<Symbol>.Enumerator enumerator = symbols.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
Symbol symbol = ConstructWithCrefTypeParameters(arity, typeArgumentListSyntax, current);
if (!(symbol is NamedTypeSymbol namedTypeSymbol))
{
candidates.Add(symbol);
}
else
{
candidates.AddRange<MethodSymbol>(namedTypeSymbol.InstanceConstructors);
}
}
}
private static ImmutableArray<Symbol> PerformCrefOverloadResolution(ArrayBuilder<Symbol> candidates, ImmutableArray<ParameterSymbol> parameterSymbols, int arity, MemberCrefSyntax memberSyntax, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//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_0022: Invalid comparison between Unknown and I4
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Invalid comparison between Unknown and I4
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Invalid comparison between Unknown and I4
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
ArrayBuilder<Symbol> val = null;
Enumerator<Symbol> enumerator = candidates.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
SymbolKind kind = current.Kind;
Symbol member;
if ((int)kind != 9)
{
if ((int)kind == 11)
{
throw ExceptionUtilities.UnexpectedValue((object)current.Kind);
}
if ((int)kind != 15)
{
continue;
}
member = new SignatureOnlyPropertySymbol(null, null, parameterSymbols, (RefKind)0, default(TypeWithAnnotations), ImmutableArray<CustomModifier>.Empty, isStatic: false, ImmutableArray<PropertySymbol>.Empty);
}
else
{
MethodSymbol methodSymbol = (MethodSymbol)current;
MethodKind methodKind = methodSymbol.MethodKind;
bool isVararg = methodSymbol.IsVararg;
int count = (((int)methodKind != 1) ? ((arity == 0) ? methodSymbol.Arity : arity) : 0);
member = new SignatureOnlyMethodSymbol(null, null, methodKind, typeParameters: IndexedTypeParameterSymbol.TakeSymbols(count), parameters: parameterSymbols, callingConvention: (CallingConvention)(isVararg ? 5 : 32), refKind: (RefKind)0, isInitOnly: false, isStatic: false, returnType: default(TypeWithAnnotations), refCustomModifiers: ImmutableArray<CustomModifier>.Empty, explicitInterfaceImplementations: ImmutableArray<MethodSymbol>.Empty);
}
if (!MemberSignatureComparer.CrefComparer.Equals(member, current))
{
continue;
}
if (val == null)
{
val = ArrayBuilder<Symbol>.GetInstance();
val.Add(current);
continue;
}
bool flag = val[0].GetMemberArity() == 0;
bool flag2 = current.GetMemberArity() == 0;
if (!flag || flag2)
{
if (!flag && flag2)
{
val.Clear();
}
val.Add(current);
}
}
if (val == null)
{
ambiguityWinner = null;
return ImmutableArray<Symbol>.Empty;
}
if (val.Count > 1)
{
ambiguityWinner = val[0];
CrefSyntax rootCrefSyntax = GetRootCrefSyntax(memberSyntax);
diagnostics.Add(ErrorCode.WRN_AmbiguousXMLReference, ((SyntaxNode)rootCrefSyntax).Location, ((object)rootCrefSyntax).ToString(), ambiguityWinner, val[1]);
}
else
{
ambiguityWinner = null;
}
return val.ToImmutableAndFree();
}
private Symbol ConstructWithCrefTypeParameters(int arity, TypeArgumentListSyntax? typeArgumentListSyntax, Symbol symbol)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Invalid comparison between Unknown and I4
if (arity > 0)
{
SeparatedSyntaxList<TypeSyntax> arguments = typeArgumentListSyntax.Arguments;
ArrayBuilder<TypeWithAnnotations> instance = ArrayBuilder<TypeWithAnnotations>.GetInstance(arity);
BindingDiagnosticBag discarded = BindingDiagnosticBag.Discarded;
for (int i = 0; i < arity; i++)
{
TypeSyntax syntax = arguments[i];
TypeWithAnnotations typeWithAnnotations = BindType(syntax, discarded);
instance.Add(typeWithAnnotations);
}
symbol = (((int)symbol.Kind != 9) ? ((Symbol)((NamedTypeSymbol)symbol).Construct(instance.ToImmutableAndFree())) : ((Symbol)((MethodSymbol)symbol).Construct(instance.ToImmutableAndFree())));
}
return symbol;
}
private ImmutableArray<ParameterSymbol> BindCrefParameters(BaseCrefParameterListSyntax parameterListSyntax, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Invalid comparison between Unknown and I4
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
ArrayBuilder<ParameterSymbol> instance = ArrayBuilder<ParameterSymbol>.GetInstance(parameterListSyntax.Parameters.Count);
Enumerator<CrefParameterSyntax> enumerator = parameterListSyntax.Parameters.GetEnumerator();
while (enumerator.MoveNext())
{
CrefParameterSyntax current = enumerator.Current;
RefKind val = current.RefKindKeyword.Kind().GetRefKind();
if ((int)val == 1 && current.ReadOnlyKeyword.IsKind(SyntaxKind.ReadOnlyKeyword))
{
CheckFeatureAvailability(current.ReadOnlyKeyword, MessageID.IDS_FeatureRefReadonlyParameters, diagnostics, forceWarning: true);
val = (RefKind)4;
}
TypeSymbol typeSymbol = BindCrefParameterOrReturnType(current.Type, (MemberCrefSyntax)parameterListSyntax.Parent, diagnostics);
instance.Add((ParameterSymbol)new SignatureOnlyParameterSymbol(TypeWithAnnotations.Create(typeSymbol), ImmutableArray<CustomModifier>.Empty, isParams: false, val));
}
return instance.ToImmutableAndFree();
}
private TypeSymbol BindCrefParameterOrReturnType(TypeSyntax typeSyntax, MemberCrefSyntax memberCrefSyntax, BindingDiagnosticBag diagnostics)
{
Binder binder = WithAdditionalFlags(BinderFlags.CrefParameterOrReturnType);
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(withDiagnostics: true, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
TypeSymbol type = binder.BindType(typeSyntax, instance).Type;
if (((BindingDiagnosticBag)instance).HasAnyErrors() && HasNonObsoleteError(((BindingDiagnosticBag)instance).DiagnosticBag))
{
CrefSyntax rootCrefSyntax = GetRootCrefSyntax(memberCrefSyntax);
if (typeSyntax.Parent.Kind() == SyntaxKind.ConversionOperatorMemberCref)
{
diagnostics.Add(ErrorCode.WRN_BadXMLRefReturnType, ((SyntaxNode)typeSyntax).Location);
}
else
{
diagnostics.Add(ErrorCode.WRN_BadXMLRefParamType, ((SyntaxNode)typeSyntax).Location, ((object)typeSyntax).ToString(), ((object)rootCrefSyntax).ToString());
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddDependencies((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
return type;
}
private static bool HasNonObsoleteError(DiagnosticBag unusedDiagnostics)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between Unknown and I4
foreach (Diagnostic item in unusedDiagnostics.AsEnumerable())
{
ErrorCode code = (ErrorCode)item.Code;
if (code != ErrorCode.ERR_DeprecatedSymbolStr && code != ErrorCode.ERR_DeprecatedCollectionInitAddStr && (int)item.Severity == 3)
{
return true;
}
}
return false;
}
private static CrefSyntax GetRootCrefSyntax(MemberCrefSyntax syntax)
{
SyntaxNode parent = (SyntaxNode)(object)syntax.Parent;
if (parent != null && !parent.IsKind(SyntaxKind.XmlCrefAttribute))
{
return (CrefSyntax)(object)parent;
}
return syntax;
}
internal BoundExpression BindDeconstruction(AssignmentExpressionSyntax node, BindingDiagnosticBag diagnostics, bool resultIsUsedOverride = false)
{
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
ExpressionSyntax left = node.Left;
ExpressionSyntax right = node.Right;
DeclarationExpressionSyntax declaration = null;
ExpressionSyntax expression = null;
BoundDeconstructionAssignmentOperator result = BindDeconstruction(node, left, right, diagnostics, ref declaration, ref expression, resultIsUsedOverride);
if (declaration != null)
{
switch (node.Parent?.Kind())
{
case null:
case SyntaxKind.ExpressionStatement:
if (expression != null)
{
MessageID.IDS_FeatureMixedDeclarationsAndExpressionsInDeconstruction.CheckFeatureAvailability(diagnostics, (Compilation)(object)Compilation, ((SyntaxNode)node).Location);
}
break;
case SyntaxKind.ForStatement:
if (((ForStatementSyntax)node.Parent).Initializers.Contains((ExpressionSyntax)node))
{
if (expression != null)
{
MessageID.IDS_FeatureMixedDeclarationsAndExpressionsInDeconstruction.CheckFeatureAvailability(diagnostics, (Compilation)(object)Compilation, ((SyntaxNode)node).Location);
}
}
else
{
Error(diagnostics, ErrorCode.ERR_DeclarationExpressionNotPermitted, (CSharpSyntaxNode)declaration);
}
break;
default:
Error(diagnostics, ErrorCode.ERR_DeclarationExpressionNotPermitted, (CSharpSyntaxNode)declaration);
break;
}
}
return result;
}
internal BoundDeconstructionAssignmentOperator BindDeconstruction(CSharpSyntaxNode deconstruction, ExpressionSyntax left, ExpressionSyntax right, BindingDiagnosticBag diagnostics, ref DeclarationExpressionSyntax? declaration, ref ExpressionSyntax? expression, bool resultIsUsedOverride = false, BoundDeconstructValuePlaceholder? rightPlaceholder = null)
{
DeconstructionVariable deconstructionVariable = BindDeconstructionVariables(left, diagnostics, ref declaration, ref expression);
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(withDiagnostics: true, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
BoundExpression boundRHS = rightPlaceholder ?? BindValue(right, instance, BindValueKind.RValue);
boundRHS = FixTupleLiteral(deconstructionVariable.NestedVariables, boundRHS, deconstruction, instance);
boundRHS = BindToNaturalType(boundRHS, diagnostics);
bool resultIsUsed = resultIsUsedOverride || IsDeconstructionResultUsed(left);
BoundDeconstructionAssignmentOperator result = BindDeconstructionAssignment(deconstruction, left, boundRHS, deconstructionVariable.NestedVariables, resultIsUsed, instance);
DeconstructionVariable.FreeDeconstructionVariables(deconstructionVariable.NestedVariables);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRangeAndFree((BindingDiagnosticBag<AssemblySymbol>)(object)instance);
return result;
}
private BoundDeconstructionAssignmentOperator BindDeconstructionAssignment(CSharpSyntaxNode node, ExpressionSyntax left, BoundExpression boundRHS, ArrayBuilder<DeconstructionVariable> checkedVariables, bool resultIsUsed, BindingDiagnosticBag diagnostics)
{
if ((object)boundRHS.Type == null || boundRHS.Type.IsErrorType())
{
FailRemainingInferences(checkedVariables, diagnostics);
NamedTypeSymbol specialType = GetSpecialType((SpecialType)6, diagnostics, (SyntaxNode)(object)node);
TypeSymbol type = boundRHS.Type ?? specialType;
return new BoundDeconstructionAssignmentOperator((SyntaxNode)(object)node, DeconstructionVariablesAsTuple(left, checkedVariables, diagnostics, ignoreDiagnosticsFromTuple: true), new BoundConversion(boundRHS.Syntax, boundRHS, Conversion.Deconstruction, @checked: false, explicitCastInCode: false, null, null, type, hasErrors: true), resultIsUsed, specialType, hasErrors: true);
}
Conversion conversion;
bool flag = !MakeDeconstructionConversion(boundRHS.Type, (SyntaxNode)(object)node, boundRHS.Syntax, diagnostics, checkedVariables, out conversion);
if (conversion.Method != null)
{
CheckImplicitThisCopyInReadOnlyMember(boundRHS, conversion.Method, diagnostics);
}
FailRemainingInferences(checkedVariables, diagnostics);
BoundTupleExpression boundTupleExpression = DeconstructionVariablesAsTuple(left, checkedVariables, diagnostics, ((BindingDiagnosticBag)diagnostics).HasAnyErrors() || !resultIsUsed);
TypeSymbol type2 = (flag ? CreateErrorType() : boundTupleExpression.Type);
BoundConversion right = new BoundConversion(boundRHS.Syntax, boundRHS, conversion, @checked: false, explicitCastInCode: false, null, null, type2, flag)
{
WasCompilerGenerated = true
};
return new BoundDeconstructionAssignmentOperator((SyntaxNode)(object)node, boundTupleExpression, right, resultIsUsed, type2);
}
private static bool IsDeconstructionResultUsed(ExpressionSyntax left)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
CSharpSyntaxNode parent = left.Parent;
if (parent == null || parent.Kind() == SyntaxKind.ForEachVariableStatement)
{
return false;
}
CSharpSyntaxNode parent2 = parent.Parent;
if (parent2 == null)
{
return false;
}
switch (parent2.Kind())
{
case SyntaxKind.ExpressionStatement:
return ((ExpressionStatementSyntax)parent2).Expression != parent;
case SyntaxKind.ForStatement:
{
ForStatementSyntax forStatementSyntax = (ForStatementSyntax)parent2;
if (!IReadOnlyListExtensions.Contains<CSharpSyntaxNode>((IReadOnlyList<CSharpSyntaxNode>)(object)forStatementSyntax.Incrementors, parent, (IEqualityComparer<CSharpSyntaxNode>)null))
{
return !IReadOnlyListExtensions.Contains<CSharpSyntaxNode>((IReadOnlyList<CSharpSyntaxNode>)(object)forStatementSyntax.Initializers, parent, (IEqualityComparer<CSharpSyntaxNode>)null);
}
return false;
}
default:
return true;
}
}
private BoundExpression FixTupleLiteral(ArrayBuilder<DeconstructionVariable> checkedVariables, BoundExpression boundRHS, CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
if (boundRHS.Kind == BoundKind.TupleLiteral)
{
bool flag = ((BindingDiagnosticBag)diagnostics).HasAnyErrors();
TypeSymbol typeSymbol = MakeMergedTupleType(checkedVariables, (BoundTupleLiteral)boundRHS, syntax, flag ? null : diagnostics);
if ((object)typeSymbol != null)
{
boundRHS = GenerateConversionForAssignment(typeSymbol, boundRHS, diagnostics);
}
}
else if ((object)boundRHS.Type == null)
{
Error(diagnostics, ErrorCode.ERR_DeconstructRequiresExpression, SyntaxNodeOrToken.op_Implicit(boundRHS.Syntax));
}
return boundRHS;
}
private bool MakeDeconstructionConversion(TypeSymbol type, SyntaxNode syntax, SyntaxNode rightSyntax, BindingDiagnosticBag diagnostics, ArrayBuilder<DeconstructionVariable> variables, out Conversion conversion)
{
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
conversion = Conversion.Deconstruction;
DeconstructMethodInfo deconstructMethodInfo = default(DeconstructMethodInfo);
ImmutableArray<TypeSymbol> foundTypes;
if (type.IsTupleType)
{
foundTypes = ImmutableArrayExtensions.SelectAsArray<TypeWithAnnotations, TypeSymbol>(type.TupleElementTypesWithAnnotations, TypeMap.AsTypeSymbol);
SetInferredTypes(variables, foundTypes, diagnostics);
if (variables.Count != foundTypes.Length)
{
Error(diagnostics, ErrorCode.ERR_DeconstructWrongCardinality, SyntaxNodeOrToken.op_Implicit(syntax), foundTypes.Length, variables.Count);
return false;
}
}
else
{
if (variables.Count < 2)
{
Error(diagnostics, ErrorCode.ERR_DeconstructTooFewElements, SyntaxNodeOrToken.op_Implicit(syntax));
return false;
}
BoundDeconstructValuePlaceholder boundDeconstructValuePlaceholder = new BoundDeconstructValuePlaceholder(syntax, null, isDiscardExpression: false, type);
ImmutableArray<BoundDeconstructValuePlaceholder> outPlaceholders;
bool anyApplicableCandidates;
BoundExpression boundExpression = MakeDeconstructInvocationExpression(variables.Count, boundDeconstructValuePlaceholder, rightSyntax, diagnostics, out outPlaceholders, out anyApplicableCandidates, variables);
if (boundExpression.HasAnyErrors)
{
return false;
}
deconstructMethodInfo = new DeconstructMethodInfo(boundExpression, boundDeconstructValuePlaceholder, outPlaceholders);
foundTypes = ImmutableArrayExtensions.SelectAsArray<BoundDeconstructValuePlaceholder, TypeSymbol>(outPlaceholders, (Func<BoundDeconstructValuePlaceholder, TypeSymbol>)((BoundDeconstructValuePlaceholder p) => p.Type));
SetInferredTypes(variables, foundTypes, diagnostics);
}
bool flag = false;
int count = variables.Count;
ArrayBuilder<(BoundValuePlaceholder, BoundExpression)> instance = ArrayBuilder<(BoundValuePlaceholder, BoundExpression)>.GetInstance(count);
for (int num = 0; num < count; num++)
{
DeconstructionVariable deconstructionVariable = variables[num];
Conversion conversion2;
if (deconstructionVariable.NestedVariables != null)
{
SyntaxNode syntax2 = (SyntaxNode)(object)((syntax.Kind() == SyntaxKind.TupleExpression) ? ((TupleExpressionSyntax)(object)syntax).Arguments[num] : ((ArgumentSyntax)(object)syntax));
flag |= !MakeDeconstructionConversion(foundTypes[num], syntax2, rightSyntax, diagnostics, deconstructionVariable.NestedVariables, out conversion2);
BoundValuePlaceholder boundValuePlaceholder = new BoundValuePlaceholder(syntax, ErrorTypeSymbol.UnknownResultType).MakeCompilerGenerated();
instance.Add((boundValuePlaceholder, (BoundExpression)new BoundConversion(syntax, boundValuePlaceholder, conversion2, @checked: false, explicitCastInCode: false, null, null, ErrorTypeSymbol.UnknownResultType)
{
WasCompilerGenerated = true
}));
continue;
}
BoundExpression single = deconstructionVariable.Single;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
conversion2 = Conversions.ClassifyConversionFromType(foundTypes[num], single.Type, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(single.Syntax, useSiteInfo);
if (!conversion2.IsImplicit)
{
flag = true;
GenerateImplicitConversionError(diagnostics, Compilation, single.Syntax, conversion2, foundTypes[num], single.Type);
instance.Add(((BoundValuePlaceholder)null, (BoundExpression)null));
}
else
{
BoundValuePlaceholder boundValuePlaceholder2 = new BoundValuePlaceholder(syntax, foundTypes[num]).MakeCompilerGenerated();
instance.Add((boundValuePlaceholder2, CreateConversion(syntax, boundValuePlaceholder2, conversion2, isCast: false, null, single.Type, diagnostics)));
}
}
conversion = new Conversion(ConversionKind.Deconstruction, deconstructMethodInfo, instance.ToImmutableAndFree());
return !flag;
}
private void SetInferredTypes(ArrayBuilder<DeconstructionVariable> variables, ImmutableArray<TypeSymbol> foundTypes, BindingDiagnosticBag diagnostics)
{
int num = Math.Min(variables.Count, foundTypes.Length);
for (int i = 0; i < num; i++)
{
DeconstructionVariable deconstructionVariable = variables[i];
BoundExpression single = deconstructionVariable.Single;
if (single != null && (object)single.Type == null)
{
variables[i] = new DeconstructionVariable(SetInferredType(single, foundTypes[i], diagnostics), (SyntaxNode)(object)deconstructionVariable.Syntax);
}
}
}
private BoundExpression SetInferredType(BoundExpression expression, TypeSymbol type, BindingDiagnosticBag diagnostics)
{
return expression.Kind switch
{
BoundKind.DeconstructionVariablePendingInference => ((DeconstructionVariablePendingInference)expression).SetInferredTypeWithAnnotations(TypeWithAnnotations.Create(type), this, diagnostics),
BoundKind.DiscardExpression => ((BoundDiscardExpression)expression).SetInferredTypeWithAnnotations(TypeWithAnnotations.Create(type)),
_ => throw ExceptionUtilities.UnexpectedValue((object)expression.Kind),
};
}
private void FailRemainingInferences(ArrayBuilder<DeconstructionVariable> variables, BindingDiagnosticBag diagnostics)
{
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
int count = variables.Count;
for (int i = 0; i < count; i++)
{
DeconstructionVariable deconstructionVariable = variables[i];
if (deconstructionVariable.NestedVariables != null)
{
FailRemainingInferences(deconstructionVariable.NestedVariables, diagnostics);
continue;
}
switch (deconstructionVariable.Single.Kind)
{
case BoundKind.DeconstructionVariablePendingInference:
{
BoundExpression boundExpression = ((DeconstructionVariablePendingInference)deconstructionVariable.Single).FailInference(this, diagnostics);
variables[i] = new DeconstructionVariable(boundExpression, boundExpression.Syntax);
break;
}
case BoundKind.DiscardExpression:
{
BoundDiscardExpression boundDiscardExpression = (BoundDiscardExpression)deconstructionVariable.Single;
if ((object)boundDiscardExpression.Type == null)
{
Error(diagnostics, ErrorCode.ERR_TypeInferenceFailedForImplicitlyTypedDeconstructionVariable, SyntaxNodeOrToken.op_Implicit(boundDiscardExpression.Syntax), "_");
variables[i] = new DeconstructionVariable((BoundExpression)boundDiscardExpression.FailInference(this, diagnostics), boundDiscardExpression.Syntax);
}
break;
}
}
}
}
private TypeSymbol? MakeMergedTupleType(ArrayBuilder<DeconstructionVariable> lhsVariables, BoundTupleLiteral rhsLiteral, CSharpSyntaxNode syntax, BindingDiagnosticBag? diagnostics)
{
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
int count = lhsVariables.Count;
int length = rhsLiteral.Arguments.Length;
ArrayBuilder<TypeWithAnnotations> instance = ArrayBuilder<TypeWithAnnotations>.GetInstance(count);
ArrayBuilder<Location> instance2 = ArrayBuilder<Location>.GetInstance(count);
for (int i = 0; i < length; i++)
{
BoundExpression boundExpression = rhsLiteral.Arguments[i];
TypeSymbol typeSymbol = boundExpression.Type;
if (i < count)
{
DeconstructionVariable deconstructionVariable = lhsVariables[i];
if (deconstructionVariable.NestedVariables != null)
{
if (boundExpression.Kind == BoundKind.TupleLiteral)
{
typeSymbol = MakeMergedTupleType(deconstructionVariable.NestedVariables, (BoundTupleLiteral)boundExpression, syntax, diagnostics);
}
else if ((object)typeSymbol == null && diagnostics != null)
{
Error(diagnostics, ErrorCode.ERR_DeconstructRequiresExpression, SyntaxNodeOrToken.op_Implicit(boundExpression.Syntax));
}
}
else if ((object)deconstructionVariable.Single.Type != null)
{
typeSymbol = deconstructionVariable.Single.Type;
}
}
else if ((object)typeSymbol == null && diagnostics != null)
{
Error(diagnostics, ErrorCode.ERR_DeconstructRequiresExpression, SyntaxNodeOrToken.op_Implicit(boundExpression.Syntax));
}
instance.Add(TypeWithAnnotations.Create(typeSymbol));
instance2.Add(boundExpression.Syntax.Location);
}
if (ArrayBuilderExtensions.Any<TypeWithAnnotations>(instance, (Func<TypeWithAnnotations, bool>)((TypeWithAnnotations t) => !t.HasType)))
{
instance.Free();
instance2.Free();
return null;
}
return NamedTypeSymbol.CreateTuple(null, instance.ToImmutableAndFree(), instance2.ToImmutableAndFree(), default(ImmutableArray<string>), Compilation, shouldCheckConstraints: true, includeNullability: false, default(ImmutableArray<bool>), syntax, diagnostics);
}
private BoundTupleExpression DeconstructionVariablesAsTuple(CSharpSyntaxNode syntax, ArrayBuilder<DeconstructionVariable> variables, BindingDiagnosticBag diagnostics, bool ignoreDiagnosticsFromTuple)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
int count = variables.Count;
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(count);
ArrayBuilder<TypeWithAnnotations> instance2 = ArrayBuilder<TypeWithAnnotations>.GetInstance(count);
ArrayBuilder<Location> instance3 = ArrayBuilder<Location>.GetInstance(count);
ArrayBuilder<string> inferredElementNames = ArrayBuilder<string>.GetInstance(count);
Enumerator<DeconstructionVariable> enumerator = variables.GetEnumerator();
while (enumerator.MoveNext())
{
DeconstructionVariable current = enumerator.Current;
BoundExpression boundExpression;
if (current.NestedVariables != null)
{
boundExpression = DeconstructionVariablesAsTuple(current.Syntax, current.NestedVariables, diagnostics, ignoreDiagnosticsFromTuple);
inferredElementNames.Add((string)null);
}
else
{
boundExpression = current.Single;
inferredElementNames.Add(ExtractDeconstructResultElementName(boundExpression));
}
instance.Add(boundExpression);
instance2.Add(TypeWithAnnotations.Create(boundExpression.Type));
instance3.Add(((SyntaxNode)current.Syntax).Location);
}
ImmutableArray<BoundExpression> arguments = instance.ToImmutableAndFree();
PooledHashSet<string> instance4 = PooledHashSet<string>.GetInstance();
RemoveDuplicateInferredTupleNamesAndFreeIfEmptied(ref inferredElementNames, (HashSet<string>)(object)instance4);
instance4.Free();
ImmutableArray<string> immutableArray = inferredElementNames?.ToImmutableAndFree() ?? default(ImmutableArray<string>);
ImmutableArray<bool> immutableArray2 = (immutableArray.IsDefault ? default(ImmutableArray<bool>) : ImmutableArrayExtensions.SelectAsArray<string, bool>(immutableArray, (Func<string, bool>)((string n) => n != null)));
bool flag = Compilation.LanguageVersion.DisallowInferredTupleElementNames();
NamedTypeSymbol type = NamedTypeSymbol.CreateTuple(((SyntaxNode)syntax).Location, instance2.ToImmutableAndFree(), instance3.ToImmutableAndFree(), immutableArray, Compilation, !ignoreDiagnosticsFromTuple, includeNullability: false, flag ? immutableArray2 : default(ImmutableArray<bool>), syntax, ignoreDiagnosticsFromTuple ? null : diagnostics);
return (BoundTupleExpression)BindToNaturalType(new BoundTupleLiteral((SyntaxNode)(object)syntax, arguments, immutableArray, immutableArray2, type), diagnostics);
}
private static string? ExtractDeconstructResultElementName(BoundExpression expression)
{
if (expression.Kind == BoundKind.DiscardExpression)
{
return null;
}
return InferTupleElementName(expression.Syntax);
}
private BoundExpression MakeDeconstructInvocationExpression(int numCheckedVariables, BoundExpression receiver, SyntaxNode rightSyntax, BindingDiagnosticBag diagnostics, out ImmutableArray<BoundDeconstructValuePlaceholder> outPlaceholders, out bool anyApplicableCandidates, ArrayBuilder<DeconstructionVariable>? variablesOpt = null)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Invalid comparison between Unknown and I4
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Invalid comparison between Unknown and I4
anyApplicableCandidates = false;
CSharpSyntaxNode cSharpSyntaxNode = (CSharpSyntaxNode)(object)receiver.Syntax;
TypeSymbol? type = receiver.Type;
if ((object)type != null && type.IsDynamic())
{
Error(diagnostics, ErrorCode.ERR_CannotDeconstructDynamic, SyntaxNodeOrToken.op_Implicit(rightSyntax));
outPlaceholders = default(ImmutableArray<BoundDeconstructValuePlaceholder>);
return BadExpression((SyntaxNode)(object)cSharpSyntaxNode, receiver);
}
receiver = BindToNaturalType(receiver, diagnostics);
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
ArrayBuilder<OutDeconstructVarPendingInference> instance2 = ArrayBuilder<OutDeconstructVarPendingInference>.GetInstance(numCheckedVariables);
try
{
for (int i = 0; i < numCheckedVariables; i++)
{
BoundExpression boundExpression = variablesOpt?[i].Single;
Symbol symbol;
if (boundExpression is DeconstructionVariablePendingInference deconstructionVariablePendingInference)
{
Symbol variableSymbol = deconstructionVariablePendingInference.VariableSymbol;
symbol = variableSymbol;
}
else if (boundExpression is BoundLocal { DeclarationKind: var declarationKind } boundLocal && (uint)(declarationKind - 1) <= 1u)
{
LocalSymbol localSymbol = boundLocal.LocalSymbol;
symbol = localSymbol;
}
else
{
symbol = null;
}
Symbol variableSymbol2 = symbol;
OutDeconstructVarPendingInference outDeconstructVarPendingInference = new OutDeconstructVarPendingInference((SyntaxNode)(object)cSharpSyntaxNode, variableSymbol2, boundExpression is BoundDiscardExpression);
instance.Arguments.Add((BoundExpression)outDeconstructVarPendingInference);
instance.RefKinds.Add((RefKind)2);
instance2.Add(outDeconstructVarPendingInference);
}
BoundExpression expr = BindInstanceMemberAccess(rightSyntax, (SyntaxNode)(object)cSharpSyntaxNode, receiver, "Deconstruct", 0, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), invoked: true, indexed: false, diagnostics);
expr = CheckValue(expr, BindValueKind.RValueOrMethodGroup, diagnostics);
expr.WasCompilerGenerated = true;
if (expr.Kind != BoundKind.MethodGroup)
{
return MissingDeconstruct(receiver, rightSyntax, numCheckedVariables, diagnostics, out outPlaceholders, receiver);
}
BoundExpression boundExpression2 = BindMethodGroupInvocation(rightSyntax, rightSyntax, "Deconstruct", (BoundMethodGroup)expr, instance, diagnostics, null, allowUnexpandedForm: true, out anyApplicableCandidates);
boundExpression2.WasCompilerGenerated = true;
if (!anyApplicableCandidates)
{
return MissingDeconstruct(receiver, rightSyntax, numCheckedVariables, diagnostics, out outPlaceholders, boundExpression2);
}
MethodSymbol method = ((BoundCall)boundExpression2).Method;
ImmutableArray<ParameterSymbol> parameters = method.Parameters;
for (int j = (method.IsExtensionMethod ? 1 : 0); j < parameters.Length; j++)
{
if ((int)parameters[j].RefKind != 2)
{
return MissingDeconstruct(receiver, rightSyntax, numCheckedVariables, diagnostics, out outPlaceholders, boundExpression2);
}
}
if ((int)method.ReturnType.GetSpecialTypeSafe() != 6)
{
return MissingDeconstruct(receiver, rightSyntax, numCheckedVariables, diagnostics, out outPlaceholders, boundExpression2);
}
if (ArrayBuilderExtensions.Any<OutDeconstructVarPendingInference>(instance2, (Func<OutDeconstructVarPendingInference, bool>)((OutDeconstructVarPendingInference v) => v.Placeholder == null)))
{
return MissingDeconstruct(receiver, rightSyntax, numCheckedVariables, diagnostics, out outPlaceholders, boundExpression2);
}
outPlaceholders = ArrayBuilderExtensions.SelectAsArray<OutDeconstructVarPendingInference, BoundDeconstructValuePlaceholder>(instance2, (Func<OutDeconstructVarPendingInference, BoundDeconstructValuePlaceholder>)((OutDeconstructVarPendingInference v) => v.Placeholder));
return boundExpression2;
}
finally
{
instance.Free();
instance2.Free();
}
}
private BoundBadExpression MissingDeconstruct(BoundExpression receiver, SyntaxNode rightSyntax, int numParameters, BindingDiagnosticBag diagnostics, out ImmutableArray<BoundDeconstructValuePlaceholder> outPlaceholders, BoundExpression childNode)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
TypeSymbol? type = receiver.Type;
if ((object)type != null && !type.IsErrorType())
{
Error(diagnostics, ErrorCode.ERR_MissingDeconstruct, SyntaxNodeOrToken.op_Implicit(rightSyntax), receiver.Type, numParameters);
}
outPlaceholders = default(ImmutableArray<BoundDeconstructValuePlaceholder>);
return BadExpression(rightSyntax, childNode);
}
private DeconstructionVariable BindDeconstructionVariables(ExpressionSyntax node, BindingDiagnosticBag diagnostics, ref DeclarationExpressionSyntax? declaration, ref ExpressionSyntax? expression)
{
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
switch (node.Kind())
{
case SyntaxKind.DeclarationExpression:
{
DeclarationExpressionSyntax declarationExpressionSyntax = (DeclarationExpressionSyntax)node;
if (declaration == null)
{
declaration = declarationExpressionSyntax;
}
bool isConst = false;
bool isScoped;
bool isVar;
AliasSymbol alias;
TypeWithAnnotations declTypeWithAnnotations = BindVariableTypeWithAnnotations(declarationExpressionSyntax.Designation, diagnostics, declarationExpressionSyntax.Type.SkipScoped(out isScoped).SkipRef(), ref isConst, out isVar, out alias);
if (declarationExpressionSyntax.Designation.Kind() == SyntaxKind.ParenthesizedVariableDesignation)
{
if (!isVar)
{
Error(diagnostics, ErrorCode.ERR_DeconstructionVarFormDisallowsSpecificType, (CSharpSyntaxNode)declarationExpressionSyntax.Designation);
}
else if (!(node.Parent is ArgumentSyntax))
{
MessageID.IDS_FeatureTuples.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)declarationExpressionSyntax.Designation);
}
}
return BindDeconstructionVariables(declTypeWithAnnotations, declarationExpressionSyntax.Designation, declarationExpressionSyntax, diagnostics);
}
case SyntaxKind.TupleExpression:
{
MessageID.IDS_FeatureTuples.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)node);
TupleExpressionSyntax obj = (TupleExpressionSyntax)node;
ArrayBuilder<DeconstructionVariable> instance = ArrayBuilder<DeconstructionVariable>.GetInstance(obj.Arguments.Count);
Enumerator<ArgumentSyntax> enumerator = obj.Arguments.GetEnumerator();
while (enumerator.MoveNext())
{
ArgumentSyntax current = enumerator.Current;
if (current.NameColon != null)
{
Error(diagnostics, ErrorCode.ERR_TupleElementNamesInDeconstruction, (CSharpSyntaxNode)current.NameColon);
}
instance.Add(BindDeconstructionVariables(current.Expression, diagnostics, ref declaration, ref expression));
}
return new DeconstructionVariable(instance, (SyntaxNode)(object)node);
}
default:
{
BoundExpression expr = BindExpression(node, diagnostics, invoked: false, indexed: false);
BoundExpression boundExpression = CheckValue(expr, BindValueKind.Assignable, diagnostics);
if (expression == null && boundExpression.Kind != BoundKind.DiscardExpression)
{
expression = node;
}
return new DeconstructionVariable(boundExpression, (SyntaxNode)(object)node);
}
}
}
private DeconstructionVariable BindDeconstructionVariables(TypeWithAnnotations declTypeWithAnnotations, VariableDesignationSyntax node, CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
{
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
switch (node.Kind())
{
case SyntaxKind.SingleVariableDesignation:
{
SingleVariableDesignationSyntax designation = (SingleVariableDesignationSyntax)node;
return new DeconstructionVariable(BindDeconstructionVariable(declTypeWithAnnotations, designation, syntax, diagnostics), (SyntaxNode)(object)syntax);
}
case SyntaxKind.DiscardDesignation:
{
DiscardDesignationSyntax discardDesignationSyntax = (DiscardDesignationSyntax)node;
if (discardDesignationSyntax.Parent is DeclarationExpressionSyntax declarationExpressionSyntax && declarationExpressionSyntax.Designation == discardDesignationSyntax)
{
TypeSyntax type = declarationExpressionSyntax.Type;
SyntaxToken val;
if (type is ScopedTypeSyntax scopedTypeSyntax)
{
val = scopedTypeSyntax.ScopedKeyword;
diagnostics.Add(ErrorCode.ERR_ScopedDiscard, ((SyntaxToken)(ref val)).GetLocation());
type = scopedTypeSyntax.Type;
}
if (type is RefTypeSyntax refTypeSyntax)
{
val = refTypeSyntax.RefKeyword;
diagnostics.Add(ErrorCode.ERR_DeconstructVariableCannotBeByRef, ((SyntaxToken)(ref val)).GetLocation());
}
}
return new DeconstructionVariable((BoundExpression)BindDiscardExpression((SyntaxNode)(object)syntax, declTypeWithAnnotations), (SyntaxNode)(object)syntax);
}
case SyntaxKind.ParenthesizedVariableDesignation:
{
ParenthesizedVariableDesignationSyntax obj = (ParenthesizedVariableDesignationSyntax)node;
ArrayBuilder<DeconstructionVariable> instance = ArrayBuilder<DeconstructionVariable>.GetInstance();
Enumerator<VariableDesignationSyntax> enumerator = obj.Variables.GetEnumerator();
while (enumerator.MoveNext())
{
VariableDesignationSyntax current = enumerator.Current;
instance.Add(BindDeconstructionVariables(declTypeWithAnnotations, current, current, diagnostics));
}
return new DeconstructionVariable(instance, (SyntaxNode)(object)syntax);
}
default:
throw ExceptionUtilities.UnexpectedValue((object)node.Kind());
}
}
private BoundDiscardExpression BindDiscardExpression(SyntaxNode syntax, TypeWithAnnotations declTypeWithAnnotations)
{
TypeSymbol type = declTypeWithAnnotations.Type;
return new BoundDiscardExpression(syntax, declTypeWithAnnotations.NullableAnnotation, (object)type == null, type);
}
private BoundExpression BindDeconstructionVariable(TypeWithAnnotations declTypeWithAnnotations, SingleVariableDesignationSyntax designation, CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Invalid comparison between Unknown and I4
SourceLocalSymbol sourceLocalSymbol = LookupLocal(designation.Identifier);
SyntaxToken val;
if ((object)sourceLocalSymbol != null)
{
if (designation.Parent is DeclarationExpressionSyntax declarationExpressionSyntax && declarationExpressionSyntax.Designation == designation)
{
TypeSyntax type = declarationExpressionSyntax.Type;
if (type is ScopedTypeSyntax scopedTypeSyntax)
{
ModifierUtils.CheckScopedModifierAvailability(type, scopedTypeSyntax.ScopedKeyword, diagnostics);
type = scopedTypeSyntax.Type;
}
if (type is RefTypeSyntax refTypeSyntax)
{
val = refTypeSyntax.RefKeyword;
diagnostics.Add(ErrorCode.ERR_DeconstructVariableCannotBeByRef, ((SyntaxToken)(ref val)).GetLocation());
}
if (declTypeWithAnnotations.HasType)
{
CheckRestrictedTypeInAsyncMethod(ContainingMemberOrLambda, declTypeWithAnnotations.Type, diagnostics, (SyntaxNode)(object)type);
}
if (declTypeWithAnnotations.HasType && (int)sourceLocalSymbol.Scope == 2 && !declTypeWithAnnotations.Type.IsErrorTypeOrRefLikeType())
{
diagnostics.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly, ((SyntaxNode)type).Location);
}
}
bool hasErrors = sourceLocalSymbol.ScopeBinder.ValidateDeclarationNameConflictsInScope(sourceLocalSymbol, diagnostics);
if (declTypeWithAnnotations.HasType)
{
return new BoundLocal((SyntaxNode)(object)syntax, sourceLocalSymbol, BoundLocalDeclarationKind.WithExplicitType, null, isNullableUnknown: false, declTypeWithAnnotations.Type, hasErrors);
}
return new DeconstructionVariablePendingInference((SyntaxNode)(object)syntax, sourceLocalSymbol, null);
}
GlobalExpressionVariable globalExpressionVariable = LookupDeclaredField(designation);
if ((object)globalExpressionVariable == null)
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Binder/Binder_Deconstruct.cs", 923);
}
if (designation.Parent is DeclarationExpressionSyntax declarationExpressionSyntax2 && declarationExpressionSyntax2.Designation == designation)
{
TypeSyntax type2 = declarationExpressionSyntax2.Type;
if (type2 is ScopedTypeSyntax scopedTypeSyntax2)
{
val = scopedTypeSyntax2.ScopedKeyword;
Location location = ((SyntaxToken)(ref val)).GetLocation();
object[] array = new object[1];
val = scopedTypeSyntax2.ScopedKeyword;
array[0] = ((SyntaxToken)(ref val)).ValueText;
diagnostics.Add(ErrorCode.ERR_UnexpectedToken, location, array);
type2 = scopedTypeSyntax2.Type;
}
if (type2 is RefTypeSyntax refTypeSyntax2)
{
val = refTypeSyntax2.RefKeyword;
Location location2 = ((SyntaxToken)(ref val)).GetLocation();
object[] array2 = new object[1];
val = refTypeSyntax2.RefKeyword;
array2[0] = ((SyntaxToken)(ref val)).ValueText;
diagnostics.Add(ErrorCode.ERR_UnexpectedToken, location2, array2);
}
}
BoundThisReference boundThisReference = ThisReference((SyntaxNode)(object)designation, ContainingType, hasErrors: false, wasCompilerGenerated: true);
if (declTypeWithAnnotations.HasType)
{
return new BoundFieldAccess((SyntaxNode)(object)syntax, boundThisReference, globalExpressionVariable, null, LookupResultKind.Viable, isDeclaration: true, globalExpressionVariable.GetFieldType(FieldsBeingBound).Type);
}
return new DeconstructionVariablePendingInference((SyntaxNode)(object)syntax, globalExpressionVariable, boundThisReference);
}
internal bool HasThis(bool isExplicit, out bool inStaticContext)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Invalid comparison between Unknown and I4
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Invalid comparison between Unknown and I4
Symbol symbol = ContainingMemberOrLambda?.ContainingNonLambdaMember();
if ((object)symbol != null && symbol.IsStatic)
{
inStaticContext = (int)symbol.Kind == 6 || (int)symbol.Kind == 9 || (int)symbol.Kind == 15;
return false;
}
inStaticContext = false;
if (InConstructorInitializer || InAttributeArgument)
{
return false;
}
bool flag = (symbol?.ContainingType)?.IsScriptClass ?? false;
if (InFieldInitializer && !flag)
{
return false;
}
if (flag)
{
return !isExplicit;
}
return true;
}
protected virtual bool IsUnboundTypeAllowed(GenericNameSyntax syntax)
{
return Next.IsUnboundTypeAllowed(syntax);
}
private BoundBadExpression BadExpression(SyntaxNode syntax)
{
return BadExpression(syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty);
}
private BoundBadExpression BadExpression(SyntaxNode syntax, BoundExpression childNode)
{
return BadExpression(syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, childNode);
}
private BoundBadExpression BadExpression(SyntaxNode syntax, ImmutableArray<BoundExpression> childNodes)
{
return BadExpression(syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, childNodes);
}
protected BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind lookupResultKind)
{
return BadExpression(syntax, lookupResultKind, ImmutableArray<Symbol>.Empty);
}
protected BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind lookupResultKind, BoundExpression childNode)
{
return BadExpression(syntax, lookupResultKind, ImmutableArray<Symbol>.Empty, childNode);
}
private BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray<Symbol> symbols)
{
return new BoundBadExpression(syntax, resultKind, symbols, ImmutableArray<BoundExpression>.Empty, CreateErrorType());
}
private BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray<Symbol> symbols, BoundExpression childNode)
{
return new BoundBadExpression(syntax, resultKind, symbols, ImmutableArray.Create(BindToTypeForErrorRecovery(childNode)), CreateErrorType());
}
private BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray<Symbol> symbols, ImmutableArray<BoundExpression> childNodes, bool wasCompilerGenerated = false)
{
return new BoundBadExpression(syntax, resultKind, symbols, ImmutableArrayExtensions.SelectAsArray<BoundExpression, Binder, BoundExpression>(childNodes, (Func<BoundExpression, Binder, BoundExpression>)((BoundExpression e, Binder self) => self.BindToTypeForErrorRecovery(e)), this), CreateErrorType())
{
WasCompilerGenerated = wasCompilerGenerated
};
}
private BoundExpression ToBadExpression(BoundExpression expr, LookupResultKind resultKind = LookupResultKind.Empty)
{
TypeSymbol type = expr.Type;
BoundKind kind = expr.Kind;
if (expr.HasAnyErrors && ((object)type != null || kind == BoundKind.UnboundLambda || kind == BoundKind.DefaultLiteral))
{
return expr;
}
if (kind == BoundKind.BadExpression)
{
BoundBadExpression boundBadExpression = (BoundBadExpression)expr;
return boundBadExpression.Update(resultKind, boundBadExpression.Symbols, boundBadExpression.ChildBoundNodes, type);
}
ArrayBuilder<Symbol> instance = ArrayBuilder<Symbol>.GetInstance();
expr.GetExpressionSymbols(instance, null, this);
return new BoundBadExpression(expr.Syntax, resultKind, instance.ToImmutableAndFree(), ImmutableArray.Create(BindToTypeForErrorRecovery(expr)), type ?? CreateErrorType());
}
internal NamedTypeSymbol CreateErrorType(string name = "")
{
return new ExtendedErrorTypeSymbol(Compilation, name, 0, null);
}
internal BoundExpression BindValue(ExpressionSyntax node, BindingDiagnosticBag diagnostics, BindValueKind valueKind)
{
BoundExpression expr = BindExpression(node, diagnostics, invoked: false, indexed: false);
return CheckValue(expr, valueKind, diagnostics);
}
internal BoundExpression BindRValueWithoutTargetType(ExpressionSyntax node, BindingDiagnosticBag diagnostics, bool reportNoTargetType = true)
{
return BindToNaturalType(BindValue(node, diagnostics, BindValueKind.RValue), diagnostics, reportNoTargetType);
}
internal BoundExpression BindTypeOrRValue(ExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
BoundExpression boundExpression = BindExpression(node, diagnostics, invoked: false, indexed: false);
if (boundExpression.Kind == BoundKind.TypeExpression)
{
return boundExpression;
}
return CheckValue(boundExpression, BindValueKind.RValue, diagnostics);
}
internal BoundExpression BindToTypeForErrorRecovery(BoundExpression expression, TypeSymbol type = null)
{
if (expression == null)
{
return null;
}
if (expression.NeedsToBeConverted())
{
if ((object)type != null)
{
return GenerateConversionForAssignment(type, expression, BindingDiagnosticBag.Discarded);
}
return BindToNaturalType(expression, BindingDiagnosticBag.Discarded, reportNoTargetType: false);
}
return expression;
}
internal BoundExpression BindToNaturalType(BoundExpression expression, BindingDiagnosticBag diagnostics, bool reportNoTargetType = true)
{
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
if (!expression.NeedsToBeConverted())
{
return expression;
}
BoundExpression boundExpression;
if (!(expression is BoundUnconvertedSwitchExpression boundUnconvertedSwitchExpression))
{
if (!(expression is BoundUnconvertedConditionalOperator boundUnconvertedConditionalOperator))
{
if (!(expression is BoundTupleLiteral boundTupleLiteral))
{
if (!(expression is BoundDefaultLiteral boundDefaultLiteral))
{
if (expression is BoundStackAllocArrayCreation boundStackAllocArrayCreation)
{
if ((object)expression.Type != null)
{
goto IL_0369;
}
PointerTypeSymbol targetType = new PointerTypeSymbol(TypeWithAnnotations.Create(boundStackAllocArrayCreation.ElementType));
boundExpression = GenerateConversionForAssignment(targetType, boundStackAllocArrayCreation, diagnostics);
}
else if (!(expression is BoundUnconvertedObjectCreationExpression boundUnconvertedObjectCreationExpression))
{
if (!(expression is BoundUnconvertedInterpolatedString unconvertedInterpolatedString))
{
if (!(expression is BoundBinaryOperator unconvertedBinaryOperator))
{
if (!(expression is BoundUnconvertedCollectionExpression boundUnconvertedCollectionExpression))
{
goto IL_0369;
}
if (reportNoTargetType && !boundUnconvertedCollectionExpression.HasAnyErrors)
{
diagnostics.Add(ErrorCode.ERR_CollectionExpressionNoTargetType, boundUnconvertedCollectionExpression.Syntax.GetLocation());
}
boundExpression = BindCollectionExpressionForErrorRecovery(boundUnconvertedCollectionExpression, CreateErrorType(), diagnostics);
}
else
{
boundExpression = RebindSimpleBinaryOperatorAsConverted(unconvertedBinaryOperator, diagnostics);
}
}
else
{
boundExpression = BindUnconvertedInterpolatedStringToString(unconvertedInterpolatedString, diagnostics);
}
}
else
{
if (reportNoTargetType && !boundUnconvertedObjectCreationExpression.HasAnyErrors)
{
diagnostics.Add(ErrorCode.ERR_ImplicitObjectCreationNoTargetType, boundUnconvertedObjectCreationExpression.Syntax.GetLocation(), boundUnconvertedObjectCreationExpression.Display);
}
boundExpression = BindObjectCreationForErrorRecovery(boundUnconvertedObjectCreationExpression, diagnostics);
}
}
else
{
if (reportNoTargetType)
{
diagnostics.Add(ErrorCode.ERR_DefaultLiteralNoTargetType, boundDefaultLiteral.Syntax.GetLocation());
}
boundExpression = new BoundDefaultExpression(boundDefaultLiteral.Syntax, null, boundDefaultLiteral.ConstantValueOpt, CreateErrorType(), hasErrors: true).WithSuppression(boundDefaultLiteral.IsSuppressed);
}
}
else
{
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(boundTupleLiteral.Arguments.Length);
ImmutableArray<BoundExpression>.Enumerator enumerator = boundTupleLiteral.Arguments.GetEnumerator();
while (enumerator.MoveNext())
{
BoundExpression current = enumerator.Current;
instance.Add(BindToNaturalType(current, diagnostics, reportNoTargetType));
}
boundExpression = new BoundConvertedTupleLiteral(boundTupleLiteral.Syntax, boundTupleLiteral, wasTargetTyped: false, instance.ToImmutableAndFree(), boundTupleLiteral.ArgumentNamesOpt, boundTupleLiteral.InferredNamesOpt, boundTupleLiteral.Type, boundTupleLiteral.HasErrors).WithSuppression(boundTupleLiteral.IsSuppressed);
}
}
else
{
TypeSymbol typeSymbol = boundUnconvertedConditionalOperator.Type;
bool hasErrors = boundUnconvertedConditionalOperator.HasErrors;
if ((object)typeSymbol == null)
{
typeSymbol = CreateErrorType();
hasErrors = true;
object obj = boundUnconvertedConditionalOperator.Consequence.Display;
object obj2 = boundUnconvertedConditionalOperator.Alternative.Display;
if (boundUnconvertedConditionalOperator.NoCommonTypeError == ErrorCode.ERR_InvalidQM && obj is Symbol symbol && obj2 is Symbol symbol2)
{
SymbolDistinguisher symbolDistinguisher = new SymbolDistinguisher(Compilation, symbol, symbol2);
obj = symbolDistinguisher.First;
obj2 = symbolDistinguisher.Second;
}
diagnostics.Add(boundUnconvertedConditionalOperator.NoCommonTypeError, boundUnconvertedConditionalOperator.Syntax.Location, obj, obj2);
}
boundExpression = ConvertConditionalExpression(boundUnconvertedConditionalOperator, typeSymbol, null, diagnostics, hasErrors);
}
}
else
{
TypeSymbol typeSymbol2 = boundUnconvertedSwitchExpression.Type;
SwitchExpressionSyntax switchExpressionSyntax = (SwitchExpressionSyntax)(object)boundUnconvertedSwitchExpression.Syntax;
bool hasErrors2 = expression.HasErrors;
if ((object)typeSymbol2 == null)
{
SyntaxToken switchKeyword = switchExpressionSyntax.SwitchKeyword;
diagnostics.Add(ErrorCode.ERR_SwitchExpressionNoBestType, ((SyntaxToken)(ref switchKeyword)).GetLocation());
typeSymbol2 = CreateErrorType();
hasErrors2 = true;
}
boundExpression = ConvertSwitchExpression(boundUnconvertedSwitchExpression, typeSymbol2, null, diagnostics, hasErrors2);
}
goto IL_036b;
IL_0369:
boundExpression = expression;
goto IL_036b;
IL_036b:
return boundExpression?.WithWasConverted();
}
private BoundExpression BindToInferredDelegateType(BoundExpression expr, BindingDiagnosticBag diagnostics)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
SyntaxNode syntax = expr.Syntax;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
NamedTypeSymbol namedTypeSymbol = expr.GetInferredDelegateType(ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(syntax, useSiteInfo);
if ((object)namedTypeSymbol == null)
{
if (CheckFeatureAvailability(syntax, MessageID.IDS_FeatureInferredDelegateType, diagnostics))
{
diagnostics.Add(ErrorCode.ERR_CannotInferDelegateType, syntax.GetLocation());
}
namedTypeSymbol = CreateErrorType();
}
return GenerateConversionForAssignment(namedTypeSymbol, expr, diagnostics);
}
internal BoundExpression BindValueAllowArgList(ExpressionSyntax node, BindingDiagnosticBag diagnostics, BindValueKind valueKind)
{
BoundExpression expr = BindExpressionAllowArgList(node, diagnostics);
return CheckValue(expr, valueKind, diagnostics);
}
internal BoundFieldEqualsValue BindFieldInitializer(FieldSymbol field, EqualsValueClauseSyntax initializerOpt, BindingDiagnosticBag diagnostics)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Invalid comparison between Unknown and I4
if (initializerOpt == null)
{
return null;
}
Binder binder = GetBinder((SyntaxNode)(object)initializerOpt);
BoundExpression boundExpression = binder.BindVariableOrAutoPropInitializerValue(initializerOpt, field.RefKind, field.GetFieldType(binder.FieldsBeingBound).Type, diagnostics);
if ((object)field != null && !field.IsStatic && (int)field.RefKind == 0 && field.ContainingSymbol is SourceMemberContainerTypeSymbol sourceMemberContainerTypeSymbol)
{
SynthesizedPrimaryConstructor primaryConstructor = sourceMemberContainerTypeSymbol.PrimaryConstructor;
if ((object)primaryConstructor != null)
{
(ParameterSymbol, SyntaxNode) tuple = TryGetPrimaryConstructorParameterUsedAsValue(primaryConstructor, boundExpression);
var (parameterSymbol, _) = tuple;
if ((object)parameterSymbol != null)
{
SyntaxNode item = tuple.Item2;
if (item != null && primaryConstructor.GetCapturedParameters().ContainsKey(parameterSymbol))
{
diagnostics.Add(ErrorCode.WRN_CapturedPrimaryConstructorParameterInFieldInitializer, item.Location, parameterSymbol);
}
}
}
}
return new BoundFieldEqualsValue((SyntaxNode)(object)initializerOpt, field, binder.GetDeclaredLocalsForScope((SyntaxNode)(object)initializerOpt), boundExpression);
}
internal BoundExpression BindVariableOrAutoPropInitializerValue(EqualsValueClauseSyntax initializerOpt, RefKind refKind, TypeSymbol varType, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (initializerOpt == null)
{
return null;
}
IsInitializerRefKindValid(initializerOpt, initializerOpt, refKind, diagnostics, out var valueKind, out var value);
BoundExpression expression = BindPossibleArrayInitializer(value, varType, valueKind, diagnostics);
return GenerateConversionForAssignment(varType, expression, diagnostics);
}
internal Binder CreateBinderForParameterDefaultValue(ParameterSymbol parameter, EqualsValueClauseSyntax defaultValueSyntax)
{
LocalScopeBinder next = new LocalScopeBinder(WithContainingMemberOrLambda(parameter.ContainingSymbol).WithAdditionalFlags(BinderFlags.ParameterDefaultValue));
return new ExecutableCodeBinder((SyntaxNode)(object)defaultValueSyntax, parameter.ContainingSymbol, next);
}
internal BoundParameterEqualsValue BindParameterDefaultValue(EqualsValueClauseSyntax defaultValueSyntax, ParameterSymbol parameter, BindingDiagnosticBag diagnostics, out BoundExpression valueBeforeConversion)
{
Binder binder = GetBinder((SyntaxNode)(object)defaultValueSyntax);
valueBeforeConversion = binder.BindValue(defaultValueSyntax.Value, diagnostics, BindValueKind.RValue);
return new BoundParameterEqualsValue((SyntaxNode)(object)defaultValueSyntax, parameter, binder.GetDeclaredLocalsForScope((SyntaxNode)(object)defaultValueSyntax), binder.GenerateConversionForAssignment(parameter.Type, valueBeforeConversion, diagnostics, ConversionForAssignmentFlags.DefaultParameter));
}
internal BoundFieldEqualsValue BindEnumConstantInitializer(SourceEnumConstantSymbol symbol, EqualsValueClauseSyntax equalsValueSyntax, BindingDiagnosticBag diagnostics)
{
Binder binder = GetBinder((SyntaxNode)(object)equalsValueSyntax);
BoundExpression expression = binder.BindValue(equalsValueSyntax.Value, diagnostics, BindValueKind.RValue);
expression = binder.GenerateConversionForAssignment(symbol.ContainingType.EnumUnderlyingType, expression, diagnostics);
return new BoundFieldEqualsValue((SyntaxNode)(object)equalsValueSyntax, symbol, binder.GetDeclaredLocalsForScope((SyntaxNode)(object)equalsValueSyntax), expression);
}
public BoundExpression BindExpression(ExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
return BindExpression(node, diagnostics, invoked: false, indexed: false);
}
protected BoundExpression BindExpression(ExpressionSyntax node, BindingDiagnosticBag diagnostics, bool invoked, bool indexed)
{
BoundExpression boundExpression = BindExpressionInternal(node, diagnostics, invoked, indexed);
CheckContextForPointerTypes(node, diagnostics, boundExpression);
if (boundExpression.Kind == BoundKind.ArgListOperator)
{
Error(diagnostics, ErrorCode.ERR_IllegalArglist, (CSharpSyntaxNode)node);
boundExpression = ToBadExpression(boundExpression);
}
return boundExpression;
}
protected BoundExpression BindExpressionAllowArgList(ExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
BoundExpression boundExpression = BindExpressionInternal(node, diagnostics, invoked: false, indexed: false);
CheckContextForPointerTypes(node, diagnostics, boundExpression);
return boundExpression;
}
private void CheckContextForPointerTypes(ExpressionSyntax node, BindingDiagnosticBag diagnostics, BoundExpression expr)
{
if (!expr.HasAnyErrors && !IsInsideNameof)
{
TypeSymbol type = expr.Type;
if ((object)type != null && type.ContainsPointer())
{
ReportUnsafeIfNotAllowed((SyntaxNode)(object)node, diagnostics);
}
}
}
private BoundExpression BindExpressionInternal(ExpressionSyntax node, BindingDiagnosticBag diagnostics, bool invoked, bool indexed)
{
//IL_0513: Unknown result type (might be due to invalid IL or missing references)
//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
if (IsEarlyAttributeBinder && !EarlyWellKnownAttributeBinder.CanBeValidAttributeArgument(node))
{
return BadExpression((SyntaxNode)(object)node, LookupResultKind.NotAValue);
}
switch (node.Kind())
{
case SyntaxKind.AnonymousMethodExpression:
case SyntaxKind.SimpleLambdaExpression:
case SyntaxKind.ParenthesizedLambdaExpression:
return BindAnonymousFunction((AnonymousFunctionExpressionSyntax)node, diagnostics);
case SyntaxKind.ThisExpression:
return BindThis((ThisExpressionSyntax)node, diagnostics);
case SyntaxKind.BaseExpression:
return BindBase((BaseExpressionSyntax)node, diagnostics);
case SyntaxKind.InvocationExpression:
return BindInvocationExpression((InvocationExpressionSyntax)node, diagnostics);
case SyntaxKind.ArrayInitializerExpression:
return BindUnexpectedArrayInitializer((InitializerExpressionSyntax)node, diagnostics, ErrorCode.ERR_ArrayInitInBadPlace);
case SyntaxKind.ArrayCreationExpression:
return BindArrayCreationExpression((ArrayCreationExpressionSyntax)node, diagnostics);
case SyntaxKind.ImplicitArrayCreationExpression:
return BindImplicitArrayCreationExpression((ImplicitArrayCreationExpressionSyntax)node, diagnostics);
case SyntaxKind.StackAllocArrayCreationExpression:
return BindStackAllocArrayCreationExpression((StackAllocArrayCreationExpressionSyntax)node, diagnostics);
case SyntaxKind.ImplicitStackAllocArrayCreationExpression:
return BindImplicitStackAllocArrayCreationExpression((ImplicitStackAllocArrayCreationExpressionSyntax)node, diagnostics);
case SyntaxKind.ObjectCreationExpression:
return BindObjectCreationExpression((ObjectCreationExpressionSyntax)node, diagnostics);
case SyntaxKind.ImplicitObjectCreationExpression:
return BindImplicitObjectCreationExpression((ImplicitObjectCreationExpressionSyntax)node, diagnostics);
case SyntaxKind.IdentifierName:
case SyntaxKind.GenericName:
return BindIdentifier((SimpleNameSyntax)node, invoked, indexed, diagnostics);
case SyntaxKind.SimpleMemberAccessExpression:
case SyntaxKind.PointerMemberAccessExpression:
return BindMemberAccess((MemberAccessExpressionSyntax)node, invoked, indexed, diagnostics);
case SyntaxKind.SimpleAssignmentExpression:
return BindAssignment((AssignmentExpressionSyntax)node, diagnostics);
case SyntaxKind.CastExpression:
return BindCast((CastExpressionSyntax)node, diagnostics);
case SyntaxKind.ElementAccessExpression:
return BindElementAccess((ElementAccessExpressionSyntax)node, diagnostics);
case SyntaxKind.AddExpression:
case SyntaxKind.SubtractExpression:
case SyntaxKind.MultiplyExpression:
case SyntaxKind.DivideExpression:
case SyntaxKind.ModuloExpression:
case SyntaxKind.LeftShiftExpression:
case SyntaxKind.RightShiftExpression:
case SyntaxKind.BitwiseOrExpression:
case SyntaxKind.BitwiseAndExpression:
case SyntaxKind.ExclusiveOrExpression:
case SyntaxKind.EqualsExpression:
case SyntaxKind.NotEqualsExpression:
case SyntaxKind.LessThanExpression:
case SyntaxKind.LessThanOrEqualExpression:
case SyntaxKind.GreaterThanExpression:
case SyntaxKind.GreaterThanOrEqualExpression:
case SyntaxKind.UnsignedRightShiftExpression:
return BindSimpleBinaryOperator((BinaryExpressionSyntax)node, diagnostics);
case SyntaxKind.LogicalOrExpression:
case SyntaxKind.LogicalAndExpression:
return BindConditionalLogicalOperator((BinaryExpressionSyntax)node, diagnostics);
case SyntaxKind.CoalesceExpression:
return BindNullCoalescingOperator((BinaryExpressionSyntax)node, diagnostics);
case SyntaxKind.ConditionalAccessExpression:
return BindConditionalAccessExpression((ConditionalAccessExpressionSyntax)node, diagnostics);
case SyntaxKind.MemberBindingExpression:
return BindMemberBindingExpression((MemberBindingExpressionSyntax)node, invoked, indexed, diagnostics);
case SyntaxKind.ElementBindingExpression:
return BindElementBindingExpression((ElementBindingExpressionSyntax)node, diagnostics);
case SyntaxKind.IsExpression:
return BindIsOperator((BinaryExpressionSyntax)node, diagnostics);
case SyntaxKind.AsExpression:
return BindAsOperator((BinaryExpressionSyntax)node, diagnostics);
case SyntaxKind.UnaryPlusExpression:
case SyntaxKind.UnaryMinusExpression:
case SyntaxKind.BitwiseNotExpression:
case SyntaxKind.LogicalNotExpression:
return BindUnaryOperator((PrefixUnaryExpressionSyntax)node, diagnostics);
case SyntaxKind.IndexExpression:
return BindFromEndIndexExpression((PrefixUnaryExpressionSyntax)node, diagnostics);
case SyntaxKind.RangeExpression:
return BindRangeExpression((RangeExpressionSyntax)node, diagnostics);
case SyntaxKind.AddressOfExpression:
return BindAddressOfExpression((PrefixUnaryExpressionSyntax)node, diagnostics);
case SyntaxKind.PointerIndirectionExpression:
return BindPointerIndirectionExpression((PrefixUnaryExpressionSyntax)node, diagnostics);
case SyntaxKind.PostIncrementExpression:
case SyntaxKind.PostDecrementExpression:
return BindIncrementOperator(node, ((PostfixUnaryExpressionSyntax)node).Operand, ((PostfixUnaryExpressionSyntax)node).OperatorToken, diagnostics);
case SyntaxKind.PreIncrementExpression:
case SyntaxKind.PreDecrementExpression:
return BindIncrementOperator(node, ((PrefixUnaryExpressionSyntax)node).Operand, ((PrefixUnaryExpressionSyntax)node).OperatorToken, diagnostics);
case SyntaxKind.ConditionalExpression:
return BindConditionalOperator((ConditionalExpressionSyntax)node, diagnostics);
case SyntaxKind.SwitchExpression:
return BindSwitchExpression((SwitchExpressionSyntax)node, diagnostics);
case SyntaxKind.NumericLiteralExpression:
case SyntaxKind.StringLiteralExpression:
case SyntaxKind.CharacterLiteralExpression:
case SyntaxKind.TrueLiteralExpression:
case SyntaxKind.FalseLiteralExpression:
case SyntaxKind.NullLiteralExpression:
return BindLiteralConstant((LiteralExpressionSyntax)node, diagnostics);
case SyntaxKind.Utf8StringLiteralExpression:
return BindUtf8StringLiteral((LiteralExpressionSyntax)node, diagnostics);
case SyntaxKind.DefaultLiteralExpression:
MessageID.IDS_FeatureDefaultLiteral.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)node);
return new BoundDefaultLiteral((SyntaxNode)(object)node);
case SyntaxKind.ParenthesizedExpression:
return BindParenthesizedExpression(((ParenthesizedExpressionSyntax)node).Expression, diagnostics);
case SyntaxKind.CheckedExpression:
case SyntaxKind.UncheckedExpression:
return BindCheckedExpression((CheckedExpressionSyntax)node, diagnostics);
case SyntaxKind.DefaultExpression:
return BindDefaultExpression((DefaultExpressionSyntax)node, diagnostics);
case SyntaxKind.TypeOfExpression:
return BindTypeOf((TypeOfExpressionSyntax)node, diagnostics);
case SyntaxKind.SizeOfExpression:
return BindSizeOf((SizeOfExpressionSyntax)node, diagnostics);
case SyntaxKind.AddAssignmentExpression:
case SyntaxKind.SubtractAssignmentExpression:
case SyntaxKind.MultiplyAssignmentExpression:
case SyntaxKind.DivideAssignmentExpression:
case SyntaxKind.ModuloAssignmentExpression:
case SyntaxKind.AndAssignmentExpression:
case SyntaxKind.ExclusiveOrAssignmentExpression:
case SyntaxKind.OrAssignmentExpression:
case SyntaxKind.LeftShiftAssignmentExpression:
case SyntaxKind.RightShiftAssignmentExpression:
case SyntaxKind.UnsignedRightShiftAssignmentExpression:
return BindCompoundAssignment((AssignmentExpressionSyntax)node, diagnostics);
case SyntaxKind.CoalesceAssignmentExpression:
return BindNullCoalescingAssignmentOperator((AssignmentExpressionSyntax)node, diagnostics);
case SyntaxKind.AliasQualifiedName:
case SyntaxKind.PredefinedType:
return BindNamespaceOrType(node, diagnostics);
case SyntaxKind.QueryExpression:
return BindQuery((QueryExpressionSyntax)node, diagnostics);
case SyntaxKind.AnonymousObjectCreationExpression:
return BindAnonymousObjectCreation((AnonymousObjectCreationExpressionSyntax)node, diagnostics);
case SyntaxKind.QualifiedName:
return BindQualifiedName((QualifiedNameSyntax)node, diagnostics);
case SyntaxKind.ComplexElementInitializerExpression:
return BindUnexpectedComplexElementInitializer((InitializerExpressionSyntax)node, diagnostics);
case SyntaxKind.ArgListExpression:
return BindArgList(node, diagnostics);
case SyntaxKind.RefTypeExpression:
return BindRefType((RefTypeExpressionSyntax)node, diagnostics);
case SyntaxKind.MakeRefExpression:
return BindMakeRef((MakeRefExpressionSyntax)node, diagnostics);
case SyntaxKind.RefValueExpression:
return BindRefValue((RefValueExpressionSyntax)node, diagnostics);
case SyntaxKind.AwaitExpression:
return BindAwait((AwaitExpressionSyntax)node, diagnostics);
case SyntaxKind.OmittedTypeArgument:
case SyntaxKind.ObjectInitializerExpression:
case SyntaxKind.OmittedArraySizeExpression:
return BadExpression((SyntaxNode)(object)node);
case SyntaxKind.CollectionExpression:
return BindCollectionExpression((CollectionExpressionSyntax)node, diagnostics);
case SyntaxKind.NullableType:
return BadExpression((SyntaxNode)(object)node);
case SyntaxKind.InterpolatedStringExpression:
return BindInterpolatedString((InterpolatedStringExpressionSyntax)node, diagnostics);
case SyntaxKind.IsPatternExpression:
return BindIsPatternExpression((IsPatternExpressionSyntax)node, diagnostics);
case SyntaxKind.TupleExpression:
return BindTupleExpression((TupleExpressionSyntax)node, diagnostics);
case SyntaxKind.ThrowExpression:
return BindThrowExpression((ThrowExpressionSyntax)node, diagnostics);
case SyntaxKind.RefType:
return BindRefType(node, diagnostics);
case SyntaxKind.ScopedType:
return BindScopedType(node, diagnostics);
case SyntaxKind.RefExpression:
return BindRefExpression((RefExpressionSyntax)node, diagnostics);
case SyntaxKind.DeclarationExpression:
return BindDeclarationExpressionAsError((DeclarationExpressionSyntax)node, diagnostics);
case SyntaxKind.SuppressNullableWarningExpression:
return BindSuppressNullableWarningExpression((PostfixUnaryExpressionSyntax)node, diagnostics);
case SyntaxKind.WithExpression:
return BindWithExpression((WithExpressionSyntax)node, diagnostics);
default:
diagnostics.Add(ErrorCode.ERR_InternalError, ((SyntaxNode)node).Location);
return BadExpression((SyntaxNode)(object)node);
}
}
internal virtual BoundSwitchExpressionArm BindSwitchExpressionArm(SwitchExpressionArmSyntax node, TypeSymbol switchGoverningType, BindingDiagnosticBag diagnostics)
{
return NextRequired.BindSwitchExpressionArm(node, switchGoverningType, diagnostics);
}
private BoundExpression BindRefExpression(RefExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken firstToken = node.GetFirstToken();
diagnostics.Add(ErrorCode.ERR_UnexpectedToken, ((SyntaxToken)(ref firstToken)).GetLocation(), ((SyntaxToken)(ref firstToken)).ValueText);
return new BoundBadExpression((SyntaxNode)(object)node, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create(BindToTypeForErrorRecovery(BindValue(node.Expression, BindingDiagnosticBag.Discarded, BindValueKind.RefersToLocation))), CreateErrorType("ref"));
}
private BoundExpression BindRefType(ExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken firstToken = node.GetFirstToken();
diagnostics.Add(ErrorCode.ERR_UnexpectedToken, ((SyntaxToken)(ref firstToken)).GetLocation(), ((SyntaxToken)(ref firstToken)).ValueText);
return new BoundTypeExpression((SyntaxNode)(object)node, null, CreateErrorType("ref"));
}
private BoundExpression BindScopedType(ExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken firstToken = node.GetFirstToken();
diagnostics.Add(ErrorCode.ERR_UnexpectedToken, ((SyntaxToken)(ref firstToken)).GetLocation(), ((SyntaxToken)(ref firstToken)).ValueText);
return new BoundTypeExpression((SyntaxNode)(object)node, null, CreateErrorType("scoped"));
}
private BoundExpression BindThrowExpression(ThrowExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureThrowExpression.CheckFeatureAvailability(diagnostics, node.ThrowKeyword);
bool hasErrors = ((SyntaxNode)node).HasErrors;
if (!IsThrowExpressionInProperContext(node))
{
SyntaxToken throwKeyword = node.ThrowKeyword;
diagnostics.Add(ErrorCode.ERR_ThrowMisplaced, ((SyntaxToken)(ref throwKeyword)).GetLocation());
hasErrors = true;
}
BoundExpression expression = BindThrownExpression(node.Expression, diagnostics, ref hasErrors);
return new BoundThrowExpression((SyntaxNode)(object)node, expression, null, hasErrors);
}
private static bool IsThrowExpressionInProperContext(ThrowExpressionSyntax node)
{
CSharpSyntaxNode parent = node.Parent;
if (parent == null || ((SyntaxNode)node).HasErrors)
{
return true;
}
switch (parent.Kind())
{
case SyntaxKind.ConditionalExpression:
{
ConditionalExpressionSyntax conditionalExpressionSyntax = (ConditionalExpressionSyntax)parent;
if (node != conditionalExpressionSyntax.WhenTrue)
{
return node == conditionalExpressionSyntax.WhenFalse;
}
return true;
}
case SyntaxKind.CoalesceExpression:
{
BinaryExpressionSyntax binaryExpressionSyntax = (BinaryExpressionSyntax)parent;
return node == binaryExpressionSyntax.Right;
}
case SyntaxKind.SimpleLambdaExpression:
case SyntaxKind.ParenthesizedLambdaExpression:
case SyntaxKind.ArrowExpressionClause:
case SyntaxKind.SwitchExpressionArm:
return true;
default:
return false;
}
}
private BoundExpression BindDeclarationExpressionAsError(DeclarationExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
bool isConst = false;
bool isScoped;
bool isVar;
AliasSymbol alias;
TypeWithAnnotations declTypeWithAnnotations = BindVariableTypeWithAnnotations(node.Designation, diagnostics, node.Type.SkipScoped(out isScoped).SkipRef(), ref isConst, out isVar, out alias);
Error(diagnostics, ErrorCode.ERR_DeclarationExpressionNotPermitted, (CSharpSyntaxNode)node);
return BindDeclarationVariablesForErrorRecovery(declTypeWithAnnotations, node.Designation, node, diagnostics);
}
private BoundExpression BindDeclarationVariablesForErrorRecovery(TypeWithAnnotations declTypeWithAnnotations, VariableDesignationSyntax node, CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
declTypeWithAnnotations = (declTypeWithAnnotations.HasType ? declTypeWithAnnotations : TypeWithAnnotations.Create(CreateErrorType("var")));
switch (node.Kind())
{
case SyntaxKind.SingleVariableDesignation:
{
SingleVariableDesignationSyntax designation = (SingleVariableDesignationSyntax)node;
BoundExpression expression = BindDeconstructionVariable(declTypeWithAnnotations, designation, syntax, diagnostics);
return BindToTypeForErrorRecovery(expression);
}
case SyntaxKind.DiscardDesignation:
return BindDiscardExpression((SyntaxNode)(object)syntax, declTypeWithAnnotations);
case SyntaxKind.ParenthesizedVariableDesignation:
{
ParenthesizedVariableDesignationSyntax obj = (ParenthesizedVariableDesignationSyntax)node;
int count = obj.Variables.Count;
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(count);
ArrayBuilder<string> inferredElementNames = ArrayBuilder<string>.GetInstance(count);
Enumerator<VariableDesignationSyntax> enumerator = obj.Variables.GetEnumerator();
while (enumerator.MoveNext())
{
VariableDesignationSyntax current = enumerator.Current;
instance.Add(BindDeclarationVariablesForErrorRecovery(declTypeWithAnnotations, current, current, diagnostics));
inferredElementNames.Add(InferTupleElementName((SyntaxNode)(object)current));
}
ImmutableArray<BoundExpression> immutableArray = instance.ToImmutableAndFree();
PooledHashSet<string> instance2 = PooledHashSet<string>.GetInstance();
RemoveDuplicateInferredTupleNamesAndFreeIfEmptied(ref inferredElementNames, (HashSet<string>)(object)instance2);
instance2.Free();
ImmutableArray<string> immutableArray2 = inferredElementNames?.ToImmutableAndFree() ?? default(ImmutableArray<string>);
ImmutableArray<bool> immutableArray3 = (immutableArray2.IsDefault ? default(ImmutableArray<bool>) : ImmutableArrayExtensions.SelectAsArray<string, bool>(immutableArray2, (Func<string, bool>)((string n) => n != null)));
bool flag = Compilation.LanguageVersion.DisallowInferredTupleElementNames();
NamedTypeSymbol type = NamedTypeSymbol.CreateTuple(null, ImmutableArrayExtensions.SelectAsArray<BoundExpression, TypeWithAnnotations>(immutableArray, (Func<BoundExpression, TypeWithAnnotations>)((BoundExpression e) => TypeWithAnnotations.Create(e.Type))), default(ImmutableArray<Location>), immutableArray2, Compilation, shouldCheckConstraints: false, includeNullability: false, flag ? immutableArray3 : default(ImmutableArray<bool>));
return new BoundConvertedTupleLiteral((SyntaxNode)(object)syntax, null, wasTargetTyped: true, immutableArray, immutableArray2, immutableArray3, type);
}
default:
throw ExceptionUtilities.UnexpectedValue((object)node.Kind());
}
}
private BoundExpression BindTupleExpression(TupleExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Invalid comparison between Unknown and I4
MessageID.IDS_FeatureTuples.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)node);
SeparatedSyntaxList<ArgumentSyntax> arguments = node.Arguments;
int count = arguments.Count;
if (count < 2)
{
ImmutableArray<BoundExpression> childNodes = ((count == 1) ? ImmutableArray.Create(BindValue(arguments[0].Expression, diagnostics, BindValueKind.RValue)) : ImmutableArray<BoundExpression>.Empty);
return BadExpression((SyntaxNode)(object)node, childNodes);
}
bool flag = true;
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(arguments.Count);
ArrayBuilder<TypeWithAnnotations> instance2 = ArrayBuilder<TypeWithAnnotations>.GetInstance(arguments.Count);
ArrayBuilder<Location> instance3 = ArrayBuilder<Location>.GetInstance(arguments.Count);
(ImmutableArray<string> elementNamesArray, ImmutableArray<bool> inferredArray, bool hasErrors) tuple = ExtractTupleElementNames(arguments, diagnostics);
ImmutableArray<string> item = tuple.elementNamesArray;
ImmutableArray<bool> item2 = tuple.inferredArray;
bool item3 = tuple.hasErrors;
for (int i = 0; i < count; i++)
{
ArgumentSyntax argumentSyntax = arguments[i];
IdentifierNameSyntax identifierNameSyntax = argumentSyntax.NameColon?.Name;
if (identifierNameSyntax != null)
{
instance3.Add(((SyntaxNode)identifierNameSyntax).Location);
}
else
{
instance3.Add(((SyntaxNode)argumentSyntax).Location);
}
BoundExpression boundExpression = BindValue(argumentSyntax.Expression, diagnostics, BindValueKind.RValue);
TypeSymbol? type = boundExpression.Type;
if ((object)type != null && (int)type.SpecialType == 6)
{
diagnostics.Add(ErrorCode.ERR_VoidInTuple, ((SyntaxNode)argumentSyntax).Location);
boundExpression = new BoundBadExpression((SyntaxNode)(object)argumentSyntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create(boundExpression), CreateErrorType("void"));
}
instance.Add(boundExpression);
TypeWithAnnotations typeWithAnnotations = TypeWithAnnotations.Create(boundExpression.Type);
instance2.Add(typeWithAnnotations);
if (!typeWithAnnotations.HasType)
{
flag = false;
}
}
NamedTypeSymbol type2 = null;
ImmutableArray<TypeWithAnnotations> immutableArray = instance2.ToImmutableAndFree();
ImmutableArray<Location> immutableArray2 = instance3.ToImmutableAndFree();
if (flag)
{
bool flag2 = Compilation.LanguageVersion.DisallowInferredTupleElementNames();
type2 = NamedTypeSymbol.CreateTuple(((SyntaxNode)node).Location, immutableArray, immutableArray2, item, Compilation, shouldCheckConstraints: true, includeNullability: false, syntax: node, diagnostics: diagnostics, errorPositions: flag2 ? item2 : default(ImmutableArray<bool>));
}
else
{
NamedTypeSymbol.VerifyTupleTypePresent(immutableArray.Length, node, Compilation, diagnostics);
}
return new BoundTupleLiteral((SyntaxNode)(object)node, instance.ToImmutableAndFree(), item, item2, type2, item3);
}
private static (ImmutableArray<string> elementNamesArray, ImmutableArray<bool> inferredArray, bool hasErrors) ExtractTupleElementNames(SeparatedSyntaxList<ArgumentSyntax> arguments, BindingDiagnosticBag diagnostics)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
bool item = false;
int count = arguments.Count;
PooledHashSet<string> instance = PooledHashSet<string>.GetInstance();
ArrayBuilder<string> elementNames = null;
ArrayBuilder<string> elementNames2 = null;
for (int i = 0; i < count; i++)
{
ArgumentSyntax argumentSyntax = arguments[i];
IdentifierNameSyntax identifierNameSyntax = argumentSyntax.NameColon?.Name;
string name = null;
string name2 = null;
if (identifierNameSyntax != null)
{
SyntaxToken identifier = identifierNameSyntax.Identifier;
name = ((SyntaxToken)(ref identifier)).ValueText;
if (diagnostics != null && !CheckTupleMemberName(name, i, SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)argumentSyntax.NameColon.Name), diagnostics, instance))
{
item = true;
}
}
else
{
name2 = InferTupleElementName((SyntaxNode)(object)argumentSyntax.Expression);
}
CollectTupleFieldMemberName(name, i, count, ref elementNames);
CollectTupleFieldMemberName(name2, i, count, ref elementNames2);
}
RemoveDuplicateInferredTupleNamesAndFreeIfEmptied(ref elementNames2, (HashSet<string>)(object)instance);
instance.Free();
(ImmutableArray<string>, ImmutableArray<bool>) tuple = MergeTupleElementNames(elementNames, elementNames2);
elementNames?.Free();
elementNames2?.Free();
return (elementNamesArray: tuple.Item1, inferredArray: tuple.Item2, hasErrors: item);
}
private static (ImmutableArray<string> names, ImmutableArray<bool> inferred) MergeTupleElementNames(ArrayBuilder<string> elementNames, ArrayBuilder<string> inferredElementNames)
{
if (elementNames == null)
{
if (inferredElementNames == null)
{
return (names: default(ImmutableArray<string>), inferred: default(ImmutableArray<bool>));
}
ImmutableArray<string> immutableArray = inferredElementNames.ToImmutable();
return (names: immutableArray, inferred: ImmutableArrayExtensions.SelectAsArray<string, bool>(immutableArray, (Func<string, bool>)((string n) => n != null)));
}
if (inferredElementNames == null)
{
return (names: elementNames.ToImmutable(), inferred: default(ImmutableArray<bool>));
}
ArrayBuilder<bool> instance = ArrayBuilder<bool>.GetInstance(elementNames.Count);
for (int num = 0; num < elementNames.Count; num++)
{
string text = inferredElementNames[num];
if (elementNames[num] == null && text != null)
{
elementNames[num] = text;
instance.Add(true);
}
else
{
instance.Add(false);
}
}
return (names: elementNames.ToImmutable(), inferred: instance.ToImmutableAndFree());
}
private static void RemoveDuplicateInferredTupleNamesAndFreeIfEmptied(ref ArrayBuilder<string> inferredElementNames, HashSet<string> uniqueFieldNames)
{
//IL_000d: 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)
if (inferredElementNames == null)
{
return;
}
PooledHashSet<string> instance = PooledHashSet<string>.GetInstance();
Enumerator<string> enumerator = inferredElementNames.GetEnumerator();
while (enumerator.MoveNext())
{
string current = enumerator.Current;
if (current != null && !uniqueFieldNames.Add(current))
{
((HashSet<string>)(object)instance).Add(current);
}
}
for (int i = 0; i < inferredElementNames.Count; i++)
{
string text = inferredElementNames[i];
if (text != null && ((HashSet<string>)(object)instance).Contains(text))
{
inferredElementNames[i] = null;
}
}
instance.Free();
if (ArrayBuilderExtensions.All<string>(inferredElementNames, (Func<string, bool>)((string n) => n == null)))
{
inferredElementNames.Free();
inferredElementNames = null;
}
}
private static string InferTupleElementName(SyntaxNode syntax)
{
string text = syntax.TryGetInferredMemberName();
if (text == null || NamedTypeSymbol.IsTupleElementNameReserved(text) != -1)
{
return null;
}
return text;
}
private BoundExpression BindRefValue(RefValueExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
BoundExpression boundExpression = BindValue(node.Expression, diagnostics, BindValueKind.RValue);
bool hasErrors = boundExpression.HasAnyErrors;
TypeSymbol specialType = Compilation.GetSpecialType((SpecialType)36);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyConversionFromExpression(boundExpression, specialType, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
if (!conversion.IsImplicit || !conversion.IsValid)
{
hasErrors = true;
GenerateImplicitConversionError(diagnostics, (SyntaxNode)(object)node, conversion, boundExpression, specialType);
}
boundExpression = CreateConversion(boundExpression, conversion, specialType, diagnostics);
TypeWithAnnotations typeWithAnnotations = BindType(node.Type, diagnostics);
return new BoundRefValueOperator((SyntaxNode)(object)node, typeWithAnnotations.NullableAnnotation, boundExpression, typeWithAnnotations.Type, hasErrors);
}
private BoundExpression BindMakeRef(MakeRefExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
BoundExpression boundExpression = BindValue(node.Expression, diagnostics, BindValueKind.RefOrOut);
bool hasErrors = boundExpression.HasAnyErrors;
TypeSymbol specialType = GetSpecialType((SpecialType)36, diagnostics, (SyntaxNode)(object)node);
if ((object)boundExpression.Type != null && boundExpression.Type.IsRestrictedType())
{
Error(diagnostics, ErrorCode.ERR_MethodArgCantBeRefAny, (CSharpSyntaxNode)node, new object[1] { boundExpression.Type });
hasErrors = true;
}
return new BoundMakeRefOperator((SyntaxNode)(object)node, boundExpression, specialType, hasErrors);
}
private BoundExpression BindRefType(RefTypeExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
BoundExpression boundExpression = BindValue(node.Expression, diagnostics, BindValueKind.RValue);
bool hasErrors = boundExpression.HasAnyErrors;
TypeSymbol specialType = Compilation.GetSpecialType((SpecialType)36);
TypeSymbol wellKnownType = GetWellKnownType((WellKnownType)61, diagnostics, (SyntaxNode)(object)node);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyConversionFromExpression(boundExpression, specialType, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
if (!conversion.IsImplicit || !conversion.IsValid)
{
hasErrors = true;
GenerateImplicitConversionError(diagnostics, (SyntaxNode)(object)node, conversion, boundExpression, specialType);
}
boundExpression = CreateConversion(boundExpression, conversion, specialType, diagnostics);
return new BoundRefTypeOperator((SyntaxNode)(object)node, boundExpression, null, wellKnownType, hasErrors);
}
private BoundExpression BindArgList(CSharpSyntaxNode node, BindingDiagnosticBag diagnostics)
{
TypeSymbol specialType = GetSpecialType((SpecialType)38, diagnostics, (SyntaxNode)(object)node);
MethodSymbol methodSymbol = ContainingMember() as MethodSymbol;
bool hasErrors = false;
if ((object)methodSymbol == null || !methodSymbol.IsVararg)
{
Error(diagnostics, ErrorCode.ERR_ArgsInvalid, node);
hasErrors = true;
}
else if (ContainingMemberOrLambda != methodSymbol)
{
Error(diagnostics, ErrorCode.ERR_SpecialByRefInLambda, node, specialType);
hasErrors = true;
}
return new BoundArgList((SyntaxNode)(object)node, specialType, hasErrors);
}
private BoundExpression BindQualifiedName(QualifiedNameSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
return BindMemberAccessWithBoundLeft(node, BindLeftOfPotentialColorColorMemberAccess(node.Left, diagnostics), node.Right, node.DotToken, invoked: false, indexed: false, diagnostics);
}
private BoundExpression BindParenthesizedExpression(ExpressionSyntax innerExpression, BindingDiagnosticBag diagnostics)
{
BoundExpression boundExpression = BindExpression(innerExpression, diagnostics);
CheckNotNamespaceOrType(boundExpression, diagnostics);
return boundExpression;
}
private BoundExpression BindTypeOf(TypeOfExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
ExpressionSyntax type = node.Type;
AliasSymbol alias;
TypeWithAnnotations typeWithAnnotations = new TypeofBinder(type, this).BindType(type, diagnostics, out alias);
TypeSymbol type2 = typeWithAnnotations.Type;
bool hasErrors = false;
if (type2.IsDynamic())
{
diagnostics.Add(ErrorCode.ERR_BadDynamicTypeof, ((SyntaxNode)node).Location);
hasErrors = true;
}
else if (typeWithAnnotations.NullableAnnotation.IsAnnotated() && type2.IsReferenceType)
{
diagnostics.Add(ErrorCode.ERR_BadNullableTypeof, ((SyntaxNode)node).Location);
hasErrors = true;
}
BoundTypeExpression sourceType = new BoundTypeExpression((SyntaxNode)(object)type, alias, typeWithAnnotations, type2.IsErrorType());
return new BoundTypeOfOperator((SyntaxNode)(object)node, sourceType, null, GetWellKnownType((WellKnownType)61, diagnostics, (SyntaxNode)(object)node), hasErrors);
}
private void CheckDisallowedAttributeDependentType(TypeWithAnnotations typeArgument, NameSyntax attributeName, BindingDiagnosticBag diagnostics)
{
typeArgument.VisitType(null, delegate(TypeWithAnnotations typeWithAnnotations, (NameSyntax attributeName, BindingDiagnosticBag diagnostics) arg, bool _)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Invalid comparison between Unknown and I4
(NameSyntax attributeName, BindingDiagnosticBag diagnostics) tuple = arg;
NameSyntax item = tuple.attributeName;
BindingDiagnosticBag item2 = tuple.diagnostics;
TypeSymbol type = typeWithAnnotations.Type;
if (type.IsDynamic() || (typeWithAnnotations.NullableAnnotation.IsAnnotated() && !type.IsValueType) || type.IsNativeIntegerWrapperType || (type.IsTupleType && !type.TupleElementNames.IsDefault))
{
item2.Add(ErrorCode.ERR_AttrDependentTypeNotAllowed, (SyntaxNode)(object)item, type);
return true;
}
if (type.IsUnboundGenericType() || (int)type.Kind == 17)
{
item2.Add(ErrorCode.ERR_AttrTypeArgCannotBeTypeVar, (SyntaxNode)(object)item, type);
return true;
}
return false;
}, null, (attributeName, diagnostics));
}
private BoundExpression BindSizeOf(SizeOfExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
ExpressionSyntax type = node.Type;
AliasSymbol alias;
TypeWithAnnotations typeWithAnnotations = BindType(type, diagnostics, out alias);
TypeSymbol type2 = typeWithAnnotations.Type;
bool hasErrors = type2.IsErrorType() || CheckManagedAddr(Compilation, type2, ((SyntaxNode)node).Location, diagnostics);
BoundTypeExpression sourceType = new BoundTypeExpression((SyntaxNode)(object)type, alias, typeWithAnnotations, hasErrors);
ConstantValue constantSizeOf = GetConstantSizeOf(type2);
bool hasErrors2 = constantSizeOf == null && ReportUnsafeIfNotAllowed((SyntaxNode)(object)node, diagnostics, type2);
return new BoundSizeOfOperator((SyntaxNode)(object)node, sourceType, constantSizeOf, GetSpecialType((SpecialType)13, diagnostics, (SyntaxNode)(object)node), hasErrors2);
}
internal static bool CheckManagedAddr(CSharpCompilation compilation, TypeSymbol type, Location location, BindingDiagnosticBag diagnostics, bool errorForManaged = false)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = default(CompoundUseSiteInfo<AssemblySymbol>);
useSiteInfo._002Ector((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics, compilation.Assembly);
ManagedKind managedKind = type.GetManagedKind(ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(location, useSiteInfo);
return CheckManagedAddr(compilation, type, managedKind, location, diagnostics, errorForManaged);
}
internal static bool CheckManagedAddr(CSharpCompilation compilation, TypeSymbol type, ManagedKind managedKind, Location location, BindingDiagnosticBag diagnostics, bool errorForManaged = false)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected I4, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
switch ((int)managedKind)
{
case 3:
if (errorForManaged)
{
diagnostics.Add(ErrorCode.ERR_ManagedAddr, location, type);
return true;
}
diagnostics.Add(ErrorCode.WRN_ManagedAddr, location, type);
return false;
case 2:
{
CSDiagnosticInfo featureAvailabilityDiagnosticInfo = MessageID.IDS_FeatureUnmanagedConstructedTypes.GetFeatureAvailabilityDiagnosticInfo(compilation);
if (featureAvailabilityDiagnosticInfo != null)
{
diagnostics.Add((DiagnosticInfo?)(object)featureAvailabilityDiagnosticInfo, location);
return true;
}
break;
}
case 0:
throw ExceptionUtilities.UnexpectedValue((object)managedKind);
}
return false;
}
internal static ConstantValue GetConstantSizeOf(TypeSymbol type)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return ConstantValue.CreateSizeOf((type.GetEnumUnderlyingType() ?? type).SpecialType);
}
private BoundExpression BindDefaultExpression(DefaultExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureDefault.CheckFeatureAvailability(diagnostics, node.Keyword);
AliasSymbol alias;
TypeWithAnnotations typeWithAnnotations = BindType(node.Type, diagnostics, out alias);
BoundTypeExpression targetType = new BoundTypeExpression((SyntaxNode)(object)node.Type, alias, typeWithAnnotations);
TypeSymbol type = typeWithAnnotations.Type;
return new BoundDefaultExpression((SyntaxNode)(object)node, targetType, type.GetDefaultValue(), type);
}
private BoundExpression BindIdentifier(SimpleNameSyntax node, bool invoked, bool indexed, BindingDiagnosticBag diagnostics)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Invalid comparison between Unknown and I4
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Invalid comparison between Unknown and I4
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
if (((SyntaxNode)node).IsMissing)
{
return BadExpression((SyntaxNode)(object)node);
}
bool flag = node.Arity > 0;
SeparatedSyntaxList<TypeSyntax> val = (SeparatedSyntaxList<TypeSyntax>)((node.Kind() == SyntaxKind.GenericName) ? ((GenericNameSyntax)node).TypeArgumentList.Arguments : default(SeparatedSyntaxList<TypeSyntax>));
ImmutableArray<TypeWithAnnotations> typeArguments = (flag ? BindTypeArguments(val, diagnostics) : default(ImmutableArray<TypeWithAnnotations>));
LookupResult instance = LookupResult.GetInstance();
SyntaxToken identifier = node.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupIdentifier(instance, node, invoked, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
BoundExpression boundExpression2;
if (instance.Kind != LookupResultKind.Empty)
{
ArrayBuilder<Symbol> instance2 = ArrayBuilder<Symbol>.GetInstance();
bool wasError;
Symbol symbol = GetSymbolOrMethodOrPropertyGroup(instance, (SyntaxNode)(object)node, valueText, node.Arity, instance2, diagnostics, out wasError, null);
if ((object)symbol == null)
{
BoundExpression boundExpression = SynthesizeMethodGroupReceiver(node, instance2);
boundExpression2 = ConstructBoundMemberGroupAndReportOmittedTypeArguments((SyntaxNode)(object)node, val, typeArguments, boundExpression, valueText, instance2, instance, (boundExpression != null) ? BoundMethodGroupFlags.HasImplicitReceiver : BoundMethodGroupFlags.None, wasError, diagnostics);
ReportSimpleProgramLocalReferencedOutsideOfTopLevelStatement(node, instance2[0], diagnostics);
}
else
{
bool flag2 = (int)symbol.Kind == 11 || (int)symbol.Kind == 4;
if (flag && flag2)
{
symbol = ConstructNamedTypeUnlessTypeArgumentOmitted((SyntaxNode)(object)node, (NamedTypeSymbol)symbol, val, typeArguments, diagnostics);
}
boundExpression2 = BindNonMethod(node, symbol, diagnostics, instance.Kind, indexed, wasError);
if (!flag2 && (flag || node.Kind() == SyntaxKind.GenericName))
{
boundExpression2 = new BoundBadExpression((SyntaxNode)(object)node, LookupResultKind.WrongArity, ImmutableArray.Create(symbol), ImmutableArray.Create(BindToTypeForErrorRecovery(boundExpression2)), boundExpression2.Type, wasError);
}
}
reportPrimaryConstructorParameterShadowing(node, symbol ?? instance2[0], valueText, invoked, instance, instance2, diagnostics);
instance2.Free();
}
else
{
boundExpression2 = null;
if (node is IdentifierNameSyntax node2)
{
NamedTypeSymbol namedTypeSymbol = BindNativeIntegerSymbolIfAny(node2, diagnostics);
if ((object)namedTypeSymbol != null)
{
boundExpression2 = new BoundTypeExpression((SyntaxNode)(object)node, null, namedTypeSymbol);
}
else if (FallBackOnDiscard(node2, diagnostics))
{
boundExpression2 = new BoundDiscardExpression((SyntaxNode)(object)node, NullableAnnotation.Annotated, isInferred: true, null);
}
}
if (boundExpression2 == null)
{
boundExpression2 = BadExpression((SyntaxNode)(object)node);
if (instance.Error != null)
{
Error(diagnostics, instance.Error, (SyntaxNode)(object)node);
}
else if (IsJoinRangeVariableInLeftKey(node))
{
Error(diagnostics, ErrorCode.ERR_QueryOuterKey, (CSharpSyntaxNode)node, new object[1] { valueText });
}
else if (IsInJoinRightKey(node))
{
Error(diagnostics, ErrorCode.ERR_QueryInnerKey, (CSharpSyntaxNode)node, new object[1] { valueText });
}
else
{
Error(diagnostics, ErrorCode.ERR_NameNotInContext, (CSharpSyntaxNode)node, new object[1] { valueText });
}
}
}
instance.Free();
return boundExpression2;
void reportPrimaryConstructorParameterShadowing(SimpleNameSyntax simpleNameSyntax, Symbol symbol2, string name, bool invoked2, LookupResult lookupResult, ArrayBuilder<Symbol> members, BindingDiagnosticBag bindingDiagnosticBag)
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Invalid comparison between Unknown and I4
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
if (symbol2.ContainingSymbol is NamedTypeSymbol { OriginalDefinition: var originalDefinition })
{
NamedTypeSymbol containingType = ContainingType;
if (containingType is SourceMemberContainerTypeSymbol { IsRecord: false, IsRecordStruct: false } sourceMemberContainerTypeSymbol)
{
SynthesizedPrimaryConstructor primaryConstructor = sourceMemberContainerTypeSymbol.PrimaryConstructor;
if ((object)primaryConstructor != null && primaryConstructor.ParameterCount != 0)
{
NamedTypeSymbol originalDefinition2 = containingType.OriginalDefinition;
Symbol symbol3 = ContainingMember();
if ((object)symbol3 != null && (int)symbol3.Kind != 11 && !symbol3.IsStatic && ImmutableArrayExtensions.Any<ParameterSymbol, string>(primaryConstructor.Parameters, (Func<ParameterSymbol, string, bool>)((ParameterSymbol p, string text) => p.Name == text), name) && (object)originalDefinition != originalDefinition2 && !ArrayBuilderExtensions.Any<Symbol, NamedTypeSymbol>(members, (Func<Symbol, NamedTypeSymbol, bool>)((Symbol m, NamedTypeSymbol containingTypeDefinition) => (object)m.ContainingSymbol.OriginalDefinition == containingTypeDefinition), originalDefinition2))
{
NamedTypeSymbol baseTypeNoUseSiteDiagnostics = originalDefinition2.BaseTypeNoUseSiteDiagnostics;
while ((object)baseTypeNoUseSiteDiagnostics != null && (object)originalDefinition != baseTypeNoUseSiteDiagnostics.OriginalDefinition)
{
baseTypeNoUseSiteDiagnostics = baseTypeNoUseSiteDiagnostics.OriginalDefinition.BaseTypeNoUseSiteDiagnostics;
}
if ((object)baseTypeNoUseSiteDiagnostics != null)
{
Binder binder = this;
while (binder != null && (!(binder is InContainerBinder { Container: var container }) || (object)container.OriginalDefinition != originalDefinition2))
{
binder = binder.Next;
}
if (binder != null)
{
Binder next = binder.Next;
if (next != null)
{
lookupResult.Clear();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo2 = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
next.LookupIdentifier(lookupResult, simpleNameSyntax, invoked2, ref useSiteInfo2);
if (lookupResult.Kind != LookupResultKind.Empty)
{
members.Clear();
if (GetSymbolOrMethodOrPropertyGroup(lookupResult, (SyntaxNode)(object)simpleNameSyntax, name, simpleNameSyntax.Arity, members, bindingDiagnosticBag, out var _, null) is ParameterSymbol parameterSymbol && (object)parameterSymbol.ContainingSymbol == primaryConstructor && !primaryConstructor.GetParametersPassedToTheBase().Contains(parameterSymbol))
{
bindingDiagnosticBag.Add(ErrorCode.WRN_PrimaryConstructorParameterIsShadowedAndNotPassedToBase, ((SyntaxNode)simpleNameSyntax).Location, parameterSymbol);
}
}
}
}
}
}
}
}
}
}
}
private void LookupIdentifier(LookupResult lookupResult, SimpleNameSyntax node, bool invoked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
LookupOptions lookupOptions = LookupOptions.AllMethodsOnArityZero;
if (invoked)
{
lookupOptions |= LookupOptions.MustBeInvocableIfMember;
}
if (!IsInMethodBody && !IsInsideNameof)
{
lookupOptions |= LookupOptions.MustNotBeMethodTypeParameter;
}
SyntaxToken identifier = node.Identifier;
LookupSymbolsWithFallback(lookupResult, ((SyntaxToken)(ref identifier)).ValueText, node.Arity, ref useSiteInfo, null, lookupOptions);
}
private static bool FallBackOnDiscard(IdentifierNameSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (!node.Identifier.IsUnderscoreToken())
{
return false;
}
int num;
if (node.GetContainingDeconstruction() == null)
{
num = (IsOutVarDiscardIdentifier(node) ? 1 : 0);
if (num == 0)
{
goto IL_0031;
}
}
else
{
num = 1;
}
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureDiscards, diagnostics);
goto IL_0031;
IL_0031:
return (byte)num != 0;
}
private static bool IsOutVarDiscardIdentifier(SimpleNameSyntax node)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
CSharpSyntaxNode parent = node.Parent;
if (parent != null && parent.Kind() == SyntaxKind.Argument)
{
return ((ArgumentSyntax)parent).RefOrOutKeyword.Kind() == SyntaxKind.OutKeyword;
}
return false;
}
private BoundExpression SynthesizeMethodGroupReceiver(CSharpSyntaxNode syntax, ArrayBuilder<Symbol> members)
{
//IL_0019: 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)
NamedTypeSymbol containingType = ContainingType;
if ((object)containingType == null)
{
return null;
}
NamedTypeSymbol containingType2 = members[0].ContainingType;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
if (containingType.IsEqualToOrDerivedFrom(containingType2, (TypeCompareKind)0, ref useSiteInfo) || (containingType.IsInterface && (containingType2.IsObjectType() || containingType.AllInterfacesNoUseSiteDiagnostics.Contains(containingType2))))
{
return ThisReference((SyntaxNode)(object)syntax, containingType, hasErrors: false, wasCompilerGenerated: true);
}
return TryBindInteractiveReceiver((SyntaxNode)(object)syntax, containingType2);
}
private bool IsBadLocalOrParameterCapture(Symbol symbol, TypeSymbol type, RefKind refKind)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Invalid comparison between Unknown and I4
if (((int)refKind != 0 || type.IsRestrictedType()) && ContainingMemberOrLambda is MethodSymbol methodSymbol && (object)symbol.ContainingSymbol != methodSymbol)
{
if ((int)methodSymbol.MethodKind == 0 || (int)methodSymbol.MethodKind == 17)
{
return !IsInsideNameof;
}
return false;
}
return false;
}
private BoundExpression BindNonMethod(SimpleNameSyntax node, Symbol symbol, BindingDiagnosticBag diagnostics, LookupResultKind resultKind, bool indexed, bool isError)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected I4, but got Unknown
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_05af: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_058c: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0292: Invalid comparison between Unknown and I4
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0383: Unknown result type (might be due to invalid IL or missing references)
//IL_0432: Unknown result type (might be due to invalid IL or missing references)
//IL_0438: Invalid comparison between Unknown and I4
//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
//IL_0457: Unknown result type (might be due to invalid IL or missing references)
//IL_045c: Unknown result type (might be due to invalid IL or missing references)
//IL_045e: Unknown result type (might be due to invalid IL or missing references)
//IL_0462: Unknown result type (might be due to invalid IL or missing references)
//IL_0466: Invalid comparison between Unknown and I4
SymbolKind kind = symbol.Kind;
if (((int)kind != 5 && (int)kind != 15) || 1 == 0)
{
ReportDiagnosticsIfObsolete(diagnostics, symbol, SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)node), hasBaseReceiver: false);
}
kind = symbol.Kind;
LocalSymbol localSymbol;
TypeSymbol typeSymbol;
bool isNullableUnknown;
ParameterSymbol parameterSymbol;
SynthesizedPrimaryConstructor synthesizedPrimaryConstructor;
bool flag3;
int num;
ConstantValue constantValueOpt;
bool flag;
switch ((int)kind)
{
case 8:
localSymbol = (LocalSymbol)symbol;
if (ReportSimpleProgramLocalReferencedOutsideOfTopLevelStatement(node, localSymbol, diagnostics))
{
typeSymbol = new ExtendedErrorTypeSymbol(Compilation, "var", 0, null, unreported: false, variableUsedBeforeDeclaration: true);
isNullableUnknown = true;
}
else if (isUsedBeforeDeclaration(node, localSymbol))
{
FieldSymbol fieldSymbol = null;
LookupResult instance = LookupResult.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupMembersInType(instance, ContainingType, localSymbol.Name, 0, null, LookupOptions.Default, this, diagnose: false, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
fieldSymbol = instance.SingleSymbolOrDefault as FieldSymbol;
instance.Free();
if ((object)fieldSymbol != null)
{
Error(diagnostics, ErrorCode.ERR_VariableUsedBeforeDeclarationAndHidesField, (CSharpSyntaxNode)node, new object[2] { node, fieldSymbol });
}
else
{
Error(diagnostics, ErrorCode.ERR_VariableUsedBeforeDeclaration, (CSharpSyntaxNode)node, new object[1] { node });
}
typeSymbol = new ExtendedErrorTypeSymbol(Compilation, "var", 0, null, unreported: false, variableUsedBeforeDeclaration: true);
isNullableUnknown = true;
}
else
{
SourceLocalSymbol obj = localSymbol as SourceLocalSymbol;
if ((object)obj != null && obj.IsVar)
{
SyntaxNode forbiddenZone = localSymbol.ForbiddenZone;
if (forbiddenZone != null && forbiddenZone.Contains((SyntaxNode)(object)node))
{
diagnostics.Add(localSymbol.ForbiddenDiagnostic, ((SyntaxNode)node).Location, node);
typeSymbol = new ExtendedErrorTypeSymbol(Compilation, "var", 0, null, unreported: false, variableUsedBeforeDeclaration: true);
isNullableUnknown = true;
goto IL_021a;
}
}
typeSymbol = localSymbol.Type;
isNullableUnknown = false;
if (IsBadLocalOrParameterCapture(localSymbol, typeSymbol, localSymbol.RefKind))
{
isError = true;
if ((int)localSymbol.RefKind == 0 && typeSymbol.IsRestrictedType(ignoreSpanLikeTypes: true))
{
Error(diagnostics, ErrorCode.ERR_SpecialByRefInLambda, (CSharpSyntaxNode)node, new object[1] { typeSymbol });
}
else
{
Error(diagnostics, ErrorCode.ERR_AnonDelegateCantUseLocal, (CSharpSyntaxNode)node, new object[1] { localSymbol });
}
}
}
goto IL_021a;
case 13:
parameterSymbol = (ParameterSymbol)symbol;
synthesizedPrimaryConstructor = parameterSymbol.ContainingSymbol as SynthesizedPrimaryConstructor;
if ((object)synthesizedPrimaryConstructor != null && (!IsInDeclaringTypeInstanceMember(synthesizedPrimaryConstructor) || (ContainingMember() is MethodSymbol methodSymbol2 && (int)methodSymbol2.MethodKind == 1 && (object)methodSymbol2 != synthesizedPrimaryConstructor)) && !IsInsideNameof)
{
Error(diagnostics, ErrorCode.ERR_InvalidPrimaryConstructorParameterReference, (CSharpSyntaxNode)node, new object[1] { parameterSymbol });
}
else if (IsBadLocalOrParameterCapture(parameterSymbol, parameterSymbol.Type, parameterSymbol.RefKind))
{
isError = true;
if ((int)parameterSymbol.RefKind != 0)
{
Error(diagnostics, ErrorCode.ERR_AnonDelegateCantUse, (CSharpSyntaxNode)node, new object[1] { parameterSymbol.Name });
}
else if (parameterSymbol.Type.IsRestrictedType(ignoreSpanLikeTypes: true))
{
Error(diagnostics, ErrorCode.ERR_SpecialByRefInLambda, (CSharpSyntaxNode)node, new object[1] { parameterSymbol.Type });
}
else
{
Error(diagnostics, ErrorCode.ERR_AnonDelegateCantUseRefLike, (CSharpSyntaxNode)node, new object[1] { parameterSymbol.Name });
}
}
else if ((object)synthesizedPrimaryConstructor != null)
{
flag3 = ContainingMember() is MethodSymbol methodSymbol3 && (object)synthesizedPrimaryConstructor != methodSymbol3;
if (!flag3 || ((int)parameterSymbol.RefKind == 0 && !parameterSymbol.Type.IsRestrictedType()) || IsInsideNameof)
{
if ((object)synthesizedPrimaryConstructor != null)
{
ParameterSymbol thisParameter = synthesizedPrimaryConstructor.ThisParameter;
if ((object)thisParameter != null)
{
num = (((int)thisParameter.RefKind != 0) ? 1 : 0);
goto IL_0440;
}
}
num = 0;
goto IL_0440;
}
if ((int)parameterSymbol.RefKind != 0)
{
Error(diagnostics, ErrorCode.ERR_UnsupportedPrimaryConstructorParameterCapturingRef, (CSharpSyntaxNode)node, new object[1] { parameterSymbol.Name });
}
else if (parameterSymbol.Type.IsRestrictedType(ignoreSpanLikeTypes: true))
{
Error(diagnostics, ErrorCode.ERR_UnsupportedPrimaryConstructorParameterCapturingRefAny, (CSharpSyntaxNode)node, new object[1] { parameterSymbol.Type });
}
else
{
Error(diagnostics, ErrorCode.ERR_UnsupportedPrimaryConstructorParameterCapturingRefLike, (CSharpSyntaxNode)node, new object[1] { parameterSymbol.Name });
}
}
goto IL_04ac;
case 4:
case 11:
case 17:
return new BoundTypeExpression((SyntaxNode)(object)node, null, (TypeSymbol)symbol, isError);
case 15:
{
BoundExpression receiver3 = SynthesizeReceiver((SyntaxNode)(object)node, symbol, diagnostics);
return BindPropertyAccess((SyntaxNode)(object)node, receiver3, (PropertySymbol)symbol, diagnostics, resultKind, isError);
}
case 5:
{
BoundExpression receiver2 = SynthesizeReceiver((SyntaxNode)(object)node, symbol, diagnostics);
return BindEventAccess((SyntaxNode)(object)node, receiver2, (EventSymbol)symbol, diagnostics, resultKind, isError);
}
case 6:
{
BoundExpression receiver = SynthesizeReceiver((SyntaxNode)(object)node, symbol, diagnostics);
return BindFieldAccess((SyntaxNode)(object)node, receiver, (FieldSymbol)symbol, diagnostics, resultKind, indexed, isError);
}
case 12:
return new BoundNamespaceExpression((SyntaxNode)(object)node, (NamespaceSymbol)symbol, isError);
case 0:
{
AliasSymbol aliasSymbol = (AliasSymbol)symbol;
NamespaceOrTypeSymbol target = aliasSymbol.Target;
if (!(target is TypeSymbol type))
{
if (target is NamespaceSymbol namespaceSymbol)
{
return new BoundNamespaceExpression((SyntaxNode)(object)node, namespaceSymbol, aliasSymbol, isError);
}
throw ExceptionUtilities.UnexpectedValue((object)aliasSymbol.Target.Kind);
}
return new BoundTypeExpression((SyntaxNode)(object)node, aliasSymbol, type, isError);
}
case 16:
return BindRangeVariable(node, (RangeVariableSymbol)symbol, diagnostics);
default:
{
throw ExceptionUtilities.UnexpectedValue((object)symbol.Kind);
}
IL_021a:
constantValueOpt = ((localSymbol.IsConst && !IsInsideNameof && !typeSymbol.IsErrorType()) ? localSymbol.GetConstantValue((SyntaxNode)(object)node, LocalInProgress, diagnostics) : null);
return new BoundLocal((SyntaxNode)(object)node, localSymbol, BoundLocalDeclarationKind.None, constantValueOpt, isNullableUnknown, typeSymbol, isError);
IL_04ac:
return new BoundParameter((SyntaxNode)(object)node, parameterSymbol, isError);
IL_0440:
flag = (byte)num != 0;
if (flag)
{
bool flag2 = ((ContainingMemberOrLambda is MethodSymbol { MethodKind: var methodKind } && ((int)methodKind == 0 || (int)methodKind == 17)) ? true : false);
flag = flag2;
}
if (flag && !IsInsideNameof)
{
if (flag3)
{
Error(diagnostics, ErrorCode.ERR_AnonDelegateCantUseStructPrimaryConstructorParameterInMember, (CSharpSyntaxNode)node);
}
else if (synthesizedPrimaryConstructor.GetCapturedParameters().ContainsKey(parameterSymbol))
{
Error(diagnostics, ErrorCode.ERR_AnonDelegateCantUseStructPrimaryConstructorParameterCaptured, (CSharpSyntaxNode)node);
}
}
goto IL_04ac;
}
static bool isUsedBeforeDeclaration(SimpleNameSyntax simpleNameSyntax, LocalSymbol localSymbol2)
{
if (!localSymbol2.HasSourceLocation)
{
return false;
}
SyntaxNode declaratorSyntax = localSymbol2.GetDeclaratorSyntax();
if (((SyntaxNode)simpleNameSyntax).SpanStart >= declaratorSyntax.SpanStart)
{
return false;
}
return simpleNameSyntax.SyntaxTree == declaratorSyntax.SyntaxTree;
}
}
private bool IsInDeclaringTypeInstanceMember(SynthesizedPrimaryConstructor primaryCtor)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Invalid comparison between Unknown and I4
if (!InParameterDefaultValue && !InAttributeArgument)
{
Symbol symbol = ContainingMember();
if ((object)symbol != null && (int)symbol.Kind != 11 && !symbol.IsStatic)
{
return (object)symbol.ContainingSymbol == primaryCtor.ContainingSymbol;
}
}
return false;
}
private bool ReportSimpleProgramLocalReferencedOutsideOfTopLevelStatement(SimpleNameSyntax node, Symbol symbol, BindingDiagnosticBag diagnostics)
{
if (symbol.ContainingSymbol is SynthesizedSimpleProgramEntryPointSymbol && !(ContainingMember() is SynthesizedSimpleProgramEntryPointSymbol))
{
Error(diagnostics, ErrorCode.ERR_SimpleProgramLocalIsReferencedOutsideOfTopLevelStatement, (CSharpSyntaxNode)node, new object[1] { node });
return true;
}
return false;
}
protected virtual BoundExpression BindRangeVariable(SimpleNameSyntax node, RangeVariableSymbol qv, BindingDiagnosticBag diagnostics)
{
return Next.BindRangeVariable(node, qv, diagnostics);
}
private BoundExpression SynthesizeReceiver(SyntaxNode node, Symbol member, BindingDiagnosticBag diagnostics)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Invalid comparison between Unknown and I4
if (!member.RequiresInstanceReceiver())
{
return null;
}
NamedTypeSymbol containingType = ContainingType;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
NamedTypeSymbol containingType2 = member.ContainingType;
if (containingType.IsEqualToOrDerivedFrom(containingType2, (TypeCompareKind)0, ref useSiteInfo) || (containingType.IsInterface && (containingType2.IsObjectType() || containingType.AllInterfacesNoUseSiteDiagnostics.Contains(containingType2))))
{
bool flag = false;
if (!IsInsideNameof || (EnclosingNameofArgument != node && !node.IsFeatureEnabled(MessageID.IDS_FeatureInstanceMemberInNameof)))
{
DiagnosticInfo val = null;
if (InFieldInitializer && !containingType.IsScriptClass)
{
val = (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_FieldInitRefNonstatic, member);
}
else if (InConstructorInitializer || InAttributeArgument)
{
val = (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_ObjectRequired, member);
}
else
{
Symbol symbol = ContainingMember();
if (symbol.IsStatic || ((int)symbol.Kind == 11 && !containingType.IsScriptClass))
{
val = (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_ObjectRequired, member);
}
}
if (val == null)
{
val = GetDiagnosticIfRefOrOutThisParameterCaptured();
}
flag = val != null;
if (flag)
{
if (IsInsideNameof)
{
CheckFeatureAvailability(node, MessageID.IDS_FeatureInstanceMemberInNameof, diagnostics);
}
else
{
Error(diagnostics, val, node);
}
}
}
return ThisReference(node, containingType, flag, wasCompilerGenerated: true);
}
return TryBindInteractiveReceiver(node, containingType2);
}
internal Symbol ContainingMember()
{
return ContainingMemberOrLambda.ContainingNonLambdaMember();
}
private BoundExpression TryBindInteractiveReceiver(SyntaxNode syntax, NamedTypeSymbol memberDeclaringType)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
if ((int)ContainingType.TypeKind == 12 && isInstanceContext())
{
if ((int)memberDeclaringType.TypeKind == 12)
{
return new BoundPreviousSubmissionReference(syntax, memberDeclaringType)
{
WasCompilerGenerated = true
};
}
TypeSymbol hostObjectTypeSymbol = Compilation.GetHostObjectTypeSymbol();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
if ((object)hostObjectTypeSymbol != null && hostObjectTypeSymbol.IsEqualToOrDerivedFrom(memberDeclaringType, (TypeCompareKind)0, ref useSiteInfo))
{
return new BoundHostObjectMemberReference(syntax, hostObjectTypeSymbol)
{
WasCompilerGenerated = true
};
}
}
return null;
bool isInstanceContext()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Invalid comparison between Unknown and I4
Symbol symbol = ContainingMemberOrLambda;
do
{
if (symbol.IsStatic)
{
return false;
}
if ((int)symbol.Kind == 11)
{
break;
}
symbol = symbol.ContainingSymbol;
}
while ((object)symbol != null);
return true;
}
}
public BoundExpression BindNamespaceOrTypeOrExpression(ExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
if (node.Kind() == SyntaxKind.PredefinedType)
{
return BindNamespaceOrType(node, diagnostics);
}
if (SyntaxFacts.IsName(node.Kind()))
{
if (SyntaxFacts.IsNamespaceAliasQualifier(node))
{
return BindNamespaceAlias((IdentifierNameSyntax)node, diagnostics);
}
if (SyntaxFacts.IsInNamespaceOrTypeContext(node))
{
return BindNamespaceOrType(node, diagnostics);
}
}
else if (SyntaxFacts.IsTypeSyntax(node.Kind()))
{
return BindNamespaceOrType(node, diagnostics);
}
return BindExpression(node, diagnostics, SyntaxFacts.IsInvoked(node), SyntaxFacts.IsIndexed(node));
}
public BoundExpression BindLabel(ExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
if (!(node is IdentifierNameSyntax identifierNameSyntax))
{
return BadExpression((SyntaxNode)(object)node, LookupResultKind.NotLabel);
}
LookupResult instance = LookupResult.GetInstance();
SyntaxToken identifier = identifierNameSyntax.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupSymbolsWithFallback(instance, valueText, 0, ref useSiteInfo, null, LookupOptions.LabelsOnly);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
if (!instance.IsMultiViable)
{
Error(diagnostics, ErrorCode.ERR_LabelNotFound, (CSharpSyntaxNode)node, new object[1] { valueText });
instance.Free();
return BadExpression((SyntaxNode)(object)node, instance.Kind);
}
LabelSymbol label = (LabelSymbol)instance.Symbols.First();
instance.Free();
return new BoundLabel((SyntaxNode)(object)node, label, null);
}
public BoundExpression BindNamespaceOrType(ExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
return CreateBoundNamespaceOrTypeExpression(node, BindNamespaceOrTypeOrAliasSymbol(node, diagnostics, null, suppressUseSiteDiagnostics: false).Symbol);
}
public BoundExpression BindNamespaceAlias(IdentifierNameSyntax node, BindingDiagnosticBag diagnostics)
{
Symbol symbol = BindNamespaceAliasSymbol(node, diagnostics);
return CreateBoundNamespaceOrTypeExpression(node, symbol);
}
private static BoundExpression CreateBoundNamespaceOrTypeExpression(ExpressionSyntax node, Symbol symbol)
{
AliasSymbol aliasSymbol = symbol as AliasSymbol;
if ((object)aliasSymbol != null)
{
symbol = aliasSymbol.Target;
}
if (symbol is TypeSymbol type)
{
return new BoundTypeExpression((SyntaxNode)(object)node, aliasSymbol, type);
}
if (symbol is NamespaceSymbol namespaceSymbol)
{
return new BoundNamespaceExpression((SyntaxNode)(object)node, namespaceSymbol, aliasSymbol);
}
throw ExceptionUtilities.UnexpectedValue((object)symbol);
}
private BoundThisReference BindThis(ThisExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0021: 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)
bool hasErrors = true;
if (!HasThis(isExplicit: true, out var inStaticContext))
{
Error(diagnostics, inStaticContext ? ErrorCode.ERR_ThisInStaticMeth : ErrorCode.ERR_ThisInBadContext, (CSharpSyntaxNode)node);
}
else
{
hasErrors = IsRefOrOutThisParameterCaptured(SyntaxNodeOrToken.op_Implicit(node.Token), diagnostics);
}
return ThisReference((SyntaxNode)(object)node, ContainingType, hasErrors);
}
private BoundThisReference ThisReference(SyntaxNode node, NamedTypeSymbol thisTypeOpt, bool hasErrors = false, bool wasCompilerGenerated = false)
{
return new BoundThisReference(node, thisTypeOpt ?? CreateErrorType(), hasErrors)
{
WasCompilerGenerated = wasCompilerGenerated
};
}
private bool IsRefOrOutThisParameterCaptured(SyntaxNodeOrToken thisOrBaseToken, BindingDiagnosticBag diagnostics)
{
DiagnosticInfo diagnosticIfRefOrOutThisParameterCaptured = GetDiagnosticIfRefOrOutThisParameterCaptured();
if (diagnosticIfRefOrOutThisParameterCaptured != null)
{
Location location = ((SyntaxNodeOrToken)(ref thisOrBaseToken)).GetLocation();
Error(diagnostics, diagnosticIfRefOrOutThisParameterCaptured, location);
return true;
}
return false;
}
private DiagnosticInfo? GetDiagnosticIfRefOrOutThisParameterCaptured()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
ParameterSymbol parameterSymbol = ContainingMemberOrLambda.EnclosingThisSymbol();
if ((object)parameterSymbol != null && parameterSymbol.ContainingSymbol != ContainingMemberOrLambda && (int)parameterSymbol.RefKind != 0)
{
return (DiagnosticInfo?)(object)new CSDiagnosticInfo(ErrorCode.ERR_ThisStructNotInAnonMeth);
}
return null;
}
private BoundBaseReference BindBase(BaseExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
bool hasErrors = false;
TypeSymbol typeSymbol = (((object)ContainingType == null) ? null : ContainingType.BaseTypeNoUseSiteDiagnostics);
if (!HasThis(isExplicit: true, out var inStaticContext))
{
Error(diagnostics, inStaticContext ? ErrorCode.ERR_BaseInStaticMeth : ErrorCode.ERR_BaseInBadContext, node.Token);
hasErrors = true;
}
else if ((object)typeSymbol == null)
{
Error(diagnostics, ErrorCode.ERR_NoBaseClass, (CSharpSyntaxNode)node);
hasErrors = true;
}
else if ((object)ContainingType == null || node.Parent == null || (node.Parent.Kind() != SyntaxKind.SimpleMemberAccessExpression && node.Parent.Kind() != SyntaxKind.ElementAccessExpression))
{
Error(diagnostics, ErrorCode.ERR_BaseIllegal, node.Token);
hasErrors = true;
}
else if (IsRefOrOutThisParameterCaptured(SyntaxNodeOrToken.op_Implicit(node.Token), diagnostics))
{
hasErrors = true;
}
return new BoundBaseReference((SyntaxNode)(object)node, typeSymbol, hasErrors);
}
private BoundExpression BindCast(CastExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
BoundExpression boundExpression = BindValue(node.Expression, diagnostics, BindValueKind.RValue);
TypeWithAnnotations targetTypeWithAnnotations = BindType(node.Type, diagnostics);
TypeSymbol type = targetTypeWithAnnotations.Type;
if (type.IsNullableType() && !boundExpression.HasAnyErrors && (object)boundExpression.Type != null && !boundExpression.Type.IsNullableType() && !TypeSymbol.Equals(type.GetNullableUnderlyingType(), boundExpression.Type, (TypeCompareKind)0))
{
return BindExplicitNullableCastFromNonNullable(node, boundExpression, targetTypeWithAnnotations, diagnostics);
}
return BindCastCore(node, boundExpression, targetTypeWithAnnotations, boundExpression.WasCompilerGenerated, diagnostics);
}
private BoundExpression BindFromEndIndexExpression(PrefixUnaryExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureIndexOperator, diagnostics);
GetSpecialType((SpecialType)7, diagnostics, (SyntaxNode)(object)node);
BoundExpression boundExpression = BindValue(node.Operand, diagnostics, BindValueKind.RValue);
TypeSymbol typeSymbol = GetSpecialType((SpecialType)13, diagnostics, (SyntaxNode)(object)node);
TypeSymbol typeSymbol2 = GetWellKnownType((WellKnownType)284, diagnostics, (SyntaxNode)(object)node);
if ((object)boundExpression.Type != null && boundExpression.Type.IsNullableType())
{
GetSpecialTypeMember((SpecialMember)117, diagnostics, (SyntaxNode)(object)node);
NamedTypeSymbol specialType = GetSpecialType((SpecialType)32, diagnostics, (SyntaxNode)(object)node);
if (!typeSymbol2.IsNonNullableValueType())
{
Error(diagnostics, ErrorCode.ERR_ValConstraintNotSatisfied, (CSharpSyntaxNode)node, new object[3]
{
specialType,
specialType.TypeParameters.Single(),
typeSymbol2
});
}
typeSymbol = specialType.Construct(typeSymbol);
typeSymbol2 = specialType.Construct(typeSymbol2);
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyImplicitConversionFromExpression(boundExpression, typeSymbol, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
if (!conversion.IsValid)
{
GenerateImplicitConversionError(diagnostics, (SyntaxNode)(object)node, conversion, boundExpression, typeSymbol);
}
BoundExpression operand = CreateConversion(boundExpression, conversion, typeSymbol, diagnostics);
MethodSymbol methodOpt = GetWellKnownTypeMember((WellKnownMember)417, diagnostics, null, (SyntaxNode)(object)node) as MethodSymbol;
return new BoundFromEndIndexExpression((SyntaxNode)(object)node, operand, methodOpt, typeSymbol2);
}
private BoundExpression BindRangeExpression(RangeExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureRangeOperator, diagnostics);
TypeSymbol typeSymbol = GetWellKnownType((WellKnownType)285, diagnostics, (SyntaxNode)(object)node);
MethodSymbol methodSymbol = null;
if (!typeSymbol.IsErrorType())
{
WellKnownMember? val = null;
if (node.LeftOperand == null && node.RightOperand == null)
{
val = (WellKnownMember)422;
}
else if (node.LeftOperand == null)
{
val = (WellKnownMember)421;
}
else if (node.RightOperand == null)
{
val = (WellKnownMember)420;
}
if (val.HasValue)
{
methodSymbol = (MethodSymbol)GetWellKnownTypeMember(val.GetValueOrDefault(), diagnostics, null, (SyntaxNode)(object)node, isOptional: true);
}
if ((object)methodSymbol == null)
{
methodSymbol = (MethodSymbol)GetWellKnownTypeMember((WellKnownMember)419, diagnostics, null, (SyntaxNode)(object)node);
}
}
BoundExpression boundExpression = BindRangeExpressionOperand(node.LeftOperand, diagnostics);
BoundExpression boundExpression2 = BindRangeExpressionOperand(node.RightOperand, diagnostics);
if ((boundExpression != null && boundExpression.Type.IsNullableType()) || (boundExpression2 != null && boundExpression2.Type.IsNullableType()))
{
GetSpecialType((SpecialType)7, diagnostics, (SyntaxNode)(object)node);
GetSpecialTypeMember((SpecialMember)117, diagnostics, (SyntaxNode)(object)node);
NamedTypeSymbol specialType = GetSpecialType((SpecialType)32, diagnostics, (SyntaxNode)(object)node);
if (!typeSymbol.IsNonNullableValueType())
{
Error(diagnostics, ErrorCode.ERR_ValConstraintNotSatisfied, (CSharpSyntaxNode)node, new object[3]
{
specialType,
specialType.TypeParameters.Single(),
typeSymbol
});
}
typeSymbol = specialType.Construct(typeSymbol);
}
return new BoundRangeExpression((SyntaxNode)(object)node, boundExpression, boundExpression2, methodSymbol, typeSymbol);
}
private BoundExpression BindRangeExpressionOperand(ExpressionSyntax operand, BindingDiagnosticBag diagnostics)
{
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
if (operand == null)
{
return null;
}
BoundExpression boundExpression = BindValue(operand, diagnostics, BindValueKind.RValue);
TypeSymbol typeSymbol = GetWellKnownType((WellKnownType)284, diagnostics, (SyntaxNode)(object)operand);
TypeSymbol? type = boundExpression.Type;
if ((object)type != null && type.IsNullableType())
{
GetSpecialTypeMember((SpecialMember)117, diagnostics, (SyntaxNode)(object)operand);
NamedTypeSymbol specialType = GetSpecialType((SpecialType)32, diagnostics, (SyntaxNode)(object)operand);
if (!typeSymbol.IsNonNullableValueType())
{
Error(diagnostics, ErrorCode.ERR_ValConstraintNotSatisfied, (CSharpSyntaxNode)operand, new object[3]
{
specialType,
specialType.TypeParameters.Single(),
typeSymbol
});
}
typeSymbol = specialType.Construct(typeSymbol);
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyImplicitConversionFromExpression(boundExpression, typeSymbol, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)operand, useSiteInfo);
if (!conversion.IsValid)
{
GenerateImplicitConversionError(diagnostics, (SyntaxNode)(object)operand, conversion, boundExpression, typeSymbol);
}
return CreateConversion(boundExpression, conversion, typeSymbol, diagnostics);
}
private BoundExpression BindCastCore(ExpressionSyntax node, BoundExpression operand, TypeWithAnnotations targetTypeWithAnnotations, bool wasCompilerGenerated, BindingDiagnosticBag diagnostics)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
TypeSymbol type = targetTypeWithAnnotations.Type;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyConversionFromExpression(operand, type, CheckOverflowAtRuntime, ref useSiteInfo, forCast: true);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
ConversionGroup conversionGroupOpt = new ConversionGroup(conversion, targetTypeWithAnnotations);
bool flag = operand.HasAnyErrors || type.IsErrorType();
bool flag2 = !conversion.IsValid || type.IsStatic;
if (flag2 && !flag)
{
GenerateExplicitConversionErrors(diagnostics, (SyntaxNode)(object)node, conversion, operand, type);
}
return CreateConversion((SyntaxNode)(object)node, operand, conversion, isCast: true, conversionGroupOpt, wasCompilerGenerated, type, diagnostics, flag2 || flag);
}
private void GenerateExplicitConversionErrors(BindingDiagnosticBag diagnostics, SyntaxNode syntax, Conversion conversion, BoundExpression operand, TypeSymbol targetType)
{
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Invalid comparison between Unknown and I4
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Invalid comparison between Unknown and I4
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Invalid comparison between Unknown and I4
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
if (operand.Kind == BoundKind.UnboundLambda)
{
GenerateAnonymousFunctionConversionError(diagnostics, operand.Syntax, (UnboundLambda)operand, targetType);
}
else
{
if (operand.HasAnyErrors || targetType.IsErrorType())
{
return;
}
if (targetType.IsStatic)
{
diagnostics.Add(ErrorCode.ERR_ConvertToStaticClass, syntax.Location, targetType);
return;
}
if (!targetType.IsReferenceType && !targetType.IsNullableType() && operand.IsLiteralNull())
{
diagnostics.Add(ErrorCode.ERR_ValueCantBeNull, syntax.Location, targetType);
return;
}
if (conversion.ResultKind == LookupResultKind.OverloadResolutionFailure)
{
ImmutableArray<MethodSymbol> originalUserDefinedConversions = conversion.OriginalUserDefinedConversions;
if (originalUserDefinedConversions.Length > 1)
{
diagnostics.Add(ErrorCode.ERR_AmbigUDConv, syntax.Location, originalUserDefinedConversions[0], originalUserDefinedConversions[1], operand.Display, targetType);
}
else
{
SymbolDistinguisher symbolDistinguisher = new SymbolDistinguisher(Compilation, operand.Type, targetType);
diagnostics.Add(ErrorCode.ERR_NoExplicitConv, syntax.Location, symbolDistinguisher.First, symbolDistinguisher.Second);
}
return;
}
BoundKind kind = operand.Kind;
if (kind <= BoundKind.UnconvertedSwitchExpression)
{
if (kind == BoundKind.UnconvertedAddressOfOperator)
{
TypeKind typeKind = targetType.TypeKind;
ErrorCode errorCode = (((int)typeKind == 3) ? ErrorCode.ERR_CannotConvertAddressOfToDelegate : (((int)typeKind != 13) ? ErrorCode.ERR_AddressOfToNonFunctionPointer : ErrorCode.ERR_MethFuncPtrMismatch));
ErrorCode code = errorCode;
diagnostics.Add(code, syntax.Location, ((BoundUnconvertedAddressOfOperator)operand).Operand.Name, targetType);
return;
}
if (kind != BoundKind.UnconvertedConditionalOperator)
{
if (kind == BoundKind.UnconvertedSwitchExpression && (object)operand.Type == null)
{
goto IL_02ba;
}
}
else if ((object)operand.Type == null)
{
goto IL_02ba;
}
}
else
{
switch (kind)
{
case BoundKind.MethodGroup:
{
if ((int)targetType.TypeKind != 3 || !MethodGroupConversionDoesNotExistOrHasErrors((BoundMethodGroup)operand, (NamedTypeSymbol)targetType, syntax.Location, diagnostics, out var _))
{
diagnostics.Add(ErrorCode.ERR_NoExplicitConv, syntax.Location, MessageID.IDS_SK_METHOD.Localize(), targetType);
}
return;
}
case BoundKind.TupleLiteral:
{
BoundTupleLiteral boundTupleLiteral = (BoundTupleLiteral)operand;
ImmutableArray<TypeWithAnnotations> elementTypes = default(ImmutableArray<TypeWithAnnotations>);
if (targetType.TryGetElementTypesWithAnnotationsIfTupleType(out elementTypes) && elementTypes.Length == boundTupleLiteral.Arguments.Length)
{
GenerateExplicitConversionErrorsForTupleLiteralArguments(diagnostics, boundTupleLiteral.Arguments, elementTypes);
return;
}
if ((object)boundTupleLiteral.Type == null)
{
Error(diagnostics, ErrorCode.ERR_ConversionNotTupleCompatible, SyntaxNodeOrToken.op_Implicit(syntax), boundTupleLiteral.Arguments.Length, targetType);
return;
}
break;
}
case BoundKind.StackAllocArrayCreation:
{
BoundStackAllocArrayCreation boundStackAllocArrayCreation = (BoundStackAllocArrayCreation)operand;
Error(diagnostics, ErrorCode.ERR_StackAllocConversionNotPossible, SyntaxNodeOrToken.op_Implicit(syntax), boundStackAllocArrayCreation.ElementType, targetType);
return;
}
case BoundKind.UnconvertedCollectionExpression:
if ((object)operand.Type == null)
{
Error(diagnostics, ErrorCode.ERR_CollectionExpressionTargetTypeNotConstructible, SyntaxNodeOrToken.op_Implicit(syntax), targetType);
return;
}
break;
}
}
SymbolDistinguisher symbolDistinguisher2 = new SymbolDistinguisher(Compilation, operand.Type, targetType);
diagnostics.Add(ErrorCode.ERR_NoExplicitConv, syntax.Location, symbolDistinguisher2.First, symbolDistinguisher2.Second);
}
return;
IL_02ba:
GenerateImplicitConversionError(diagnostics, operand.Syntax, conversion, operand, targetType);
}
private void GenerateExplicitConversionErrorsForTupleLiteralArguments(BindingDiagnosticBag diagnostics, ImmutableArray<BoundExpression> tupleArguments, ImmutableArray<TypeWithAnnotations> targetElementTypesWithAnnotations)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
for (int i = 0; i < targetElementTypesWithAnnotations.Length; i++)
{
BoundExpression boundExpression = tupleArguments[i];
TypeSymbol type = targetElementTypesWithAnnotations[i].Type;
Conversion conversion = Conversions.ClassifyConversionFromExpression(boundExpression, type, CheckOverflowAtRuntime, ref useSiteInfo);
if (!conversion.IsValid)
{
GenerateExplicitConversionErrors(diagnostics, boundExpression.Syntax, conversion, boundExpression, type);
}
}
}
private BoundExpression BindExplicitNullableCastFromNonNullable(ExpressionSyntax node, BoundExpression operand, TypeWithAnnotations targetTypeWithAnnotations, BindingDiagnosticBag diagnostics)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
TypeWithAnnotations nullableUnderlyingTypeWithAnnotations = targetTypeWithAnnotations.Type.GetNullableUnderlyingTypeWithAnnotations();
if (!Conversions.ClassifyBuiltInConversion(operand.Type, nullableUnderlyingTypeWithAnnotations.Type, CheckOverflowAtRuntime, ref useSiteInfo).Exists)
{
return BindCastCore(node, operand, targetTypeWithAnnotations, operand.WasCompilerGenerated, diagnostics);
}
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(withDiagnostics: true, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
try
{
BoundExpression boundExpression = BindCastCore(node, operand, nullableUnderlyingTypeWithAnnotations, wasCompilerGenerated: false, instance);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddDependencies((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
if (boundExpression.ConstantValueOpt != (ConstantValue)null && !boundExpression.HasErrors && !((BindingDiagnosticBag)instance).HasAnyErrors())
{
boundExpression.WasCompilerGenerated = true;
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(((BindingDiagnosticBag)instance).DiagnosticBag);
return BindCastCore(node, boundExpression, targetTypeWithAnnotations, operand.WasCompilerGenerated, diagnostics);
}
BindingDiagnosticBag instance2 = BindingDiagnosticBag.GetInstance(diagnostics);
BoundExpression result = BindCastCore(node, operand, targetTypeWithAnnotations, operand.WasCompilerGenerated, instance2);
if (((BindingDiagnosticBag)instance2).AccumulatesDiagnostics && ((BindingDiagnosticBag)instance).HasAnyErrors() && !((BindingDiagnosticBag)instance2).HasAnyErrors())
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(((BindingDiagnosticBag)instance).DiagnosticBag);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance2, false);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).Free();
return result;
}
finally
{
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
}
}
private static NameSyntax GetNameSyntax(SyntaxNode syntax)
{
string nameString;
return GetNameSyntax(syntax, out nameString);
}
internal static NameSyntax GetNameSyntax(SyntaxNode syntax, out string nameString)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
nameString = string.Empty;
while (true)
{
switch (syntax.Kind())
{
case SyntaxKind.PredefinedType:
{
SyntaxToken keyword = ((PredefinedTypeSyntax)(object)syntax).Keyword;
nameString = ((SyntaxToken)(ref keyword)).ValueText;
return null;
}
case SyntaxKind.SimpleLambdaExpression:
nameString = MessageID.IDS_Lambda.Localize().ToString();
return null;
case SyntaxKind.ParenthesizedExpression:
syntax = (SyntaxNode)(object)((ParenthesizedExpressionSyntax)(object)syntax).Expression;
break;
case SyntaxKind.CastExpression:
syntax = (SyntaxNode)(object)((CastExpressionSyntax)(object)syntax).Expression;
break;
case SyntaxKind.SimpleMemberAccessExpression:
case SyntaxKind.PointerMemberAccessExpression:
return ((MemberAccessExpressionSyntax)(object)syntax).Name;
case SyntaxKind.MemberBindingExpression:
return ((MemberBindingExpressionSyntax)(object)syntax).Name;
default:
return syntax as NameSyntax;
}
}
}
private static string GetName(ExpressionSyntax syntax)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
string nameString;
NameSyntax nameSyntax = GetNameSyntax((SyntaxNode)(object)syntax, out nameString);
if (nameSyntax != null)
{
SyntaxToken identifier = nameSyntax.GetUnqualifiedName().Identifier;
return ((SyntaxToken)(ref identifier)).ValueText;
}
return nameString;
}
private void BindArgumentsAndNames(BaseArgumentListSyntax argumentListOpt, BindingDiagnosticBag diagnostics, AnalyzedArguments result, bool allowArglist = false, bool isDelegateCreation = false)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if (argumentListOpt != null)
{
bool hadError = false;
bool hadLangVersionError = false;
Enumerator<ArgumentSyntax> enumerator = argumentListOpt.Arguments.GetEnumerator();
while (enumerator.MoveNext())
{
ArgumentSyntax current = enumerator.Current;
BindArgumentAndName(result, diagnostics, ref hadError, ref hadLangVersionError, current, allowArglist, isDelegateCreation);
}
}
}
private bool RefMustBeObeyed(bool isDelegateCreation, ArgumentSyntax argumentSyntax)
{
if (Compilation.FeatureStrictEnabled || !isDelegateCreation)
{
return true;
}
switch (argumentSyntax.Expression.Kind())
{
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.InvocationExpression:
case SyntaxKind.AnonymousMethodExpression:
case SyntaxKind.SimpleLambdaExpression:
case SyntaxKind.ParenthesizedLambdaExpression:
case SyntaxKind.ObjectCreationExpression:
case SyntaxKind.ImplicitObjectCreationExpression:
case SyntaxKind.DeclarationExpression:
return true;
default:
return false;
}
}
private void BindArgumentAndName(AnalyzedArguments result, BindingDiagnosticBag diagnostics, ref bool hadError, ref bool hadLangVersionError, ArgumentSyntax argumentSyntax, bool allowArglist, bool isDelegateCreation)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Invalid comparison between Unknown and I4
RefKind refKind = argumentSyntax.RefOrOutKeyword.Kind().GetRefKind();
RefKind refKind2 = (RefKind)(((int)refKind == 0 || RefMustBeObeyed(isDelegateCreation, argumentSyntax)) ? ((int)refKind) : 0);
BoundExpression boundArgumentExpression = BindArgumentValue(diagnostics, argumentSyntax, allowArglist, refKind2);
BindArgumentAndName(result, diagnostics, ref hadLangVersionError, argumentSyntax, boundArgumentExpression, argumentSyntax.NameColon, refKind2);
if (!hadError && isDelegateCreation && (int)refKind != 0 && result.Arguments.Count == 1)
{
BoundExpression boundExpression = result.Argument(0);
BoundKind kind = boundExpression.Kind;
if (kind == BoundKind.PropertyAccess || kind == BoundKind.IndexerAccess)
{
BindValueKind valueKind = (((int)refKind == 3) ? BindValueKind.ReadonlyRef : BindValueKind.RefOrOut);
hadError = !CheckValueKind((SyntaxNode)(object)argumentSyntax, boundExpression, valueKind, checkingReceiver: false, diagnostics);
return;
}
}
if (argumentSyntax.RefOrOutKeyword.Kind() != SyntaxKind.None)
{
argumentSyntax.Expression.CheckDeconstructionCompatibleArgument(diagnostics);
}
}
private BoundExpression BindArgumentValue(BindingDiagnosticBag diagnostics, ArgumentSyntax argumentSyntax, bool allowArglist, RefKind refKind)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
if (argumentSyntax.RefKindKeyword.IsKind(SyntaxKind.InKeyword))
{
MessageID.IDS_FeatureReadOnlyReferences.CheckFeatureAvailability(diagnostics, argumentSyntax.RefKindKeyword);
}
if (argumentSyntax.Expression.Kind() == SyntaxKind.DeclarationExpression)
{
if (argumentSyntax.RefKindKeyword.IsKind(SyntaxKind.OutKeyword))
{
MessageID.IDS_FeatureOutVar.CheckFeatureAvailability(diagnostics, argumentSyntax.RefKindKeyword);
}
DeclarationExpressionSyntax declarationExpressionSyntax = (DeclarationExpressionSyntax)argumentSyntax.Expression;
if (declarationExpressionSyntax.IsOutDeclaration())
{
return BindOutDeclarationArgument(declarationExpressionSyntax, diagnostics);
}
}
return BindArgumentExpression(diagnostics, argumentSyntax.Expression, refKind, allowArglist);
}
private BoundExpression BindOutDeclarationArgument(DeclarationExpressionSyntax declarationExpression, BindingDiagnosticBag diagnostics)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
TypeSyntax type = declarationExpression.Type;
VariableDesignationSyntax designation = declarationExpression.Designation;
switch (designation.Kind())
{
case SyntaxKind.DiscardDesignation:
{
if (type is ScopedTypeSyntax scopedTypeSyntax)
{
SyntaxToken scopedKeyword = scopedTypeSyntax.ScopedKeyword;
diagnostics.Add(ErrorCode.ERR_ScopedDiscard, ((SyntaxToken)(ref scopedKeyword)).GetLocation());
type = scopedTypeSyntax.Type;
}
if (type is RefTypeSyntax refTypeSyntax)
{
diagnostics.Add(ErrorCode.ERR_OutVariableCannotBeByRef, ((SyntaxNode)refTypeSyntax).Location);
type = refTypeSyntax.Type;
}
bool isConst = false;
bool isVar;
AliasSymbol alias;
TypeWithAnnotations typeWithAnnotations = BindVariableTypeWithAnnotations(designation, diagnostics, type, ref isConst, out isVar, out alias);
TypeSymbol type2 = typeWithAnnotations.Type;
return new BoundDiscardExpression((SyntaxNode)(object)declarationExpression, typeWithAnnotations.NullableAnnotation, (object)type2 == null, type2);
}
case SyntaxKind.SingleVariableDesignation:
return BindOutVariableDeclarationArgument(declarationExpression, diagnostics);
default:
throw ExceptionUtilities.UnexpectedValue((object)designation.Kind());
}
}
private BoundExpression BindOutVariableDeclarationArgument(DeclarationExpressionSyntax declarationExpression, BindingDiagnosticBag diagnostics)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Invalid comparison between Unknown and I4
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Invalid comparison between Unknown and I4
SingleVariableDesignationSyntax singleVariableDesignationSyntax = (SingleVariableDesignationSyntax)declarationExpression.Designation;
TypeSyntax type = declarationExpression.Type;
SourceLocalSymbol sourceLocalSymbol = LookupLocal(singleVariableDesignationSyntax.Identifier);
bool isVar;
if ((object)sourceLocalSymbol != null)
{
if (type is ScopedTypeSyntax scopedTypeSyntax)
{
ModifierUtils.CheckScopedModifierAvailability(type, scopedTypeSyntax.ScopedKeyword, diagnostics);
type = scopedTypeSyntax.Type;
}
if (type is RefTypeSyntax refTypeSyntax)
{
diagnostics.Add(ErrorCode.ERR_OutVariableCannotBeByRef, ((SyntaxNode)refTypeSyntax).Location);
type = refTypeSyntax.Type;
}
if ((InConstructorInitializer || InFieldInitializer) && (int)ContainingMemberOrLambda.ContainingSymbol.Kind == 11)
{
CheckFeatureAvailability((SyntaxNode)(object)declarationExpression, MessageID.IDS_FeatureExpressionVariablesInQueriesAndInitializers, diagnostics);
}
bool isConst = false;
AliasSymbol alias;
TypeWithAnnotations typeWithAnnotations = BindVariableTypeWithAnnotations(declarationExpression, diagnostics, type, ref isConst, out isVar, out alias);
sourceLocalSymbol.ScopeBinder.ValidateDeclarationNameConflictsInScope(sourceLocalSymbol, diagnostics);
if (isVar)
{
return new OutVariablePendingInference((SyntaxNode)(object)declarationExpression, sourceLocalSymbol, null);
}
CheckRestrictedTypeInAsyncMethod(ContainingMemberOrLambda, typeWithAnnotations.Type, diagnostics, (SyntaxNode)(object)type);
if ((int)sourceLocalSymbol.Scope == 2 && !typeWithAnnotations.Type.IsErrorTypeOrRefLikeType())
{
diagnostics.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly, ((SyntaxNode)type).Location);
}
return new BoundLocal((SyntaxNode)(object)declarationExpression, sourceLocalSymbol, BoundLocalDeclarationKind.WithExplicitType, null, isNullableUnknown: false, typeWithAnnotations.Type);
}
GlobalExpressionVariable globalExpressionVariable = LookupDeclaredField(singleVariableDesignationSyntax);
if ((object)globalExpressionVariable == null)
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs", 3136);
}
BoundExpression boundExpression = SynthesizeReceiver((SyntaxNode)(object)singleVariableDesignationSyntax, globalExpressionVariable, diagnostics);
SyntaxToken val;
if (type is ScopedTypeSyntax scopedTypeSyntax2)
{
val = scopedTypeSyntax2.ScopedKeyword;
Location location = ((SyntaxToken)(ref val)).GetLocation();
object[] array = new object[1];
val = scopedTypeSyntax2.ScopedKeyword;
array[0] = ((SyntaxToken)(ref val)).ValueText;
diagnostics.Add(ErrorCode.ERR_UnexpectedToken, location, array);
type = scopedTypeSyntax2.Type;
}
if (type is RefTypeSyntax refTypeSyntax2)
{
val = refTypeSyntax2.RefKeyword;
Location location2 = ((SyntaxToken)(ref val)).GetLocation();
object[] array2 = new object[1];
val = refTypeSyntax2.RefKeyword;
array2[0] = ((SyntaxToken)(ref val)).ValueText;
diagnostics.Add(ErrorCode.ERR_UnexpectedToken, location2, array2);
type = refTypeSyntax2.Type;
}
if (type.IsVar)
{
BindTypeOrAliasOrVarKeyword(type, BindingDiagnosticBag.Discarded, out isVar);
if (isVar)
{
return new OutVariablePendingInference((SyntaxNode)(object)declarationExpression, globalExpressionVariable, boundExpression);
}
}
TypeSymbol type2 = globalExpressionVariable.GetFieldType(FieldsBeingBound).Type;
return new BoundFieldAccess((SyntaxNode)(object)declarationExpression, boundExpression, globalExpressionVariable, null, LookupResultKind.Viable, isDeclaration: true, type2);
}
internal static void CheckRestrictedTypeInAsyncMethod(Symbol containingSymbol, TypeSymbol type, BindingDiagnosticBag diagnostics, SyntaxNode syntax, bool forUsingExpression = false)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
if ((int)containingSymbol.Kind == 9 && ((MethodSymbol)containingSymbol).IsAsync && type.IsRestrictedType())
{
Error(diagnostics, forUsingExpression ? ErrorCode.ERR_BadSpecialByRefUsing : ErrorCode.ERR_BadSpecialByRefLocal, SyntaxNodeOrToken.op_Implicit(syntax), type);
}
}
internal GlobalExpressionVariable LookupDeclaredField(SingleVariableDesignationSyntax variableDesignator)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken identifier = variableDesignator.Identifier;
return LookupDeclaredField((SyntaxNode)(object)variableDesignator, ((SyntaxToken)(ref identifier)).ValueText);
}
internal GlobalExpressionVariable LookupDeclaredField(SyntaxNode node, string identifier)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Invalid comparison between Unknown and I4
ImmutableArray<Symbol>.Enumerator enumerator = (ContainingType?.GetMembers(identifier) ?? ImmutableArray<Symbol>.Empty).GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
GlobalExpressionVariable globalExpressionVariable;
if ((int)current.Kind == 6 && (globalExpressionVariable = current as GlobalExpressionVariable)?.SyntaxTree == node.SyntaxTree && (object)globalExpressionVariable.SyntaxNode == node)
{
return globalExpressionVariable;
}
}
return null;
}
private void BindArgumentAndName(AnalyzedArguments result, BindingDiagnosticBag diagnostics, ref bool hadLangVersionError, CSharpSyntaxNode argumentSyntax, BoundExpression boundArgumentExpression, NameColonSyntax nameColonSyntax, RefKind refKind)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
if (nameColonSyntax != null)
{
CheckFeatureAvailability((SyntaxNode)(object)nameColonSyntax, MessageID.IDS_FeatureNamedArgument, diagnostics);
}
bool flag = result.RefKinds.Any();
if ((int)refKind != 0 && !flag)
{
flag = true;
int count = result.Arguments.Count;
for (int i = 0; i < count; i++)
{
result.RefKinds.Add((RefKind)0);
}
}
if (flag)
{
result.RefKinds.Add(refKind);
}
bool flag2 = result.Names.Any();
if (nameColonSyntax != null)
{
if (!flag2)
{
flag2 = true;
int count2 = result.Arguments.Count;
for (int j = 0; j < count2; j++)
{
result.Names.Add(((string, Location)?)null);
}
}
result.AddName(nameColonSyntax.Name);
}
else if (flag2)
{
if (!hadLangVersionError && !Compilation.LanguageVersion.AllowNonTrailingNamedArguments())
{
Error(diagnostics, ErrorCode.ERR_NamedArgumentSpecificationBeforeFixedArgument, argumentSyntax, new CSharpRequiredLanguageVersion(MessageID.IDS_FeatureNonTrailingNamedArguments.RequiredVersion()));
hadLangVersionError = true;
}
result.Names.Add(((string, Location)?)null);
}
result.Arguments.Add(boundArgumentExpression);
}
private BoundExpression BindArgumentExpression(BindingDiagnosticBag diagnostics, ExpressionSyntax argumentExpression, RefKind refKind, bool allowArglist)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Invalid comparison between Unknown and I4
BindValueKind valueKind = (((int)refKind == 0) ? BindValueKind.RValue : (((int)refKind == 3) ? BindValueKind.ReadonlyRef : BindValueKind.RefOrOut));
if (allowArglist)
{
return BindValueAllowArgList(argumentExpression, diagnostics, valueKind);
}
return BindValue(argumentExpression, diagnostics, valueKind);
}
private void CheckAndCoerceArguments<TMember>(MemberResolutionResult<TMember> methodResult, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics, BoundExpression? receiver, bool invokedAsExtensionMethod) where TMember : Symbol
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Invalid comparison between Unknown and I4
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Invalid comparison between Unknown and I4
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Invalid comparison between Unknown and I4
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Invalid comparison between Unknown and I4
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Invalid comparison between Unknown and I4
MemberAnalysisResult result = methodResult.Result;
ArrayBuilder<BoundExpression> arguments = analyzedArguments.Arguments;
ImmutableArray<ParameterSymbol> parameters = methodResult.LeastOverriddenMember.GetParameters();
for (int i = 0; i < arguments.Count; i++)
{
Conversion conversion = result.ConversionForArg(i);
BoundExpression boundExpression = arguments[i];
if (!(boundExpression is BoundArgListOperator) && !boundExpression.HasAnyErrors)
{
RefKind val = analyzedArguments.RefKind(i);
if (!Compilation.IsFeatureEnabled(MessageID.IDS_FeatureRefReadonlyParameters))
{
bool flag = (((int)val == 0 || (int)val == 3) ? true : false);
if (flag && (int)GetCorrespondingParameter(ref result, parameters, i).RefKind == 4)
{
CheckFeatureAvailability(boundExpression.Syntax, MessageID.IDS_FeatureRefReadonlyParameters, diagnostics);
}
}
else
{
int num = (invokedAsExtensionMethod ? i : (i + 1));
if ((int)val == 1)
{
if ((int)GetCorrespondingParameter(ref result, parameters, i).RefKind == 3)
{
diagnostics.Add(ErrorCode.WRN_BadArgRef, boundExpression.Syntax, num);
}
}
else if ((int)val == 0 && (int)GetCorrespondingParameter(ref result, parameters, i).RefKind == 4)
{
if (!CheckValueKind(boundExpression.Syntax, boundExpression, BindValueKind.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
{
diagnostics.Add(ErrorCode.WRN_RefReadonlyNotVariable, boundExpression.Syntax, num);
}
else if (!invokedAsExtensionMethod || i != 0)
{
if (CheckValueKind(boundExpression.Syntax, boundExpression, BindValueKind.Assignable, checkingReceiver: false, BindingDiagnosticBag.Discarded))
{
diagnostics.Add(ErrorCode.WRN_ArgExpectedRefOrIn, boundExpression.Syntax, num);
}
else
{
diagnostics.Add(ErrorCode.WRN_ArgExpectedIn, boundExpression.Syntax, num);
}
}
}
}
}
if (conversion.IsInterpolatedStringHandler)
{
TypeWithAnnotations correspondingParameterTypeWithAnnotations = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, i);
reportUnsafeIfNeeded(methodResult, diagnostics, boundExpression, correspondingParameterTypeWithAnnotations);
arguments[i] = BindInterpolatedStringHandlerInMemberCall(boundExpression, arguments, parameters, ref result, i, receiver, diagnostics);
}
else if (!conversion.IsIdentity)
{
TypeWithAnnotations correspondingParameterTypeWithAnnotations2 = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, i);
reportUnsafeIfNeeded(methodResult, diagnostics, boundExpression, correspondingParameterTypeWithAnnotations2);
arguments[i] = CreateConversion(boundExpression.Syntax, boundExpression, conversion, isCast: false, null, correspondingParameterTypeWithAnnotations2.Type, diagnostics);
}
else if (boundExpression.Kind == BoundKind.OutVariablePendingInference)
{
TypeWithAnnotations correspondingParameterTypeWithAnnotations3 = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, i);
arguments[i] = ((OutVariablePendingInference)boundExpression).SetInferredTypeWithAnnotations(correspondingParameterTypeWithAnnotations3, diagnostics);
}
else if (boundExpression.Kind == BoundKind.OutDeconstructVarPendingInference)
{
TypeWithAnnotations correspondingParameterTypeWithAnnotations4 = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, i);
arguments[i] = ((OutDeconstructVarPendingInference)boundExpression).SetInferredTypeWithAnnotations(correspondingParameterTypeWithAnnotations4, success: true);
}
else if (boundExpression.Kind == BoundKind.DiscardExpression && !boundExpression.HasExpressionType())
{
TypeWithAnnotations correspondingParameterTypeWithAnnotations5 = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, i);
arguments[i] = ((BoundDiscardExpression)boundExpression).SetInferredTypeWithAnnotations(correspondingParameterTypeWithAnnotations5);
}
else if (boundExpression.NeedsToBeConverted())
{
if (boundExpression is BoundTupleLiteral)
{
TypeWithAnnotations correspondingParameterTypeWithAnnotations6 = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, i);
arguments[i] = CreateConversion(boundExpression.Syntax, boundExpression, conversion, isCast: false, null, correspondingParameterTypeWithAnnotations6.Type, diagnostics);
}
else
{
arguments[i] = BindToNaturalType(boundExpression, diagnostics);
}
}
}
void reportUnsafeIfNeeded(MemberResolutionResult<TMember> memberResolutionResult, BindingDiagnosticBag diagnostics2, BoundExpression argument, TypeWithAnnotations parameterTypeWithAnnotations)
{
if (!memberResolutionResult.Member.IsIndexer() && !argument.HasAnyErrors && parameterTypeWithAnnotations.Type.ContainsPointer())
{
ReportUnsafeIfNotAllowed(argument.Syntax, diagnostics2);
}
}
}
private static ParameterSymbol GetCorrespondingParameter(ref MemberAnalysisResult result, ImmutableArray<ParameterSymbol> parameters, int arg)
{
int index = result.ParameterFromArgument(arg);
return parameters[index];
}
private static TypeWithAnnotations GetCorrespondingParameterTypeWithAnnotations(ref MemberAnalysisResult result, ImmutableArray<ParameterSymbol> parameters, int arg)
{
int num = result.ParameterFromArgument(arg);
TypeWithAnnotations result2 = parameters[num].TypeWithAnnotations;
if (num == parameters.Length - 1 && result.Kind == MemberResolutionKind.ApplicableInExpandedForm)
{
result2 = ((ArrayTypeSymbol)result2.Type).ElementTypeWithAnnotations;
}
return result2;
}
private BoundExpression BindArrayCreationExpression(ArrayCreationExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
ArrayTypeSymbol type = (ArrayTypeSymbol)BindArrayType(node.Type, diagnostics, permitDimensions: true, null, disallowRestrictedTypes: true).Type;
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance();
ArrayRankSpecifierSyntax arrayRankSpecifierSyntax = node.Type.RankSpecifiers[0];
bool hasErrors = false;
Enumerator<ExpressionSyntax> enumerator = arrayRankSpecifierSyntax.Sizes.GetEnumerator();
while (enumerator.MoveNext())
{
ExpressionSyntax current = enumerator.Current;
BoundExpression boundExpression = BindArrayDimension(current, diagnostics, ref hasErrors);
if (boundExpression != null)
{
instance.Add(boundExpression);
}
else if (node.Initializer == null && current == arrayRankSpecifierSyntax.Sizes[0])
{
Error(diagnostics, ErrorCode.ERR_MissingArraySize, (CSharpSyntaxNode)arrayRankSpecifierSyntax);
hasErrors = true;
}
}
for (int i = 1; i < node.Type.RankSpecifiers.Count; i++)
{
enumerator = node.Type.RankSpecifiers[i].Sizes.GetEnumerator();
while (enumerator.MoveNext())
{
ExpressionSyntax current2 = enumerator.Current;
if (current2.Kind() != SyntaxKind.OmittedArraySizeExpression)
{
BoundExpression boundExpression2 = BindRValueWithoutTargetType(current2, diagnostics);
Error(diagnostics, ErrorCode.ERR_InvalidArray, (CSharpSyntaxNode)current2);
hasErrors = true;
instance.Add(boundExpression2);
}
}
}
ImmutableArray<BoundExpression> immutableArray = instance.ToImmutableAndFree();
if (node.Initializer != null)
{
InitializerExpressionSyntax? initializer = node.Initializer;
bool hasErrors2 = hasErrors;
return BindArrayCreationWithInitializer(diagnostics, node, initializer, type, immutableArray, default(ImmutableArray<BoundExpression>), hasErrors2);
}
return new BoundArrayCreation((SyntaxNode)(object)node, immutableArray, null, type, hasErrors);
}
private BoundExpression BindArrayDimension(ExpressionSyntax dimension, BindingDiagnosticBag diagnostics, ref bool hasErrors)
{
if (dimension.Kind() != SyntaxKind.OmittedArraySizeExpression)
{
BoundExpression boundExpression = BindValue(dimension, diagnostics, BindValueKind.RValue);
if (!boundExpression.HasAnyErrors)
{
boundExpression = ConvertToArrayIndex(boundExpression, diagnostics, allowIndexAndRange: false, out var _);
if (IsNegativeConstantForArraySize(boundExpression))
{
Error(diagnostics, ErrorCode.ERR_NegativeArraySize, (CSharpSyntaxNode)dimension);
hasErrors = true;
}
}
else
{
boundExpression = BindToTypeForErrorRecovery(boundExpression);
}
return boundExpression;
}
return null;
}
private BoundExpression BindImplicitArrayCreationExpression(ImplicitArrayCreationExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureImplicitArray.CheckFeatureAvailability(diagnostics, node.NewKeyword);
InitializerExpressionSyntax initializer = node.Initializer;
SyntaxTokenList commas = node.Commas;
int rank = ((SyntaxTokenList)(ref commas)).Count + 1;
ImmutableArray<BoundExpression> immutableArray = BindArrayInitializerExpressions(initializer, diagnostics, 1, rank);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
bool inferredFromFunctionType;
TypeSymbol typeSymbol = BestTypeInferrer.InferBestType(immutableArray, Conversions, ref useSiteInfo, out inferredFromFunctionType);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
if ((object)typeSymbol == null || typeSymbol.IsVoidType())
{
Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedArrayNoBestType, (CSharpSyntaxNode)node);
typeSymbol = CreateErrorType();
}
if (typeSymbol.IsRestrictedType())
{
Error(diagnostics, ErrorCode.ERR_ArrayElementCantBeRefAny, (CSharpSyntaxNode)node, new object[1] { typeSymbol });
}
ArrayTypeSymbol type = ArrayTypeSymbol.CreateCSharpArray(Compilation.Assembly, TypeWithAnnotations.Create(typeSymbol), rank);
return BindArrayCreationWithInitializer(diagnostics, node, initializer, type, ImmutableArray<BoundExpression>.Empty, immutableArray);
}
private BoundExpression BindImplicitStackAllocArrayCreationExpression(ImplicitStackAllocArrayCreationExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
InitializerExpressionSyntax initializer = node.Initializer;
ImmutableArray<BoundExpression> immutableArray = BindArrayInitializerExpressions(initializer, diagnostics, 1, 1);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
bool inferredFromFunctionType;
TypeSymbol typeSymbol = BestTypeInferrer.InferBestType(immutableArray, Conversions, ref useSiteInfo, out inferredFromFunctionType);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
if ((object)typeSymbol == null || typeSymbol.IsVoidType())
{
Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedArrayNoBestType, (CSharpSyntaxNode)node);
typeSymbol = CreateErrorType();
}
if (!typeSymbol.IsErrorType())
{
CheckManagedAddr(Compilation, typeSymbol, ((SyntaxNode)node).Location, diagnostics, errorForManaged: true);
}
bool hasErrors;
return BindStackAllocWithInitializer((SyntaxNode)(object)node, node.StackAllocKeyword, initializer, GetStackAllocType((SyntaxNode)(object)node, TypeWithAnnotations.Create(typeSymbol), diagnostics, out hasErrors), typeSymbol, null, diagnostics, hasErrors, immutableArray);
}
private ImmutableArray<BoundExpression> BindArrayInitializerExpressions(InitializerExpressionSyntax initializer, BindingDiagnosticBag diagnostics, int dimension, int rank)
{
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance();
BindArrayInitializerExpressions(initializer, instance, diagnostics, dimension, rank);
return instance.ToImmutableAndFree();
}
private void BindArrayInitializerExpressions(InitializerExpressionSyntax initializer, ArrayBuilder<BoundExpression> exprBuilder, BindingDiagnosticBag diagnostics, int dimension, int rank)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
Enumerator<ExpressionSyntax> enumerator;
if (dimension == rank)
{
enumerator = initializer.Expressions.GetEnumerator();
while (enumerator.MoveNext())
{
ExpressionSyntax current = enumerator.Current;
BoundExpression boundExpression = BindValue(current, diagnostics, BindValueKind.RValue);
exprBuilder.Add(boundExpression);
}
return;
}
enumerator = initializer.Expressions.GetEnumerator();
while (enumerator.MoveNext())
{
ExpressionSyntax current2 = enumerator.Current;
if (current2.Kind() == SyntaxKind.ArrayInitializerExpression)
{
BindArrayInitializerExpressions((InitializerExpressionSyntax)current2, exprBuilder, diagnostics, dimension + 1, rank);
continue;
}
BoundExpression boundExpression2 = BindValue(current2, diagnostics, BindValueKind.RValue);
if ((object)boundExpression2.Type == null || !boundExpression2.Type.IsErrorType())
{
if (!boundExpression2.HasAnyErrors)
{
Error(diagnostics, ErrorCode.ERR_ArrayInitializerExpected, (CSharpSyntaxNode)current2);
}
boundExpression2 = BadExpression((SyntaxNode)(object)current2, LookupResultKind.Empty, ImmutableArray.Create(boundExpression2.ExpressionSymbol), ImmutableArray.Create(boundExpression2));
}
exprBuilder.Add(boundExpression2);
}
}
private BoundArrayInitialization ConvertAndBindArrayInitialization(BindingDiagnosticBag diagnostics, InitializerExpressionSyntax node, ArrayTypeSymbol type, int?[] knownSizes, int dimension, ImmutableArray<BoundExpression> boundInitExpr, ref int boundInitExprIndex, bool isInferred)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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)
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance();
if (dimension == type.Rank)
{
TypeSymbol elementType = type.ElementType;
Enumerator<ExpressionSyntax> enumerator = node.Expressions.GetEnumerator();
while (enumerator.MoveNext())
{
_ = enumerator.Current;
BoundExpression expression = boundInitExpr[boundInitExprIndex];
boundInitExprIndex++;
BoundExpression boundExpression = GenerateConversionForAssignment(elementType, expression, diagnostics);
instance.Add(boundExpression);
}
}
else
{
Enumerator<ExpressionSyntax> enumerator = node.Expressions.GetEnumerator();
while (enumerator.MoveNext())
{
ExpressionSyntax current = enumerator.Current;
BoundExpression boundExpression2 = null;
if (current.Kind() == SyntaxKind.ArrayInitializerExpression)
{
boundExpression2 = ConvertAndBindArrayInitialization(diagnostics, (InitializerExpressionSyntax)current, type, knownSizes, dimension + 1, boundInitExpr, ref boundInitExprIndex, isInferred);
}
else
{
boundExpression2 = boundInitExpr[boundInitExprIndex];
boundInitExprIndex++;
}
instance.Add(boundExpression2);
}
}
bool hasErrors = false;
int? num = knownSizes[dimension - 1];
if (!num.HasValue)
{
knownSizes[dimension - 1] = instance.Count;
}
else if (num != instance.Count && num >= 0)
{
Error(diagnostics, ErrorCode.ERR_ArrayInitializerIncorrectLength, (CSharpSyntaxNode)node, new object[1] { num.Value });
hasErrors = true;
}
return new BoundArrayInitialization((SyntaxNode)(object)node, isInferred, instance.ToImmutableAndFree(), hasErrors);
}
private BoundArrayInitialization BindArrayInitializerList(BindingDiagnosticBag diagnostics, InitializerExpressionSyntax node, ArrayTypeSymbol type, int?[] knownSizes, int dimension, bool isInferred, ImmutableArray<BoundExpression> boundInitExprOpt = default(ImmutableArray<BoundExpression>))
{
if (boundInitExprOpt.IsDefault)
{
boundInitExprOpt = BindArrayInitializerExpressions(node, diagnostics, dimension, type.Rank);
}
int boundInitExprIndex = 0;
return ConvertAndBindArrayInitialization(diagnostics, node, type, knownSizes, dimension, boundInitExprOpt, ref boundInitExprIndex, isInferred);
}
private BoundArrayInitialization BindUnexpectedArrayInitializer(InitializerExpressionSyntax node, BindingDiagnosticBag diagnostics, ErrorCode errorCode, CSharpSyntaxNode errorNode = null)
{
BoundArrayInitialization boundArrayInitialization = BindArrayInitializerList(diagnostics, node, Compilation.CreateArrayTypeSymbol(GetSpecialType((SpecialType)1, diagnostics, (SyntaxNode)(object)node)), new int?[1], 1, isInferred: false);
if (!boundArrayInitialization.HasAnyErrors)
{
boundArrayInitialization = new BoundArrayInitialization((SyntaxNode)(object)node, isInferred: false, boundArrayInitialization.Initializers, hasErrors: true);
}
Error(diagnostics, errorCode, errorNode ?? node);
return boundArrayInitialization;
}
private BoundArrayCreation BindArrayCreationWithInitializer(BindingDiagnosticBag diagnostics, ExpressionSyntax creationSyntax, InitializerExpressionSyntax initSyntax, ArrayTypeSymbol type, ImmutableArray<BoundExpression> sizes, ImmutableArray<BoundExpression> boundInitExprOpt = default(ImmutableArray<BoundExpression>), bool hasErrors = false)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
int rank = type.Rank;
int length = sizes.Length;
int?[] array = new int?[Math.Max(rank, length)];
for (int i = 0; i < length; i++)
{
BoundExpression boundExpression = sizes[i];
array[i] = GetIntegerConstantForArraySize(boundExpression);
if (!boundExpression.HasAnyErrors && !array[i].HasValue)
{
Error(diagnostics, ErrorCode.ERR_ConstantExpected, SyntaxNodeOrToken.op_Implicit(boundExpression.Syntax));
hasErrors = true;
}
}
bool isInferred = ((SyntaxNode?)(object)creationSyntax).IsKind(SyntaxKind.ImplicitArrayCreationExpression);
BoundArrayInitialization boundArrayInitialization = BindArrayInitializerList(diagnostics, initSyntax, type, array, 1, isInferred, boundInitExprOpt);
hasErrors = hasErrors || boundArrayInitialization.HasAnyErrors;
bool flag = creationSyntax != null;
CSharpSyntaxNode cSharpSyntaxNode = creationSyntax ?? initSyntax;
if (length == 0)
{
BoundExpression[] array2 = new BoundExpression[rank];
for (int j = 0; j < rank; j++)
{
array2[j] = new BoundLiteral((SyntaxNode)(object)cSharpSyntaxNode, ConstantValue.Create(array[j].GetValueOrDefault()), GetSpecialType((SpecialType)13, diagnostics, (SyntaxNode)(object)cSharpSyntaxNode))
{
WasCompilerGenerated = true
};
}
sizes = ImmutableArrayExtensions.AsImmutableOrNull<BoundExpression>(array2);
}
else if (!hasErrors && rank != length)
{
Error(diagnostics, ErrorCode.ERR_BadIndexCount, cSharpSyntaxNode, type.Rank);
hasErrors = true;
}
return new BoundArrayCreation((SyntaxNode)(object)cSharpSyntaxNode, sizes, boundArrayInitialization, type, hasErrors)
{
WasCompilerGenerated = (!flag && (initSyntax.Parent == null || initSyntax.Parent.Kind() != SyntaxKind.EqualsValueClause || ((EqualsValueClauseSyntax)initSyntax.Parent).Value != initSyntax))
};
}
private BoundExpression BindStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: 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_0202: Unknown result type (might be due to invalid IL or missing references)
TypeSyntax type = node.Type;
if (type.Kind() != SyntaxKind.ArrayType)
{
Error(diagnostics, ErrorCode.ERR_BadStackAllocExpr, (CSharpSyntaxNode)type);
return new BoundBadExpression((SyntaxNode)(object)node, LookupResultKind.NotCreatable, ImmutableArray<Symbol>.Empty, ImmutableArray<BoundExpression>.Empty, new PointerTypeSymbol(BindType(type, diagnostics)));
}
ArrayTypeSyntax arrayTypeSyntax = (ArrayTypeSyntax)type;
TypeSyntax elementType = arrayTypeSyntax.ElementType;
TypeWithAnnotations elementTypeWithAnnotations = ((ArrayTypeSymbol)BindArrayType(arrayTypeSyntax, diagnostics, permitDimensions: true, null, disallowRestrictedTypes: false).Type).ElementTypeWithAnnotations;
bool hasErrors;
TypeSymbol stackAllocType = GetStackAllocType((SyntaxNode)(object)node, elementTypeWithAnnotations, diagnostics, out hasErrors);
if (!elementTypeWithAnnotations.Type.IsErrorType())
{
hasErrors = hasErrors || CheckManagedAddr(Compilation, elementTypeWithAnnotations.Type, ((SyntaxNode)elementType).Location, diagnostics, errorForManaged: true);
}
SyntaxList<ArrayRankSpecifierSyntax> rankSpecifiers = arrayTypeSyntax.RankSpecifiers;
if (rankSpecifiers.Count != 1 || rankSpecifiers[0].Sizes.Count != 1)
{
Error(diagnostics, ErrorCode.ERR_BadStackAllocExpr, (CSharpSyntaxNode)type);
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance();
Enumerator<ArrayRankSpecifierSyntax> enumerator = rankSpecifiers.GetEnumerator();
while (enumerator.MoveNext())
{
Enumerator<ExpressionSyntax> enumerator2 = enumerator.Current.Sizes.GetEnumerator();
while (enumerator2.MoveNext())
{
ExpressionSyntax current = enumerator2.Current;
if (current.Kind() != SyntaxKind.OmittedArraySizeExpression)
{
instance.Add(BindExpression(current, BindingDiagnosticBag.Discarded));
}
}
}
return new BoundBadExpression((SyntaxNode)(object)node, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, instance.ToImmutableAndFree(), new PointerTypeSymbol(elementTypeWithAnnotations));
}
ExpressionSyntax expressionSyntax = rankSpecifiers[0].Sizes[0];
BoundExpression boundExpression = null;
if (expressionSyntax.Kind() != SyntaxKind.OmittedArraySizeExpression)
{
boundExpression = BindValue(expressionSyntax, diagnostics, BindValueKind.RValue);
boundExpression = GenerateConversionForAssignment(GetSpecialType((SpecialType)13, diagnostics, (SyntaxNode)(object)node), boundExpression, diagnostics);
if (IsNegativeConstantForArraySize(boundExpression))
{
Error(diagnostics, ErrorCode.ERR_NegativeStackAllocSize, (CSharpSyntaxNode)expressionSyntax);
hasErrors = true;
}
}
else if (node.Initializer == null)
{
Error(diagnostics, ErrorCode.ERR_MissingArraySize, (CSharpSyntaxNode)rankSpecifiers[0]);
boundExpression = BadExpression((SyntaxNode)(object)expressionSyntax);
hasErrors = true;
}
if (node.Initializer != null)
{
return BindStackAllocWithInitializer((SyntaxNode)(object)node, node.StackAllocKeyword, node.Initializer, stackAllocType, elementTypeWithAnnotations.Type, boundExpression, diagnostics, hasErrors);
}
return new BoundStackAllocArrayCreation((SyntaxNode)(object)node, elementTypeWithAnnotations.Type, boundExpression, null, stackAllocType, hasErrors);
}
private bool ReportBadStackAllocPosition(SyntaxNode node, BindingDiagnosticBag diagnostics)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
bool flag = true;
if (MessageID.IDS_FeatureNestedStackalloc.RequiredVersion() > Compilation.LanguageVersion)
{
flag = (IsInMethodBody || IsLocalFunctionsScopeBinder) && node.IsLegalCSharp73SpanStackAllocPosition();
if (!flag)
{
MessageID.IDS_FeatureNestedStackalloc.CheckFeatureAvailability(diagnostics, node.GetFirstToken(false, false, false, false));
}
}
if (Flags.IncludesAny(BinderFlags.InCatchBlock | BinderFlags.InFinallyBlock | BinderFlags.InCatchFilter))
{
Error(diagnostics, ErrorCode.ERR_StackallocInCatchFinally, SyntaxNodeOrToken.op_Implicit(node));
}
return flag;
}
private TypeSymbol GetStackAllocType(SyntaxNode node, TypeWithAnnotations elementTypeWithAnnotations, BindingDiagnosticBag diagnostics, out bool hasErrors)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
bool flag = ReportBadStackAllocPosition(node, diagnostics);
hasErrors = !flag;
if (flag && !isStackallocTargetTyped(node))
{
CheckFeatureAvailability(node, MessageID.IDS_FeatureRefStructs, diagnostics);
NamedTypeSymbol wellKnownType = GetWellKnownType((WellKnownType)275, diagnostics, node);
return ConstructNamedType(wellKnownType, (SyntaxNode)(object)((node.Kind() == SyntaxKind.StackAllocArrayCreationExpression) ? ((StackAllocArrayCreationExpressionSyntax)(object)node).Type : ((TypeSyntax)(object)node)), default(SeparatedSyntaxList<TypeSyntax>), ImmutableArray.Create(elementTypeWithAnnotations), null, diagnostics);
}
return null;
static bool isStackallocTargetTyped(SyntaxNode val)
{
SyntaxNode parent = val.Parent;
if (!parent.IsKind(SyntaxKind.EqualsValueClause))
{
return false;
}
SyntaxNode parent2 = parent.Parent;
if (!parent2.IsKind(SyntaxKind.VariableDeclarator))
{
return false;
}
SyntaxNode parent3 = parent2.Parent;
if (!parent3.IsKind(SyntaxKind.VariableDeclaration))
{
return false;
}
if (!parent3.Parent.IsKind(SyntaxKind.LocalDeclarationStatement))
{
return parent3.Parent.IsKind(SyntaxKind.ForStatement);
}
return true;
}
}
private BoundExpression BindStackAllocWithInitializer(SyntaxNode node, SyntaxToken stackAllocKeyword, InitializerExpressionSyntax initSyntax, TypeSymbol type, TypeSymbol elementType, BoundExpression sizeOpt, BindingDiagnosticBag diagnostics, bool hasErrors, ImmutableArray<BoundExpression> boundInitExprOpt = default(ImmutableArray<BoundExpression>))
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureStackAllocInitializer.CheckFeatureAvailability(diagnostics, stackAllocKeyword);
if (boundInitExprOpt.IsDefault)
{
boundInitExprOpt = BindArrayInitializerExpressions(initSyntax, diagnostics, 1, 1);
}
boundInitExprOpt = ImmutableArrayExtensions.SelectAsArray<BoundExpression, (TypeSymbol, BindingDiagnosticBag), BoundExpression>(boundInitExprOpt, (Func<BoundExpression, (TypeSymbol, BindingDiagnosticBag), BoundExpression>)((BoundExpression expr, (TypeSymbol elementType, BindingDiagnosticBag diagnostics) t) => GenerateConversionForAssignment(t.elementType, expr, t.diagnostics)), (elementType, diagnostics));
if (sizeOpt != null)
{
if (!sizeOpt.HasAnyErrors)
{
int? integerConstantForArraySize = GetIntegerConstantForArraySize(sizeOpt);
if (!integerConstantForArraySize.HasValue)
{
Error(diagnostics, ErrorCode.ERR_ConstantExpected, SyntaxNodeOrToken.op_Implicit(sizeOpt.Syntax));
hasErrors = true;
}
else if (boundInitExprOpt.Length != integerConstantForArraySize)
{
Error(diagnostics, ErrorCode.ERR_ArrayInitializerIncorrectLength, SyntaxNodeOrToken.op_Implicit(node), integerConstantForArraySize.Value);
hasErrors = true;
}
}
}
else
{
sizeOpt = new BoundLiteral(node, ConstantValue.Create(boundInitExprOpt.Length), GetSpecialType((SpecialType)13, diagnostics, node))
{
WasCompilerGenerated = true
};
}
bool isInferred = node.IsKind(SyntaxKind.ImplicitStackAllocArrayCreationExpression);
return new BoundStackAllocArrayCreation(node, elementType, sizeOpt, new BoundArrayInitialization((SyntaxNode)(object)initSyntax, isInferred, boundInitExprOpt), type, hasErrors);
}
private static int? GetIntegerConstantForArraySize(BoundExpression expression)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Invalid comparison between Unknown and I4
if (expression.HasAnyErrors)
{
return null;
}
ConstantValue constantValueOpt = expression.ConstantValueOpt;
if (constantValueOpt == (ConstantValue)null || constantValueOpt.IsBad || (int)expression.Type.SpecialType != 13)
{
return null;
}
return constantValueOpt.Int32Value;
}
private static bool IsNegativeConstantForArraySize(BoundExpression expression)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between Unknown and I4
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Invalid comparison between Unknown and I4
if (expression.HasAnyErrors)
{
return false;
}
ConstantValue constantValueOpt = expression.ConstantValueOpt;
if (constantValueOpt == (ConstantValue)null || constantValueOpt.IsBad)
{
return false;
}
SpecialType specialType = expression.Type.SpecialType;
if ((int)specialType == 13)
{
return constantValueOpt.Int32Value < 0;
}
if ((int)specialType == 15)
{
return constantValueOpt.Int64Value < 0;
}
return false;
}
internal BoundExpression BindConstructorInitializer(ArgumentListSyntax initializerArgumentListOpt, MethodSymbol constructor, BindingDiagnosticBag diagnostics)
{
Binder binder = null;
if (initializerArgumentListOpt != null)
{
binder = GetBinder((SyntaxNode)(object)initializerArgumentListOpt);
}
BoundExpression boundExpression = (binder ?? this).BindConstructorInitializerCore(initializerArgumentListOpt, constructor, diagnostics);
if (binder != null)
{
boundExpression = binder.WrapWithVariablesIfAny(initializerArgumentListOpt, boundExpression);
}
return boundExpression;
}
private BoundExpression BindConstructorInitializerCore(ArgumentListSyntax initializerArgumentListOpt, MethodSymbol constructor, BindingDiagnosticBag diagnostics)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Invalid comparison between Unknown and I4
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Invalid comparison between Unknown and I4
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Invalid comparison between Unknown and I4
NamedTypeSymbol containingType = constructor.ContainingType;
if (((int)containingType.TypeKind == 5 || (int)containingType.TypeKind == 10) && initializerArgumentListOpt == null)
{
return null;
}
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
try
{
TypeSymbol returnType = constructor.ReturnType;
NamedTypeSymbol baseTypeNoUseSiteDiagnostics = containingType.BaseTypeNoUseSiteDiagnostics;
if (initializerArgumentListOpt != null)
{
BindArgumentsAndNames(initializerArgumentListOpt, diagnostics, instance, allowArglist: true);
}
NamedTypeSymbol namedTypeSymbol = containingType;
bool flag = initializerArgumentListOpt == null || initializerArgumentListOpt.Parent.Kind() != SyntaxKind.ThisConstructorInitializer;
if (flag)
{
namedTypeSymbol = namedTypeSymbol.BaseTypeNoUseSiteDiagnostics;
if ((object)namedTypeSymbol == null || (int)containingType.SpecialType == 1)
{
if (initializerArgumentListOpt == null)
{
return null;
}
diagnostics.Add(ErrorCode.ERR_ObjectCallingBaseConstructor, constructor.GetFirstLocation(), containingType);
return new BoundBadExpression((SyntaxNode)(object)initializerArgumentListOpt.Parent, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, BuildArgumentsForErrorRecovery(instance), returnType);
}
if (initializerArgumentListOpt != null && (int)containingType.TypeKind == 10)
{
diagnostics.Add(ErrorCode.ERR_StructWithBaseConstructorCall, constructor.GetFirstLocation(), containingType);
return new BoundBadExpression((SyntaxNode)(object)initializerArgumentListOpt.Parent, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, BuildArgumentsForErrorRecovery(instance), returnType);
}
}
CSharpSyntaxNode cSharpSyntaxNode = initializerArgumentListOpt?.Parent;
CSharpSyntaxNode cSharpSyntaxNode2;
Location val;
bool enableCallerInfo;
if (!(cSharpSyntaxNode is ConstructorInitializerSyntax constructorInitializerSyntax))
{
if (cSharpSyntaxNode is PrimaryConstructorBaseTypeSyntax primaryConstructorBaseTypeSyntax)
{
cSharpSyntaxNode2 = primaryConstructorBaseTypeSyntax;
val = initializerArgumentListOpt.GetLocation();
enableCallerInfo = true;
}
else
{
cSharpSyntaxNode2 = constructor.GetNonNullSyntaxNode();
val = constructor.GetFirstLocation();
enableCallerInfo = false;
}
}
else
{
cSharpSyntaxNode2 = constructorInitializerSyntax;
SyntaxToken thisOrBaseKeyword = constructorInitializerSyntax.ThisOrBaseKeyword;
val = ((SyntaxToken)(ref thisOrBaseKeyword)).GetLocation();
enableCallerInfo = true;
}
if (initializerArgumentListOpt != null && instance.HasDynamicArgument)
{
diagnostics.Add(ErrorCode.ERR_NoDynamicPhantomOnBaseCtor, val);
return new BoundBadExpression((SyntaxNode)(object)initializerArgumentListOpt.Parent, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, BuildArgumentsForErrorRecovery(instance), returnType);
}
BoundExpression boundExpression = ThisReference((SyntaxNode)(object)cSharpSyntaxNode2, namedTypeSymbol, hasErrors: false, wasCompilerGenerated: true);
MemberResolutionResult<MethodSymbol> memberResolutionResult;
ImmutableArray<MethodSymbol> candidateConstructors;
bool num = TryPerformConstructorOverloadResolution(namedTypeSymbol, instance, ".ctor", val, suppressResultDiagnostics: false, diagnostics, out memberResolutionResult, out candidateConstructors, allowProtectedConstructorsOfBaseType: true, suppressUnsupportedRequiredMembersError: true);
MethodSymbol member = memberResolutionResult.Member;
validateRecordCopyConstructor(constructor, baseTypeNoUseSiteDiagnostics, member, val, diagnostics);
if (num)
{
bool hasErrors = false;
if (member == constructor)
{
diagnostics.Add(ErrorCode.ERR_RecursiveConstructorCall, val, constructor);
hasErrors = true;
}
else if (member.HasParameterContainingPointerType())
{
hasErrors = ReportUnsafeIfNotAllowed(val, diagnostics);
}
ReportDiagnosticsIfObsolete(diagnostics, member, SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)cSharpSyntaxNode2), flag);
bool flag2 = memberResolutionResult.Result.Kind == MemberResolutionKind.ApplicableInExpandedForm;
ImmutableArray<int> argsToParamsOpt = memberResolutionResult.Result.ArgsToParamsOpt;
if (constructor is SynthesizedPrimaryConstructor synthesizedPrimaryConstructor)
{
OrderedSet<ParameterSymbol> val2 = new OrderedSet<ParameterSymbol>();
for (int i = 0; i < instance.Arguments.Count; i++)
{
RefKind val3 = instance.RefKind(i);
if (val3 - 1 <= 1)
{
continue;
}
(ParameterSymbol, SyntaxNode) tuple = TryGetPrimaryConstructorParameterUsedAsValue(synthesizedPrimaryConstructor, instance.Argument(i));
var (parameterSymbol, _) = tuple;
if ((object)parameterSymbol == null)
{
continue;
}
SyntaxNode item = tuple.Item2;
if (item == null)
{
continue;
}
if (flag2)
{
ParameterSymbol correspondingParameter = GetCorrespondingParameter(i, member.Parameters, argsToParamsOpt, expanded: true);
if (correspondingParameter.Ordinal == member.ParameterCount - 1 && Microsoft.CodeAnalysis.CSharp.OverloadResolution.IsValidParamsParameter(correspondingParameter))
{
continue;
}
}
if (val2.Add(parameterSymbol) && synthesizedPrimaryConstructor.GetCapturedParameters().ContainsKey(parameterSymbol))
{
diagnostics.Add(ErrorCode.WRN_CapturedPrimaryConstructorParameterPassedToBase, item.Location, parameterSymbol);
}
}
synthesizedPrimaryConstructor.SetParametersPassedToTheBase((IReadOnlySet<ParameterSymbol>)(object)val2);
}
BindDefaultArguments((SyntaxNode)(object)cSharpSyntaxNode2, member.Parameters, instance.Arguments, instance.RefKinds, ref argsToParamsOpt, out var defaultArguments, flag2, enableCallerInfo, diagnostics);
ImmutableArray<BoundExpression> arguments = instance.Arguments.ToImmutable();
ImmutableArray<RefKind> argumentRefKindsOpt = instance.RefKinds.ToImmutableOrNull();
if (member.HasSetsRequiredMembers && !constructor.HasSetsRequiredMembers)
{
hasErrors = true;
diagnostics.Add(ErrorCode.ERR_ChainingToSetsRequiredMembersRequiresSetsRequiredMembers, val);
}
return new BoundCall((SyntaxNode)(object)cSharpSyntaxNode2, boundExpression, ReceiverIsSubjectToCloning(boundExpression, member), member, arguments, instance.GetNames(), argumentRefKindsOpt, isDelegateCall: false, flag2, invokedAsExtensionMethod: false, argsToParamsOpt, defaultArguments, LookupResultKind.Viable, returnType, hasErrors)
{
WasCompilerGenerated = (initializerArgumentListOpt == null)
};
}
BoundCall boundCall = CreateBadCall((SyntaxNode)(object)cSharpSyntaxNode2, ".ctor", boundExpression, candidateConstructors, LookupResultKind.OverloadResolutionFailure, ImmutableArray<TypeWithAnnotations>.Empty, instance, invokedAsExtensionMethod: false, isDelegate: false);
boundCall.WasCompilerGenerated = initializerArgumentListOpt == null;
return boundCall;
}
finally
{
instance.Free();
}
static void validateRecordCopyConstructor(MethodSymbol constructor2, NamedTypeSymbol baseType, MethodSymbol resultMember, Location errorLocation, BindingDiagnosticBag bindingDiagnosticBag)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
if (IsUserDefinedRecordCopyConstructor(constructor2))
{
if ((int)baseType.SpecialType == 1)
{
if ((object)resultMember == null || (int)resultMember.ContainingType.SpecialType != 1)
{
bindingDiagnosticBag.Add(ErrorCode.ERR_CopyConstructorMustInvokeBaseCopyConstructor, errorLocation);
}
}
else if ((object)resultMember == null || !SynthesizedRecordCopyCtor.HasCopyConstructorSignature(resultMember))
{
bindingDiagnosticBag.Add(ErrorCode.ERR_CopyConstructorMustInvokeBaseCopyConstructor, errorLocation);
}
}
}
}
private static (ParameterSymbol, SyntaxNode) TryGetPrimaryConstructorParameterUsedAsValue(SynthesizedPrimaryConstructor primaryConstructor, BoundExpression boundExpression)
{
BoundParameter boundParameter2;
if (!(boundExpression is BoundParameter boundParameter))
{
if (!(boundExpression is BoundConversion { Conversion: { IsIdentity: not false }, Operand: BoundParameter operand }))
{
return (null, null);
}
boundParameter2 = operand;
}
else
{
boundParameter2 = boundParameter;
}
ParameterSymbol parameterSymbol = boundParameter2.ParameterSymbol;
if ((object)parameterSymbol != null && (object)parameterSymbol.ContainingSymbol == primaryConstructor)
{
return (parameterSymbol, boundParameter2.Syntax);
}
return (null, null);
}
internal static bool IsUserDefinedRecordCopyConstructor(MethodSymbol constructor)
{
if (constructor.ContainingType is SourceNamedTypeSymbol { IsRecord: not false } && !(constructor is SynthesizedPrimaryConstructor))
{
return SynthesizedRecordCopyCtor.HasCopyConstructorSignature(constructor);
}
return false;
}
private BoundExpression BindImplicitObjectCreationExpression(ImplicitObjectCreationExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureImplicitObjectCreation.CheckFeatureAvailability(diagnostics, node.NewKeyword);
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
BindArgumentsAndNames(node.ArgumentList, diagnostics, instance, allowArglist: true);
BoundUnconvertedObjectCreationExpression result = new BoundUnconvertedObjectCreationExpression((SyntaxNode)(object)node, instance.Arguments.ToImmutable(), instance.Names.ToImmutableOrNull(), instance.RefKinds.ToImmutableOrNull(), node.Initializer, this);
instance.Free();
return result;
}
protected BoundExpression BindObjectCreationExpression(ObjectCreationExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
return bindObjectCreationExpression(node, diagnostics);
BoundExpression bindObjectCreationExpression(ObjectCreationExpressionSyntax objectCreationExpressionSyntax, BindingDiagnosticBag bindingDiagnosticBag)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected I4, but got Unknown
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
TypeWithAnnotations typeWithAnnotations = BindType(objectCreationExpressionSyntax.Type, bindingDiagnosticBag);
TypeSymbol typeSymbol = typeWithAnnotations.Type;
TypeSymbol initializerType = typeSymbol;
if (typeWithAnnotations.NullableAnnotation.IsAnnotated() && !typeSymbol.IsNullableType())
{
bindingDiagnosticBag.Add(ErrorCode.ERR_AnnotationDisallowedInObjectCreation, ((SyntaxNode)objectCreationExpressionSyntax).Location);
}
TypeKind typeKind = typeSymbol.TypeKind;
switch (typeKind - 1)
{
case 1:
case 4:
case 5:
case 9:
return BindClassCreationExpression(objectCreationExpressionSyntax, (NamedTypeSymbol)typeSymbol, GetName(objectCreationExpressionSyntax.Type), bindingDiagnosticBag, initializerType);
case 2:
return BindDelegateCreationExpression(objectCreationExpressionSyntax, (NamedTypeSymbol)typeSymbol, bindingDiagnosticBag);
case 6:
return BindInterfaceCreationExpression(objectCreationExpressionSyntax, (NamedTypeSymbol)typeSymbol, bindingDiagnosticBag);
case 10:
return BindTypeParameterCreationExpression(objectCreationExpressionSyntax, (TypeParameterSymbol)typeSymbol, bindingDiagnosticBag);
case 11:
throw ExceptionUtilities.UnexpectedValue((object)typeSymbol.TypeKind);
case 8:
case 12:
typeSymbol = new ExtendedErrorTypeSymbol(typeSymbol, LookupResultKind.NotCreatable, (DiagnosticInfo)(object)bindingDiagnosticBag.Add(ErrorCode.ERR_UnsafeTypeInObjectCreation, ((SyntaxNode)objectCreationExpressionSyntax).Location, typeSymbol));
goto case 1;
case 0:
case 3:
typeSymbol = new ExtendedErrorTypeSymbol(typeSymbol, LookupResultKind.NotCreatable, (DiagnosticInfo)(object)bindingDiagnosticBag.Add(ErrorCode.ERR_InvalidObjectCreation, ((SyntaxNode)objectCreationExpressionSyntax.Type).Location));
goto case 1;
default:
throw ExceptionUtilities.UnexpectedValue((object)typeSymbol.TypeKind);
}
}
}
private BoundExpression BindCollectionExpression(CollectionExpressionSyntax syntax, BindingDiagnosticBag diagnostics)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken openBracketToken = syntax.OpenBracketToken;
MessageID.IDS_FeatureCollectionExpressions.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)syntax, ((SyntaxToken)(ref openBracketToken)).GetLocation());
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(syntax.Elements.Count);
Enumerator<CollectionElementSyntax> enumerator = syntax.Elements.GetEnumerator();
while (enumerator.MoveNext())
{
CollectionElementSyntax current = enumerator.Current;
instance.Add(bindElement(current, diagnostics));
}
return new BoundUnconvertedCollectionExpression((SyntaxNode)(object)syntax, instance.ToImmutableAndFree());
BoundExpression bindElement(CollectionElementSyntax collectionElementSyntax, BindingDiagnosticBag diagnostics2)
{
if (collectionElementSyntax is ExpressionElementSyntax expressionElementSyntax)
{
return BindValue(expressionElementSyntax.Expression, diagnostics2, BindValueKind.RValue);
}
if (!(collectionElementSyntax is SpreadElementSyntax syntax2))
{
throw ExceptionUtilities.UnexpectedValue((object)collectionElementSyntax.Kind());
}
return bindSpreadElement(syntax2, diagnostics2);
}
BoundExpression bindSpreadElement(SpreadElementSyntax spreadElementSyntax, BindingDiagnosticBag bindingDiagnosticBag)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
BoundExpression collectionExpr = BindRValueWithoutTargetType(spreadElementSyntax.Expression, bindingDiagnosticBag);
TypeWithAnnotations inferredType;
ForEachEnumeratorInfo.Builder builder;
bool flag = !GetEnumeratorInfoAndInferCollectionElementType((SyntaxNode)(object)spreadElementSyntax, spreadElementSyntax.Expression, ref collectionExpr, isAsync: false, bindingDiagnosticBag, out inferredType, out builder) || builder.IsIncomplete;
if (flag)
{
return new BoundCollectionExpressionSpreadElement((SyntaxNode)(object)spreadElementSyntax, collectionExpr, null, null, null, null, null, null, flag);
}
BoundCollectionExpressionSpreadExpressionPlaceholder boundCollectionExpressionSpreadExpressionPlaceholder = new BoundCollectionExpressionSpreadExpressionPlaceholder((SyntaxNode)(object)spreadElementSyntax.Expression, collectionExpr.Type);
ForEachEnumeratorInfo forEachEnumeratorInfo = builder.Build(BinderFlags.None);
TypeSymbol collectionType = forEachEnumeratorInfo.CollectionType;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(bindingDiagnosticBag);
Conversion collectionConversionClassification = Conversions.ClassifyConversionFromExpression(collectionExpr, collectionType, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag).Add((SyntaxNode)(object)spreadElementSyntax.Expression, useSiteInfo);
BoundExpression conversion = ConvertForEachCollection(boundCollectionExpressionSpreadExpressionPlaceholder, collectionConversionClassification, collectionType, bindingDiagnosticBag);
if (!TryBindLengthOrCount((SyntaxNode)(object)spreadElementSyntax.Expression, boundCollectionExpressionSpreadExpressionPlaceholder, out BoundExpression lengthOrCountAccess, bindingDiagnosticBag))
{
lengthOrCountAccess = null;
}
return new BoundCollectionExpressionSpreadElement((SyntaxNode)(object)spreadElementSyntax, collectionExpr, boundCollectionExpressionSpreadExpressionPlaceholder, conversion, forEachEnumeratorInfo, lengthOrCountAccess, null, null)
{
WasCompilerGenerated = true
};
}
}
private BoundExpression BindDelegateCreationExpression(ObjectCreationExpressionSyntax node, NamedTypeSymbol type, BindingDiagnosticBag diagnostics)
{
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
BindArgumentsAndNames(node.ArgumentList, diagnostics, instance, allowArglist: false, isDelegateCreation: true);
BoundExpression result = BindDelegateCreationExpression((SyntaxNode)(object)node, type, instance, node.Initializer, wasTargetTyped: false, diagnostics);
instance.Free();
return result;
}
private BoundExpression BindDelegateCreationExpression(SyntaxNode node, NamedTypeSymbol type, AnalyzedArguments analyzedArguments, InitializerExpressionSyntax initializerOpt, bool wasTargetTyped, BindingDiagnosticBag diagnostics)
{
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Invalid comparison between Unknown and I4
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
if (!analyzedArguments.HasErrors)
{
if (analyzedArguments.Arguments.Count == 0)
{
diagnostics.Add(ErrorCode.ERR_BadCtorArgCount, node.Location, type, 0);
flag = true;
}
else if (analyzedArguments.Names.Count != 0 || analyzedArguments.RefKinds.Count != 0 || analyzedArguments.Arguments.Count != 1)
{
SyntaxNode syntax = analyzedArguments.Arguments[0].Syntax;
int spanStart = syntax.SpanStart;
TextSpan span = analyzedArguments.Arguments[analyzedArguments.Arguments.Count - 1].Syntax.Span;
int end = ((TextSpan)(ref span)).End;
TextSpan val = default(TextSpan);
((TextSpan)(ref val))._002Ector(spanStart, end - spanStart);
SourceLocation location = new SourceLocation(syntax.SyntaxTree, val);
diagnostics.Add(ErrorCode.ERR_MethodNameExpected, (Location)(object)location);
flag = true;
}
}
if (initializerOpt != null)
{
Error(diagnostics, ErrorCode.ERR_ObjectOrCollectionInitializerWithDelegateCreation, SyntaxNodeOrToken.op_Implicit(node));
flag = true;
}
BoundExpression boundExpression = ((analyzedArguments.Arguments.Count >= 1) ? BindToNaturalType(analyzedArguments.Arguments[0], diagnostics) : null);
if (!flag)
{
if (boundExpression is UnboundLambda unboundLambda)
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyConversionFromExpression(unboundLambda, type, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
BoundLambda boundLambda = unboundLambda.Bind(type, isExpressionTree: false);
if (!conversion.IsImplicit || !conversion.IsValid)
{
GenerateImplicitConversionError(diagnostics, unboundLambda.Syntax, conversion, unboundLambda, type);
}
else
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(boundLambda.Diagnostics, false);
}
flag = !conversion.IsImplicit;
if (!flag)
{
CheckParameterModifierMismatchMethodConversion(unboundLambda.Syntax, boundLambda.Symbol, type, invokedAsExtensionMethod: false, diagnostics);
CheckLambdaConversion(boundLambda.Symbol, type, diagnostics);
}
return new BoundDelegateCreationExpression(node, boundLambda, null, isExtensionMethod: false, wasTargetTyped, type, flag);
}
if (!analyzedArguments.HasErrors)
{
if (boundExpression.Kind == BoundKind.MethodGroup)
{
BoundMethodGroup boundMethodGroup = (BoundMethodGroup)boundExpression;
flag = MethodGroupConversionDoesNotExistOrHasErrors(boundMethodGroup, type, node.Location, diagnostics, out var conversion2);
boundMethodGroup = FixMethodGroupWithTypeOrValue(boundMethodGroup, conversion2, diagnostics);
return new BoundDelegateCreationExpression(node, boundMethodGroup, conversion2.Method, conversion2.IsExtensionMethod, wasTargetTyped, type, flag);
}
if ((object)boundExpression.Type == null)
{
diagnostics.Add(ErrorCode.ERR_MethodNameExpected, boundExpression.Syntax.Location);
}
else
{
if (boundExpression.HasDynamicType())
{
return new BoundDelegateCreationExpression(node, boundExpression, null, isExtensionMethod: false, wasTargetTyped, type);
}
if ((int)boundExpression.Type.TypeKind == 3)
{
NamedTypeSymbol namedTypeSymbol = (NamedTypeSymbol)boundExpression.Type;
MethodGroup instance = MethodGroup.GetInstance();
try
{
if (ReportDelegateInvokeUseSiteDiagnostic(diagnostics, boundExpression.Type, null, node))
{
return new BoundBadExpression(node, LookupResultKind.NotInvocable, StaticCast<Symbol>.From<MethodSymbol>(type.InstanceConstructors), ImmutableArray.Create(boundExpression), type);
}
instance.PopulateWithSingleMethod(boundExpression, namedTypeSymbol.DelegateInvokeMethod);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo2 = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion3 = Conversions.MethodGroupConversion(boundExpression.Syntax, instance, type, ref useSiteInfo2);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo2);
if (!conversion3.Exists)
{
BoundMethodGroup expr = new BoundMethodGroup(boundExpression.Syntax, default(ImmutableArray<TypeWithAnnotations>), "Invoke", ImmutableArray.Create(namedTypeSymbol.DelegateInvokeMethod), namedTypeSymbol.DelegateInvokeMethod, null, BoundMethodGroupFlags.None, null, boundExpression, LookupResultKind.Viable);
if (!Microsoft.CodeAnalysis.CSharp.Conversions.ReportDelegateOrFunctionPointerMethodGroupDiagnostics(this, expr, type, diagnostics))
{
diagnostics.Add(ErrorCode.ERR_MethDelegateMismatch, node.Location, namedTypeSymbol.DelegateInvokeMethod, type);
}
}
else if (!MethodGroupConversionHasErrors(boundExpression.Syntax, conversion3, boundExpression, conversion3.IsExtensionMethod, isAddressOf: false, type, diagnostics))
{
return new BoundDelegateCreationExpression(node, boundExpression, null, isExtensionMethod: false, wasTargetTyped, type);
}
}
finally
{
instance.Free();
}
}
else
{
diagnostics.Add(ErrorCode.ERR_MethodNameExpected, boundExpression.Syntax.Location);
}
}
}
}
ImmutableArray<BoundExpression> childBoundNodes = BuildArgumentsForErrorRecovery(analyzedArguments);
return new BoundBadExpression(node, LookupResultKind.OverloadResolutionFailure, StaticCast<Symbol>.From<MethodSymbol>(type.InstanceConstructors), childBoundNodes, type);
}
private BoundExpression BindClassCreationExpression(ObjectCreationExpressionSyntax node, NamedTypeSymbol type, string typeName, BindingDiagnosticBag diagnostics, TypeSymbol initializerType = null)
{
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
try
{
BindArgumentsAndNames(node.ArgumentList, diagnostics, instance, allowArglist: true);
if (type.IsStatic)
{
diagnostics.Add(ErrorCode.ERR_InstantiatingStaticClass, ((SyntaxNode)node).Location, type);
return MakeBadExpressionForObjectCreation(node, type, instance, diagnostics);
}
if (node.Type.Kind() == SyntaxKind.TupleType)
{
diagnostics.Add(ErrorCode.ERR_NewWithTupleTypeSyntax, node.Type.GetLocation());
return MakeBadExpressionForObjectCreation(node, type, instance, diagnostics);
}
return BindClassCreationExpression((SyntaxNode)(object)node, typeName, (SyntaxNode)(object)node.Type, type, instance, diagnostics, node.Initializer, initializerType);
}
finally
{
instance.Free();
}
}
private BoundExpression MakeConstructorInvocation(NamedTypeSymbol type, ArrayBuilder<BoundExpression> arguments, ArrayBuilder<RefKind> refKinds, SyntaxNode node, BindingDiagnosticBag diagnostics)
{
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
try
{
instance.Arguments.AddRange(arguments);
instance.RefKinds.AddRange(refKinds);
if (type.IsStatic)
{
diagnostics.Add(ErrorCode.ERR_InstantiatingStaticClass, node.Location, type);
return MakeBadExpressionForObjectCreation(node, type, instance, null, null, diagnostics, wasCompilerGenerated: true);
}
BoundExpression boundExpression = BindClassCreationExpression(node, type.Name, node, type, instance, diagnostics);
boundExpression.WasCompilerGenerated = true;
return boundExpression;
}
finally
{
instance.Free();
}
}
internal BoundExpression BindObjectCreationForErrorRecovery(BoundUnconvertedObjectCreationExpression node, BindingDiagnosticBag diagnostics)
{
AnalyzedArguments instance = AnalyzedArguments.GetInstance(node.Arguments, node.ArgumentRefKindsOpt, node.ArgumentNamesOpt);
BoundExpression result = MakeBadExpressionForObjectCreation(node.Syntax, CreateErrorType(), instance, node.InitializerOpt, node.Syntax, diagnostics);
instance.Free();
return result;
}
private BoundExpression MakeBadExpressionForObjectCreation(ObjectCreationExpressionSyntax node, TypeSymbol type, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics, bool wasCompilerGenerated = false)
{
return MakeBadExpressionForObjectCreation((SyntaxNode)(object)node, type, analyzedArguments, node.Initializer, (SyntaxNode?)(object)node.Type, diagnostics, wasCompilerGenerated);
}
private BoundExpression MakeBadExpressionForObjectCreation(SyntaxNode node, TypeSymbol type, AnalyzedArguments analyzedArguments, InitializerExpressionSyntax? initializerOpt, SyntaxNode? typeSyntax, BindingDiagnosticBag diagnostics, bool wasCompilerGenerated = false)
{
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance();
instance.AddRange(BuildArgumentsForErrorRecovery(analyzedArguments));
if (initializerOpt != null)
{
BoundObjectInitializerExpressionBase boundObjectInitializerExpressionBase = BindInitializerExpression(initializerOpt, type, typeSyntax, isForNewInstance: true, diagnostics);
instance.Add((BoundExpression)boundObjectInitializerExpressionBase);
}
return new BoundBadExpression(node, LookupResultKind.NotCreatable, ImmutableArray.Create((Symbol)type), instance.ToImmutableAndFree(), type)
{
WasCompilerGenerated = wasCompilerGenerated
};
}
private BoundObjectInitializerExpressionBase BindInitializerExpression(InitializerExpressionSyntax syntax, TypeSymbol type, SyntaxNode typeSyntax, bool isForNewInstance, BindingDiagnosticBag diagnostics)
{
BoundObjectOrCollectionValuePlaceholder implicitReceiver = new BoundObjectOrCollectionValuePlaceholder(typeSyntax, isForNewInstance, type)
{
WasCompilerGenerated = true
};
return syntax.Kind() switch
{
SyntaxKind.ObjectInitializerExpression => BindObjectInitializerExpression(syntax, type, diagnostics, implicitReceiver, useObjectInitDiagnostics: true),
SyntaxKind.WithInitializerExpression => BindObjectInitializerExpression(syntax, type, diagnostics, implicitReceiver, useObjectInitDiagnostics: false),
SyntaxKind.CollectionInitializerExpression => BindCollectionInitializerExpression(syntax, type, diagnostics, implicitReceiver),
_ => throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs", 5097),
};
}
private BoundExpression BindInitializerExpressionOrValue(ExpressionSyntax syntax, TypeSymbol type, BindValueKind rhsValueKind, SyntaxNode typeSyntax, BindingDiagnosticBag diagnostics)
{
SyntaxKind syntaxKind = syntax.Kind();
if (syntaxKind - 8644 <= SyntaxKind.List)
{
return BindInitializerExpression((InitializerExpressionSyntax)syntax, type, typeSyntax, isForNewInstance: false, diagnostics);
}
return BindValue(syntax, diagnostics, rhsValueKind);
}
private BoundObjectInitializerExpression BindObjectInitializerExpression(InitializerExpressionSyntax initializerSyntax, TypeSymbol initializerType, BindingDiagnosticBag diagnostics, BoundObjectOrCollectionValuePlaceholder implicitReceiver, bool useObjectInitDiagnostics)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
if (initializerSyntax.Kind() == SyntaxKind.ObjectInitializerExpression)
{
MessageID.IDS_FeatureObjectInitializer.CheckFeatureAvailability(diagnostics, initializerSyntax.OpenBraceToken);
}
Binder objectInitializerMemberBinder = (useObjectInitDiagnostics ? WithAdditionalFlags(BinderFlags.ObjectInitializerMember) : this);
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(initializerSyntax.Expressions.Count);
PooledHashSet<string> instance2 = PooledHashSet<string>.GetInstance();
Enumerator<ExpressionSyntax> enumerator = initializerSyntax.Expressions.GetEnumerator();
while (enumerator.MoveNext())
{
ExpressionSyntax current = enumerator.Current;
BoundExpression boundExpression = BindInitializerMemberAssignment(current, objectInitializerMemberBinder, diagnostics, implicitReceiver);
instance.Add(boundExpression);
ReportDuplicateObjectMemberInitializers(boundExpression, (HashSet<string>)(object)instance2, diagnostics);
}
return new BoundObjectInitializerExpression((SyntaxNode)(object)initializerSyntax, implicitReceiver, instance.ToImmutableAndFree(), initializerType);
}
private BoundExpression BindInitializerMemberAssignment(ExpressionSyntax memberInitializer, Binder objectInitializerMemberBinder, BindingDiagnosticBag diagnostics, BoundObjectOrCollectionValuePlaceholder implicitReceiver)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Invalid comparison between Unknown and I4
if (memberInitializer.Kind() == SyntaxKind.SimpleAssignmentExpression)
{
AssignmentExpressionSyntax assignmentExpressionSyntax = (AssignmentExpressionSyntax)memberInitializer;
BoundExpression boundExpression = objectInitializerMemberBinder.BindObjectInitializerMember(assignmentExpressionSyntax, implicitReceiver, diagnostics);
if (boundExpression != null)
{
RefKind refKind;
ExpressionSyntax syntax = assignmentExpressionSyntax.Right.CheckAndUnwrapRefExpression(diagnostics, out refKind);
bool flag = (int)refKind == 1;
BindValueKind rhsValueKind = (flag ? GetRequiredRHSValueKindForRefAssignment(boundExpression) : BindValueKind.RValue);
BoundExpression op = BindInitializerExpressionOrValue(syntax, boundExpression.Type, rhsValueKind, boundExpression.Syntax, diagnostics);
return BindAssignment((SyntaxNode)(object)assignmentExpressionSyntax, boundExpression, op, flag, diagnostics);
}
}
BoundExpression expr = BindValue(memberInitializer, diagnostics, BindValueKind.RValue);
Error(diagnostics, ErrorCode.ERR_InvalidInitializerElementInitializer, (CSharpSyntaxNode)memberInitializer);
return BindToTypeForErrorRecovery(ToBadExpression(expr, LookupResultKind.NotAValue));
}
private BoundExpression BindObjectInitializerMember(AssignmentExpressionSyntax namedAssignment, BoundObjectOrCollectionValuePlaceholder implicitReceiver, BindingDiagnosticBag diagnostics)
{
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
ExpressionSyntax left = namedAssignment.Left;
TypeSymbol type = implicitReceiver.Type;
SyntaxKind syntaxKind = namedAssignment.Right.Kind();
bool flag = syntaxKind == SyntaxKind.RefExpression;
bool flag2 = syntaxKind - 8644 <= SyntaxKind.List;
bool flag3 = flag2;
BindValueKind valueKind = (flag3 ? BindValueKind.RValue : (flag ? BindValueKind.RefAssignable : BindValueKind.Assignable));
BoundExpression expr;
bool flag4;
LookupResultKind resultKind;
if (left.Kind() == SyntaxKind.IdentifierName)
{
IdentifierNameSyntax identifierNameSyntax = (IdentifierNameSyntax)left;
SyntaxToken identifier;
if (type.IsDynamic())
{
identifier = identifierNameSyntax.Identifier;
expr = new BoundDynamicObjectInitializerMember((SyntaxNode)(object)left, ((SyntaxToken)(ref identifier)).Text, implicitReceiver.Type, type, hasErrors: false);
return CheckValue(expr, valueKind, diagnostics);
}
identifier = identifierNameSyntax.Identifier;
expr = BindInstanceMemberAccess((SyntaxNode)(object)identifierNameSyntax, (SyntaxNode)(object)identifierNameSyntax, implicitReceiver, ((SyntaxToken)(ref identifier)).ValueText, 0, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), invoked: false, indexed: false, diagnostics);
flag4 = expr.HasAnyErrors || implicitReceiver.HasAnyErrors;
if (expr.Kind == BoundKind.PropertyGroup)
{
expr = BindIndexedPropertyAccess((BoundPropertyGroup)expr, mustHaveAllOptionalParameters: true, diagnostics);
if (expr.HasAnyErrors)
{
flag4 = true;
}
}
resultKind = expr.ResultKind;
}
else
{
if (left.Kind() != SyntaxKind.ImplicitElementAccess)
{
return null;
}
ImplicitElementAccessSyntax implicitElementAccessSyntax = (ImplicitElementAccessSyntax)left;
MessageID.IDS_FeatureDictionaryInitializer.CheckFeatureAvailability(diagnostics, implicitElementAccessSyntax.ArgumentList.OpenBracketToken);
expr = BindElementAccess(implicitElementAccessSyntax, implicitReceiver, implicitElementAccessSyntax.ArgumentList, allowInlineArrayElementAccess: false, diagnostics);
resultKind = expr.ResultKind;
flag4 = expr.HasAnyErrors || implicitReceiver.HasAnyErrors;
}
BoundKind kind = expr.Kind;
ImmutableArray<BoundExpression> arguments = ImmutableArray<BoundExpression>.Empty;
ImmutableArray<string> argumentNamesOpt = default(ImmutableArray<string>);
ImmutableArray<int> argsToParamsOpt = default(ImmutableArray<int>);
ImmutableArray<RefKind> argumentRefKindsOpt = default(ImmutableArray<RefKind>);
BitVector defaultArguments = default(BitVector);
bool expanded = false;
switch (kind)
{
case BoundKind.FieldAccess:
{
FieldSymbol fieldSymbol = ((BoundFieldAccess)expr).FieldSymbol;
if (flag3 && fieldSymbol.IsReadOnly && fieldSymbol.Type.IsValueType)
{
if (!flag4)
{
Error(diagnostics, ErrorCode.ERR_ReadonlyValueTypeInObjectInitializer, (CSharpSyntaxNode)left, new object[2] { fieldSymbol, fieldSymbol.Type });
flag4 = true;
}
resultKind = LookupResultKind.NotAValue;
}
break;
}
case BoundKind.PropertyAccess:
flag4 |= flag3 && !CheckNestedObjectInitializerPropertySymbol(((BoundPropertyAccess)expr).PropertySymbol, left, diagnostics, flag4, ref resultKind);
break;
case BoundKind.IndexerAccess:
{
BoundIndexerAccess boundIndexerAccess = BindIndexerDefaultArguments((BoundIndexerAccess)expr, valueKind, diagnostics);
expr = boundIndexerAccess;
flag4 |= flag3 && !CheckNestedObjectInitializerPropertySymbol(boundIndexerAccess.Indexer, left, diagnostics, flag4, ref resultKind);
arguments = boundIndexerAccess.Arguments;
argumentNamesOpt = boundIndexerAccess.ArgumentNamesOpt;
argsToParamsOpt = boundIndexerAccess.ArgsToParamsOpt;
argumentRefKindsOpt = boundIndexerAccess.ArgumentRefKindsOpt;
defaultArguments = boundIndexerAccess.DefaultArguments;
expanded = boundIndexerAccess.Expanded;
ImmutableArray<BoundExpression>.Enumerator enumerator = arguments.GetEnumerator();
while (enumerator.MoveNext())
{
BoundExpression current = enumerator.Current;
if (current is BoundConversion { Conversion: { IsInterpolatedStringHandler: not false } } boundConversion)
{
BoundExpression operand = boundConversion.Operand;
if (operand.GetInterpolatedStringHandlerData().ArgumentPlaceholders.Any((BoundInterpolatedStringArgumentPlaceholder placeholder) => placeholder.ArgumentIndex == -1))
{
diagnostics.Add(ErrorCode.ERR_InterpolatedStringsReferencingInstanceCannotBeInObjectInitializers, current.Syntax.Location);
flag4 = true;
}
}
}
break;
}
case BoundKind.DynamicIndexerAccess:
{
BoundDynamicIndexerAccess obj = (BoundDynamicIndexerAccess)expr;
arguments = obj.Arguments;
argumentNamesOpt = obj.ArgumentNamesOpt;
argumentRefKindsOpt = obj.ArgumentRefKindsOpt;
break;
}
case BoundKind.PointerElementAccess:
case BoundKind.ArrayAccess:
return CheckValue(expr, valueKind, diagnostics);
default:
return BadObjectInitializerMemberAccess(expr, implicitReceiver, left, diagnostics, valueKind, flag4);
case BoundKind.DynamicObjectInitializerMember:
case BoundKind.EventAccess:
break;
}
if (!flag4 && !CheckValueKind(expr.Syntax, expr, valueKind, checkingReceiver: false, diagnostics))
{
flag4 = true;
resultKind = (flag3 ? LookupResultKind.NotAValue : LookupResultKind.NotAVariable);
}
return new BoundObjectInitializerMember((SyntaxNode)(object)left, expr.ExpressionSymbol, arguments, argumentNamesOpt, argumentRefKindsOpt, expanded, argsToParamsOpt, defaultArguments, resultKind, implicitReceiver.Type, expr.Type, flag4);
}
private static bool CheckNestedObjectInitializerPropertySymbol(PropertySymbol propertySymbol, ExpressionSyntax memberNameSyntax, BindingDiagnosticBag diagnostics, bool suppressErrors, ref LookupResultKind resultKind)
{
bool flag = false;
if (propertySymbol.Type.IsValueType)
{
if (!suppressErrors)
{
Error(diagnostics, ErrorCode.ERR_ValueTypePropertyInObjectInitializer, (CSharpSyntaxNode)memberNameSyntax, new object[2] { propertySymbol, propertySymbol.Type });
flag = true;
}
resultKind = LookupResultKind.NotAValue;
}
return !flag;
}
private BoundExpression BadObjectInitializerMemberAccess(BoundExpression boundMember, BoundObjectOrCollectionValuePlaceholder implicitReceiver, ExpressionSyntax memberNameSyntax, BindingDiagnosticBag diagnostics, BindValueKind valueKind, bool suppressErrors)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (!suppressErrors)
{
string text = ((!(memberNameSyntax is IdentifierNameSyntax { Identifier: var identifier })) ? ((object)memberNameSyntax).ToString() : ((SyntaxToken)(ref identifier)).ValueText);
switch (boundMember.ResultKind)
{
case LookupResultKind.Empty:
Error(diagnostics, ErrorCode.ERR_NoSuchMember, (CSharpSyntaxNode)memberNameSyntax, new object[2] { implicitReceiver.Type, text });
break;
case LookupResultKind.Inaccessible:
boundMember = CheckValue(boundMember, valueKind, diagnostics);
break;
default:
Error(diagnostics, ErrorCode.ERR_MemberCannotBeInitialized, (CSharpSyntaxNode)memberNameSyntax, new object[1] { text });
break;
}
}
return ToBadExpression(boundMember, (valueKind == BindValueKind.RValue) ? LookupResultKind.NotAValue : LookupResultKind.NotAVariable);
}
private static void ReportDuplicateObjectMemberInitializers(BoundExpression boundMemberInitializer, HashSet<string> memberNameMap, BindingDiagnosticBag diagnostics)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
if (!boundMemberInitializer.HasAnyErrors && ((AssignmentExpressionSyntax)(object)boundMemberInitializer.Syntax).Left is IdentifierNameSyntax { Identifier: var identifier } identifierNameSyntax)
{
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
if (!memberNameMap.Add(valueText))
{
Error(diagnostics, ErrorCode.ERR_MemberAlreadyInitialized, (CSharpSyntaxNode)identifierNameSyntax, new object[1] { valueText });
}
}
}
internal static void CheckRequiredMembersInObjectInitializer(MethodSymbol constructor, ImmutableArray<BoundExpression> initializers, SyntaxNode creationSyntax, BindingDiagnosticBag diagnostics)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
if (!constructor.ShouldCheckRequiredMembers() || constructor.ContainingType.HasRequiredMembersError)
{
return;
}
ImmutableSegmentedDictionary<string, Symbol> allRequiredMembers = constructor.ContainingType.AllRequiredMembers;
if (allRequiredMembers.Count == 0)
{
return;
}
Builder<string, Symbol> requiredMembersBuilder = allRequiredMembers.ToBuilder();
if (initializers.IsDefaultOrEmpty)
{
reportMembers();
return;
}
ImmutableArray<BoundExpression>.Enumerator enumerator = initializers.GetEnumerator();
Symbol symbol3 = default(Symbol);
while (enumerator.MoveNext())
{
if (!(enumerator.Current is BoundAssignmentOperator boundAssignmentOperator))
{
continue;
}
BoundExpression left = boundAssignmentOperator.Left;
Symbol symbol = ((left is BoundObjectInitializerMember boundObjectInitializerMember) ? boundObjectInitializerMember.MemberSymbol : ((left is BoundPropertyAccess boundPropertyAccess) ? ((Symbol)boundPropertyAccess.PropertySymbol) : ((Symbol)((!(left is BoundFieldAccess boundFieldAccess)) ? null : boundFieldAccess.FieldSymbol))));
Symbol symbol2 = symbol;
if ((object)symbol2 != null && requiredMembersBuilder.TryGetValue(symbol2.Name, ref symbol3) && symbol2.Equals(symbol3, (TypeCompareKind)0))
{
requiredMembersBuilder.Remove(symbol2.Name);
if (boundAssignmentOperator.Right is BoundObjectInitializerExpressionBase boundObjectInitializerExpressionBase)
{
diagnostics.Add(ErrorCode.ERR_RequiredMembersMustBeAssignedValue, boundObjectInitializerExpressionBase.Syntax.Location, symbol3);
}
}
}
reportMembers();
void reportMembers()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
if (requiredMembersBuilder.Count == 0)
{
return;
}
BaseObjectCreationExpressionSyntax baseObjectCreationExpressionSyntax;
Location location;
if (creationSyntax is ObjectCreationExpressionSyntax objectCreationExpressionSyntax)
{
TypeSyntax type = objectCreationExpressionSyntax.Type;
if (type == null)
{
baseObjectCreationExpressionSyntax = (BaseObjectCreationExpressionSyntax)(object)creationSyntax;
goto IL_004c;
}
location = ((SyntaxNode)type).Location;
}
else
{
baseObjectCreationExpressionSyntax = creationSyntax as BaseObjectCreationExpressionSyntax;
if (baseObjectCreationExpressionSyntax != null)
{
goto IL_004c;
}
if (creationSyntax is AttributeSyntax attributeSyntax)
{
NameSyntax name = attributeSyntax.Name;
if (name != null)
{
location = ((SyntaxNode)name).Location;
goto IL_00a0;
}
}
location = creationSyntax.Location;
}
goto IL_00a0;
IL_004c:
SyntaxToken newKeyword = baseObjectCreationExpressionSyntax.NewKeyword;
location = ((SyntaxToken)(ref newKeyword)).GetLocation();
goto IL_00a0;
IL_00a0:
Location location2 = location;
Enumerator<string, Symbol> enumerator2 = requiredMembersBuilder.GetEnumerator();
try
{
string text = default(string);
Symbol symbol4 = default(Symbol);
while (enumerator2.MoveNext())
{
KeyValuePairUtil.Deconstruct<string, Symbol>(enumerator2.Current, ref text, ref symbol4);
Symbol symbol5 = symbol4;
diagnostics.Add(ErrorCode.ERR_RequiredMemberMustBeSet, location2, symbol5);
}
}
finally
{
((IDisposable)enumerator2/*cast due to constrained. prefix*/).Dispose();
}
}
}
private BoundCollectionInitializerExpression BindCollectionInitializerExpression(InitializerExpressionSyntax initializerSyntax, TypeSymbol initializerType, BindingDiagnosticBag diagnostics, BoundObjectOrCollectionValuePlaceholder implicitReceiver)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureCollectionInitializer.CheckFeatureAvailability(diagnostics, initializerSyntax.OpenBraceToken);
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance();
bool flag = CollectionInitializerTypeImplementsIEnumerable(initializerType, initializerSyntax, diagnostics);
if (!flag && !((SyntaxNode)initializerSyntax).HasErrors && !initializerType.IsErrorType())
{
Error(diagnostics, ErrorCode.ERR_CollectionInitRequiresIEnumerable, (CSharpSyntaxNode)initializerSyntax, new object[1] { initializerType });
}
Binder collectionInitializerAddMethodBinder = WithAdditionalFlags(BinderFlags.CollectionInitializerAddMethod);
Enumerator<ExpressionSyntax> enumerator = initializerSyntax.Expressions.GetEnumerator();
while (enumerator.MoveNext())
{
ExpressionSyntax current = enumerator.Current;
BoundExpression boundExpression = BindCollectionInitializerElement(current, initializerType, flag, collectionInitializerAddMethodBinder, diagnostics, implicitReceiver);
instance.Add(boundExpression);
}
return new BoundCollectionInitializerExpression((SyntaxNode)(object)initializerSyntax, implicitReceiver, instance.ToImmutableAndFree(), initializerType);
}
private bool CollectionInitializerTypeImplementsIEnumerable(TypeSymbol initializerType, CSharpSyntaxNode node, BindingDiagnosticBag diagnostics)
{
//IL_001f: 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_003e: Unknown result type (might be due to invalid IL or missing references)
if (initializerType.IsDynamic())
{
return true;
}
if (!initializerType.IsErrorType())
{
TypeSymbol specialType = GetSpecialType((SpecialType)24, diagnostics, (SyntaxNode)(object)node);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
bool isValid = Conversions.ClassifyImplicitConversionFromType(initializerType, specialType, ref useSiteInfo).IsValid;
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
return isValid;
}
return false;
}
private BoundExpression BindCollectionInitializerElement(ExpressionSyntax elementInitializer, TypeSymbol initializerType, bool hasEnumerableInitializerType, Binder collectionInitializerAddMethodBinder, BindingDiagnosticBag diagnostics, BoundObjectOrCollectionValuePlaceholder implicitReceiver)
{
if (elementInitializer.Kind() == SyntaxKind.ComplexElementInitializerExpression)
{
return BindComplexElementInitializerExpression((InitializerExpressionSyntax)elementInitializer, diagnostics, hasEnumerableInitializerType, collectionInitializerAddMethodBinder, implicitReceiver);
}
if (SyntaxFacts.IsAssignmentExpression(elementInitializer.Kind()))
{
Error(diagnostics, ErrorCode.ERR_InvalidInitializerElementInitializer, (CSharpSyntaxNode)elementInitializer);
}
BoundExpression item = BindInitializerExpressionOrValue(elementInitializer, initializerType, BindValueKind.RValue, implicitReceiver.Syntax, diagnostics);
BoundExpression boundExpression = BindCollectionInitializerElementAddMethod(elementInitializer, ImmutableArray.Create(item), hasEnumerableInitializerType, collectionInitializerAddMethodBinder, diagnostics, implicitReceiver);
boundExpression.WasCompilerGenerated = true;
return boundExpression;
}
private BoundExpression BindComplexElementInitializerExpression(InitializerExpressionSyntax elementInitializer, BindingDiagnosticBag diagnostics, bool hasEnumerableInitializerType, Binder collectionInitializerAddMethodBinder = null, BoundObjectOrCollectionValuePlaceholder implicitReceiver = null)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
SeparatedSyntaxList<ExpressionSyntax> expressions = elementInitializer.Expressions;
if (expressions.Any())
{
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance();
Enumerator<ExpressionSyntax> enumerator = expressions.GetEnumerator();
while (enumerator.MoveNext())
{
ExpressionSyntax current = enumerator.Current;
instance.Add(BindValue(current, diagnostics, BindValueKind.RValue));
}
return BindCollectionInitializerElementAddMethod(elementInitializer, instance.ToImmutableAndFree(), hasEnumerableInitializerType, collectionInitializerAddMethodBinder, diagnostics, implicitReceiver);
}
Error(diagnostics, ErrorCode.ERR_EmptyElementInitializer, (CSharpSyntaxNode)elementInitializer);
return BadExpression((SyntaxNode)(object)elementInitializer, LookupResultKind.NotInvocable);
}
private BoundExpression BindUnexpectedComplexElementInitializer(InitializerExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
return BindComplexElementInitializerExpression(node, diagnostics, hasEnumerableInitializerType: false);
}
private BoundExpression BindCollectionInitializerElementAddMethod(ExpressionSyntax elementInitializer, ImmutableArray<BoundExpression> boundElementInitializerExpressions, bool hasEnumerableInitializerType, Binder collectionInitializerAddMethodBinder, BindingDiagnosticBag diagnostics, BoundObjectOrCollectionValuePlaceholder implicitReceiver)
{
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
if (!hasEnumerableInitializerType)
{
return BadExpression((SyntaxNode)(object)elementInitializer, LookupResultKind.NotInvocable, ImmutableArray<Symbol>.Empty, boundElementInitializerExpressions);
}
if (implicitReceiver.Type.IsDynamic())
{
bool hasErrors = ReportBadDynamicArguments((SyntaxNode)(object)elementInitializer, boundElementInitializerExpressions, default(ImmutableArray<RefKind>), diagnostics, null);
return new BoundDynamicCollectionElementInitializer((SyntaxNode)(object)elementInitializer, ImmutableArray<MethodSymbol>.Empty, implicitReceiver, ImmutableArrayExtensions.SelectAsArray<BoundExpression, BoundExpression>(boundElementInitializerExpressions, (Func<BoundExpression, BoundExpression>)((BoundExpression e) => BindToNaturalType(e, diagnostics))), GetSpecialType((SpecialType)6, diagnostics, (SyntaxNode)(object)elementInitializer), hasErrors);
}
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(withDiagnostics: true, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
BoundExpression boundExpression = collectionInitializerAddMethodBinder.MakeInvocationExpression((SyntaxNode)(object)elementInitializer, implicitReceiver, "Add", boundElementInitializerExpressions, instance);
copyRelevantAddMethodDiagnostics(instance, diagnostics);
if (boundExpression.Kind == BoundKind.DynamicInvocation)
{
BoundDynamicInvocation boundDynamicInvocation = (BoundDynamicInvocation)boundExpression;
return new BoundDynamicCollectionElementInitializer((SyntaxNode)(object)elementInitializer, boundDynamicInvocation.ApplicableMethods, implicitReceiver, boundDynamicInvocation.Arguments, boundDynamicInvocation.Type, boundDynamicInvocation.HasAnyErrors);
}
if (boundExpression.Kind == BoundKind.Call)
{
BoundCall boundCall = (BoundCall)boundExpression;
if (boundCall.HasErrors && !boundCall.OriginalMethodsOpt.IsDefault)
{
return boundCall;
}
return new BoundCollectionElementInitializer((SyntaxNode)(object)elementInitializer, boundCall.Method, boundCall.Arguments, boundCall.ReceiverOpt, boundCall.Expanded, boundCall.ArgsToParamsOpt, boundCall.DefaultArguments, boundCall.InvokedAsExtensionMethod, boundCall.ResultKind, boundCall.Type, boundCall.HasAnyErrors)
{
WasCompilerGenerated = true
};
}
return boundExpression;
static void copyRelevantAddMethodDiagnostics(BindingDiagnosticBag source, BindingDiagnosticBag target)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)target).AddDependencies((BindingDiagnosticBag<AssemblySymbol>)(object)source, false);
DiagnosticBag diagnosticBag = ((BindingDiagnosticBag)source).DiagnosticBag;
if (diagnosticBag != null && !diagnosticBag.IsEmptyWithoutResolution)
{
foreach (Diagnostic item in diagnosticBag.AsEnumerableWithoutResolution())
{
ErrorCode code = (ErrorCode)item.Code;
if ((code != ErrorCode.WRN_ArgExpectedRefOrIn && code != ErrorCode.WRN_ArgExpectedIn) || 1 == 0)
{
((BindingDiagnosticBag)target).Add(item);
}
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)source).Free();
}
}
internal BoundExpression BindCollectionExpressionElementAddMethod(BoundExpression element, Binder collectionInitializerAddMethodBinder, BoundObjectOrCollectionValuePlaceholder implicitReceiver, BindingDiagnosticBag diagnostics, out bool hasErrors)
{
BoundExpression boundExpression = ((element is BoundCollectionExpressionSpreadElement boundCollectionExpressionSpreadElement) ? BindCollectionExpressionSpreadElementAddMethod((SpreadElementSyntax)(object)boundCollectionExpressionSpreadElement.Syntax, boundCollectionExpressionSpreadElement, collectionInitializerAddMethodBinder, implicitReceiver, diagnostics) : BindCollectionInitializerElementAddMethod((ExpressionSyntax)(object)element.Syntax, ImmutableArray.Create(element), hasEnumerableInitializerType: true, collectionInitializerAddMethodBinder, diagnostics, implicitReceiver));
hasErrors = boundExpression.HasErrors;
return boundExpression;
}
private BoundCollectionExpressionSpreadElement BindCollectionExpressionSpreadElementAddMethod(SpreadElementSyntax syntax, BoundCollectionExpressionSpreadElement element, Binder collectionInitializerAddMethodBinder, BoundObjectOrCollectionValuePlaceholder implicitReceiver, BindingDiagnosticBag diagnostics)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
ForEachEnumeratorInfo enumeratorInfoOpt = element.EnumeratorInfoOpt;
if (enumeratorInfoOpt == null)
{
return element.Update(BindToNaturalType(element.Expression, BindingDiagnosticBag.Discarded, reportNoTargetType: false), element.ExpressionPlaceholder, null, enumeratorInfoOpt, null, null, null);
}
BoundValuePlaceholder boundValuePlaceholder = new BoundValuePlaceholder((SyntaxNode)(object)syntax, enumeratorInfoOpt.ElementType);
BoundExpression expression = collectionInitializerAddMethodBinder.MakeInvocationExpression((SyntaxNode)(object)syntax, implicitReceiver, "Add", ImmutableArray.Create((BoundExpression)boundValuePlaceholder), diagnostics);
return element.Update(element.Expression, element.ExpressionPlaceholder, element.Conversion, enumeratorInfoOpt, element.LengthOrCount, boundValuePlaceholder, new BoundExpressionStatement((SyntaxNode)(object)syntax, expression)
{
WasCompilerGenerated = true
});
}
internal ImmutableArray<MethodSymbol> FilterInaccessibleConstructors(ImmutableArray<MethodSymbol> constructors, bool allowProtectedConstructorsOfBaseType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
ArrayBuilder<MethodSymbol> val = null;
for (int i = 0; i < constructors.Length; i++)
{
MethodSymbol methodSymbol = constructors[i];
if (!IsConstructorAccessible(methodSymbol, ref useSiteInfo, allowProtectedConstructorsOfBaseType))
{
if (val == null)
{
val = ArrayBuilder<MethodSymbol>.GetInstance();
val.AddRange(constructors, i);
}
}
else
{
val?.Add(methodSymbol);
}
}
return val?.ToImmutableAndFree() ?? constructors;
}
private bool IsConstructorAccessible(MethodSymbol constructor, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool allowProtectedConstructorsOfBaseType = false)
{
NamedTypeSymbol containingType = ContainingType;
if ((object)containingType != null)
{
if (!allowProtectedConstructorsOfBaseType)
{
return IsSymbolAccessibleConditional(constructor, containingType, ref useSiteInfo, constructor.ContainingType);
}
return IsAccessible(constructor, ref useSiteInfo);
}
return IsSymbolAccessibleConditional(constructor, Compilation.Assembly, ref useSiteInfo);
}
protected BoundExpression BindClassCreationExpression(SyntaxNode node, string typeName, SyntaxNode typeNode, NamedTypeSymbol type, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics, InitializerExpressionSyntax initializerSyntaxOpt = null, TypeSymbol initializerTypeOpt = null, bool wasTargetTyped = false)
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
BoundExpression boundExpression = null;
bool flag = type.IsErrorType();
if (type.IsAbstract)
{
diagnostics.Add(ErrorCode.ERR_NoNewAbstract, node.Location, type);
flag = true;
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
BoundObjectInitializerExpressionBase boundObjectInitializerExpressionBase = null;
if (analyzedArguments.HasDynamicArgument)
{
OverloadResolutionResult<MethodSymbol> instance = OverloadResolutionResult<MethodSymbol>.GetInstance();
OverloadResolution.ObjectCreationOverloadResolution(GetAccessibleConstructorsForOverloadResolution(type, ref useSiteInfo), analyzedArguments, instance, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
useSiteInfo._002Ector(useSiteInfo);
if (instance.HasAnyApplicableMember)
{
ImmutableArray<BoundExpression> arguments = BuildArgumentsForDynamicInvocation(analyzedArguments, diagnostics);
ImmutableArray<RefKind> immutableArray = analyzedArguments.RefKinds.ToImmutableOrNull();
flag &= ReportBadDynamicArguments(node, arguments, immutableArray, diagnostics, null);
boundObjectInitializerExpressionBase = makeBoundInitializerOpt();
boundExpression = new BoundDynamicObjectCreationExpression(node, typeName, arguments, analyzedArguments.GetNames(), immutableArray, boundObjectInitializerExpressionBase, instance.GetAllApplicableMembers(), wasTargetTyped, type, flag);
}
instance.Free();
if (boundExpression != null)
{
return boundExpression;
}
}
if (TryPerformConstructorOverloadResolution(type, analyzedArguments, typeName, typeNode.Location, flag, diagnostics, out var memberResolutionResult, out var candidateConstructors, allowProtectedConstructorsOfBaseType: false, suppressUnsupportedRequiredMembersError: false) && !type.IsAbstract)
{
MethodSymbol member = memberResolutionResult.Member;
bool flag2 = false;
if (member.HasParameterContainingPointerType())
{
flag2 = ReportUnsafeIfNotAllowed(node, diagnostics) || flag2;
}
ReportDiagnosticsIfObsolete(diagnostics, member, SyntaxNodeOrToken.op_Implicit(node), hasBaseReceiver: false);
ConstantValue constantValueOpt = ((initializerSyntaxOpt == null && member.IsDefaultValueTypeConstructor()) ? FoldParameterlessValueTypeConstructor(type) : null);
bool expanded = memberResolutionResult.Result.Kind == MemberResolutionKind.ApplicableInExpandedForm;
ImmutableArray<int> argsToParamsOpt = memberResolutionResult.Result.ArgsToParamsOpt;
BindDefaultArguments(node, member.Parameters, analyzedArguments.Arguments, analyzedArguments.RefKinds, ref argsToParamsOpt, out var defaultArguments, expanded, enableCallerInfo: true, diagnostics);
ImmutableArray<BoundExpression> arguments2 = analyzedArguments.Arguments.ToImmutable();
ImmutableArray<RefKind> argumentRefKindsOpt = analyzedArguments.RefKinds.ToImmutableOrNull();
boundObjectInitializerExpressionBase = makeBoundInitializerOpt();
BoundObjectCreationExpression boundObjectCreationExpression = new BoundObjectCreationExpression(node, member, candidateConstructors, arguments2, analyzedArguments.GetNames(), argumentRefKindsOpt, expanded, argsToParamsOpt, defaultArguments, constantValueOpt, boundObjectInitializerExpressionBase, wasTargetTyped, type, flag2);
CheckRequiredMembersInObjectInitializer(boundObjectCreationExpression.Constructor, boundObjectCreationExpression.InitializerExpressionOpt?.Initializers ?? default(ImmutableArray<BoundExpression>), boundObjectCreationExpression.Syntax, diagnostics);
return boundObjectCreationExpression;
}
LookupResultKind resultKind = (type.IsAbstract ? LookupResultKind.NotCreatable : ((!memberResolutionResult.IsValid || IsConstructorAccessible(memberResolutionResult.Member, ref useSiteInfo)) ? LookupResultKind.OverloadResolutionFailure : LookupResultKind.Inaccessible));
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
ArrayBuilder<Symbol> instance2 = ArrayBuilder<Symbol>.GetInstance();
instance2.AddRange<MethodSymbol>(candidateConstructors);
ArrayBuilder<BoundExpression> instance3 = ArrayBuilder<BoundExpression>.GetInstance();
instance3.AddRange(BuildArgumentsForErrorRecovery(analyzedArguments, candidateConstructors));
if (initializerSyntaxOpt != null)
{
instance3.Add((BoundExpression)(boundObjectInitializerExpressionBase ?? makeBoundInitializerOpt()));
}
return new BoundBadExpression(node, resultKind, instance2.ToImmutableAndFree(), instance3.ToImmutableAndFree(), type);
BoundObjectInitializerExpressionBase makeBoundInitializerOpt()
{
if (initializerSyntaxOpt != null)
{
return BindInitializerExpression(initializerSyntaxOpt, initializerTypeOpt ?? type, typeNode, isForNewInstance: true, diagnostics);
}
return null;
}
}
private BoundExpression BindInterfaceCreationExpression(ObjectCreationExpressionSyntax node, NamedTypeSymbol type, BindingDiagnosticBag diagnostics)
{
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
BindArgumentsAndNames(node.ArgumentList, diagnostics, instance);
BoundExpression result = BindInterfaceCreationExpression((SyntaxNode)(object)node, type, diagnostics, (SyntaxNode)(object)node.Type, instance, node.Initializer, wasTargetTyped: false);
instance.Free();
return result;
}
private BoundExpression BindInterfaceCreationExpression(SyntaxNode node, NamedTypeSymbol type, BindingDiagnosticBag diagnostics, SyntaxNode typeNode, AnalyzedArguments analyzedArguments, InitializerExpressionSyntax initializerOpt, bool wasTargetTyped)
{
if (!InAttributeArgument && type.IsComImport)
{
NamedTypeSymbol comImportCoClass = type.ComImportCoClass;
if ((object)comImportCoClass != null)
{
return BindComImportCoClassCreationExpression(node, type, comImportCoClass, diagnostics, typeNode, analyzedArguments, initializerOpt, wasTargetTyped);
}
}
diagnostics.Add(ErrorCode.ERR_NoNewAbstract, node.Location, type);
return MakeBadExpressionForObjectCreation(node, type, analyzedArguments, initializerOpt, typeNode, diagnostics);
}
private BoundExpression BindComImportCoClassCreationExpression(SyntaxNode node, NamedTypeSymbol interfaceType, NamedTypeSymbol coClassType, BindingDiagnosticBag diagnostics, SyntaxNode typeNode, AnalyzedArguments analyzedArguments, InitializerExpressionSyntax initializerOpt, bool wasTargetTyped)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
if (coClassType.IsErrorType())
{
Error(diagnostics, ErrorCode.ERR_MissingCoClass, SyntaxNodeOrToken.op_Implicit(node), coClassType, interfaceType);
}
else
{
if (!coClassType.IsUnboundGenericType)
{
if (interfaceType.ContainingAssembly.IsLinked)
{
return BindNoPiaObjectCreationExpression(node, interfaceType, coClassType, diagnostics, typeNode, analyzedArguments, initializerOpt, wasTargetTyped);
}
BoundExpression boundExpression = BindClassCreationExpression(node, coClassType.Name, typeNode, coClassType, analyzedArguments, diagnostics, initializerOpt, interfaceType, wasTargetTyped);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyConversionFromExpression(boundExpression, interfaceType, CheckOverflowAtRuntime, ref useSiteInfo, forCast: true);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
if (!conversion.IsValid)
{
SymbolDistinguisher symbolDistinguisher = new SymbolDistinguisher(Compilation, coClassType, interfaceType);
Error(diagnostics, ErrorCode.ERR_NoExplicitConv, SyntaxNodeOrToken.op_Implicit(node), symbolDistinguisher.First, symbolDistinguisher.Second);
}
CreateConversion(boundExpression, conversion, interfaceType, diagnostics);
switch (boundExpression.Kind)
{
case BoundKind.ObjectCreationExpression:
{
BoundObjectCreationExpression boundObjectCreationExpression = (BoundObjectCreationExpression)boundExpression;
return boundObjectCreationExpression.Update(boundObjectCreationExpression.Constructor, boundObjectCreationExpression.ConstructorsGroup, boundObjectCreationExpression.Arguments, boundObjectCreationExpression.ArgumentNamesOpt, boundObjectCreationExpression.ArgumentRefKindsOpt, boundObjectCreationExpression.Expanded, boundObjectCreationExpression.ArgsToParamsOpt, boundObjectCreationExpression.DefaultArguments, boundObjectCreationExpression.ConstantValueOpt, boundObjectCreationExpression.InitializerExpressionOpt, interfaceType);
}
case BoundKind.BadExpression:
{
BoundBadExpression boundBadExpression = (BoundBadExpression)boundExpression;
return boundBadExpression.Update(boundBadExpression.ResultKind, boundBadExpression.Symbols, boundBadExpression.ChildBoundNodes, interfaceType);
}
default:
throw ExceptionUtilities.UnexpectedValue((object)boundExpression.Kind);
}
}
Error(diagnostics, ErrorCode.ERR_BadCoClassSig, SyntaxNodeOrToken.op_Implicit(node), coClassType, interfaceType);
}
return MakeBadExpressionForObjectCreation(node, interfaceType, analyzedArguments, initializerOpt, typeNode, diagnostics);
}
private BoundExpression BindNoPiaObjectCreationExpression(SyntaxNode node, NamedTypeSymbol interfaceType, NamedTypeSymbol coClassType, BindingDiagnosticBag diagnostics, SyntaxNode typeNode, AnalyzedArguments analyzedArguments, InitializerExpressionSyntax initializerOpt, bool wasTargetTyped)
{
if (!coClassType.GetGuidString(out var guidString))
{
Guid empty = Guid.Empty;
guidString = empty.ToString("D");
}
BoundObjectInitializerExpressionBase boundObjectInitializerExpressionBase = ((initializerOpt == null) ? null : BindInitializerExpression(initializerOpt, interfaceType, typeNode, isForNewInstance: true, diagnostics));
if (analyzedArguments.Arguments.Count > 0)
{
diagnostics.Add(ErrorCode.ERR_BadCtorArgCount, typeNode.Location, interfaceType, analyzedArguments.Arguments.Count);
ImmutableArray<BoundExpression> childBoundNodes = BuildArgumentsForErrorRecovery(analyzedArguments);
if (boundObjectInitializerExpressionBase != null)
{
childBoundNodes = childBoundNodes.Add(boundObjectInitializerExpressionBase);
}
return new BoundBadExpression(node, LookupResultKind.OverloadResolutionFailure, ImmutableArray<Symbol>.Empty, childBoundNodes, interfaceType);
}
return new BoundNoPiaObjectCreationExpression(node, guidString, boundObjectInitializerExpressionBase, wasTargetTyped, interfaceType);
}
private BoundExpression BindTypeParameterCreationExpression(ObjectCreationExpressionSyntax node, TypeParameterSymbol typeParameter, BindingDiagnosticBag diagnostics)
{
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
BindArgumentsAndNames(node.ArgumentList, diagnostics, instance);
BoundExpression result = BindTypeParameterCreationExpression((SyntaxNode)(object)node, typeParameter, instance, node.Initializer, (SyntaxNode)(object)node.Type, wasTargetTyped: false, diagnostics);
instance.Free();
return result;
}
private BoundExpression BindTypeParameterCreationExpression(SyntaxNode node, TypeParameterSymbol typeParameter, AnalyzedArguments analyzedArguments, InitializerExpressionSyntax? initializerOpt, SyntaxNode typeSyntax, bool wasTargetTyped, BindingDiagnosticBag diagnostics)
{
if (!typeParameter.HasConstructorConstraint && !typeParameter.IsValueType)
{
diagnostics.Add(ErrorCode.ERR_NoNewTyvar, node.Location, typeParameter);
}
else
{
if (analyzedArguments.Arguments.Count <= 0)
{
BoundObjectInitializerExpressionBase initializerExpressionOpt = ((initializerOpt == null) ? null : BindInitializerExpression(initializerOpt, typeParameter, typeSyntax, isForNewInstance: true, diagnostics));
return new BoundNewT(node, initializerExpressionOpt, wasTargetTyped, typeParameter);
}
diagnostics.Add(ErrorCode.ERR_NewTyvarWithArgs, node.Location, typeParameter);
}
return MakeBadExpressionForObjectCreation(node, typeParameter, analyzedArguments, initializerOpt, typeSyntax, diagnostics);
}
internal bool TryPerformConstructorOverloadResolution(NamedTypeSymbol typeContainingConstructors, AnalyzedArguments analyzedArguments, string errorName, Location errorLocation, bool suppressResultDiagnostics, BindingDiagnosticBag diagnostics, out MemberResolutionResult<MethodSymbol> memberResolutionResult, out ImmutableArray<MethodSymbol> candidateConstructors, bool allowProtectedConstructorsOfBaseType, bool suppressUnsupportedRequiredMembersError)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
candidateConstructors = GetAccessibleConstructorsForOverloadResolution(typeContainingConstructors, allowProtectedConstructorsOfBaseType, out var allInstanceConstructors, ref useSiteInfo);
OverloadResolutionResult<MethodSymbol> overloadResolutionResult = OverloadResolutionResult<MethodSymbol>.GetInstance();
bool flag = false;
bool flag2 = false;
if (candidateConstructors.Any())
{
OverloadResolution.ObjectCreationOverloadResolution(candidateConstructors, analyzedArguments, overloadResolutionResult, ref useSiteInfo);
if (overloadResolutionResult.Succeeded)
{
flag = true;
flag2 = true;
}
}
if (!flag && allInstanceConstructors.Length > candidateConstructors.Length)
{
OverloadResolutionResult<MethodSymbol> instance = OverloadResolutionResult<MethodSymbol>.GetInstance();
OverloadResolution.ObjectCreationOverloadResolution(allInstanceConstructors, analyzedArguments, instance, ref useSiteInfo);
if (instance.Succeeded)
{
flag2 = true;
candidateConstructors = allInstanceConstructors;
overloadResolutionResult.Free();
overloadResolutionResult = instance;
}
else
{
instance.Free();
}
}
ReportConstructorUseSiteDiagnostics(errorLocation, diagnostics, suppressUnsupportedRequiredMembersError, useSiteInfo);
if (flag2)
{
CheckAndCoerceArguments(overloadResolutionResult.ValidResult, analyzedArguments, diagnostics, null, invokedAsExtensionMethod: false);
}
memberResolutionResult = (flag2 ? overloadResolutionResult.ValidResult : default(MemberResolutionResult<MethodSymbol>));
if (!flag && !suppressResultDiagnostics)
{
if (flag2)
{
diagnostics.Add(ErrorCode.ERR_BadAccess, errorLocation, overloadResolutionResult.ValidResult.Member);
}
else
{
overloadResolutionResult.ReportDiagnostics(this, errorLocation, null, diagnostics, errorName, null, null, analyzedArguments, candidateConstructors, typeContainingConstructors, null);
}
}
overloadResolutionResult.Free();
return flag;
}
internal static bool ReportConstructorUseSiteDiagnostics(Location errorLocation, BindingDiagnosticBag diagnostics, bool suppressUnsupportedRequiredMembersError, CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
if (suppressUnsupportedRequiredMembersError && useSiteInfo.AccumulatesDiagnostics)
{
IReadOnlyCollection<DiagnosticInfo> diagnostics2 = useSiteInfo.Diagnostics;
if (diagnostics2 != null && diagnostics2.Count != 0)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddDependencies(useSiteInfo);
foreach (DiagnosticInfo diagnostic in useSiteInfo.Diagnostics)
{
if (diagnostic.Code != 9037)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).ReportUseSiteDiagnostic(diagnostic, errorLocation);
}
}
return true;
}
}
return ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(errorLocation, useSiteInfo);
}
private ImmutableArray<MethodSymbol> GetAccessibleConstructorsForOverloadResolution(NamedTypeSymbol type, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
ImmutableArray<MethodSymbol> allInstanceConstructors;
return GetAccessibleConstructorsForOverloadResolution(type, allowProtectedConstructorsOfBaseType: false, out allInstanceConstructors, ref useSiteInfo);
}
private ImmutableArray<MethodSymbol> GetAccessibleConstructorsForOverloadResolution(NamedTypeSymbol type, bool allowProtectedConstructorsOfBaseType, out ImmutableArray<MethodSymbol> allInstanceConstructors, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
if (type.IsErrorType())
{
type = (type.GetNonErrorGuess() as NamedTypeSymbol) ?? type;
}
allInstanceConstructors = type.InstanceConstructors;
return FilterInaccessibleConstructors(allInstanceConstructors, allowProtectedConstructorsOfBaseType, ref useSiteInfo);
}
private static ConstantValue FoldParameterlessValueTypeConstructor(NamedTypeSymbol type)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//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_0021: Invalid comparison between Unknown and I4
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
SpecialType specialType = type.SpecialType;
if ((int)type.TypeKind == 5)
{
specialType = type.EnumUnderlyingType.SpecialType;
}
if (specialType - 7 <= 12)
{
return ConstantValue.Default(specialType);
}
return null;
}
private BoundLiteral BindLiteralConstant(LiteralExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken token2;
if (node.Kind() == SyntaxKind.NumericLiteralExpression)
{
SyntaxToken token = node.Token;
token2 = node.Token;
string text = ((SyntaxToken)(ref token2)).Text;
TextSpan span;
if (text.EndsWith("l", StringComparison.Ordinal))
{
if (!text.EndsWith("ul") && !text.EndsWith("Ul"))
{
CSDiagnosticInfo info = new CSDiagnosticInfo(ErrorCode.WRN_LowercaseEllSuffix);
SyntaxTree syntaxTree = node.SyntaxTree;
span = ((SyntaxToken)(ref token)).Span;
diagnostics.Add((DiagnosticInfo?)(object)info, Location.Create(syntaxTree, new TextSpan(((TextSpan)(ref span)).End - 1, 1)));
}
}
else if (text.EndsWith("lu", StringComparison.Ordinal) || text.EndsWith("lU", StringComparison.Ordinal))
{
CSDiagnosticInfo info2 = new CSDiagnosticInfo(ErrorCode.WRN_LowercaseEllSuffix);
SyntaxTree syntaxTree2 = node.SyntaxTree;
span = ((SyntaxToken)(ref token)).Span;
diagnostics.Add((DiagnosticInfo?)(object)info2, Location.Create(syntaxTree2, new TextSpan(((TextSpan)(ref span)).End - 2, 1)));
}
}
token2 = node.Token;
object value = ((SyntaxToken)(ref token2)).Value;
TypeSymbol type = null;
ConstantValue constantValueOpt;
if (value == null)
{
constantValueOpt = ConstantValue.Null;
}
else
{
SpecialType val = SpecialTypeExtensions.FromRuntimeTypeOfLiteralValue(value);
constantValueOpt = ConstantValue.Create(value, val);
type = GetSpecialType(val, diagnostics, (SyntaxNode)(object)node);
}
SyntaxKind syntaxKind = node.Token.Kind();
if (syntaxKind - 8518 <= SyntaxKind.List)
{
MessageID.IDS_FeatureRawStringLiterals.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)node);
}
return new BoundLiteral((SyntaxNode)(object)node, constantValueOpt, type);
}
private BoundUtf8String BindUtf8StringLiteral(LiteralExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
SyntaxKind syntaxKind = node.Token.Kind();
if (syntaxKind - 8521 <= SyntaxKind.List)
{
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureRawStringLiterals, diagnostics);
}
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureUtf8StringLiterals, diagnostics);
SyntaxToken token = node.Token;
string value = (string)((SyntaxToken)(ref token)).Value;
NamedTypeSymbol type = GetWellKnownType((WellKnownType)276, diagnostics, (SyntaxNode)(object)node).Construct(GetSpecialType((SpecialType)10, diagnostics, (SyntaxNode)(object)node));
return new BoundUtf8String((SyntaxNode)(object)node, value, type);
}
private BoundExpression BindCheckedExpression(CheckedExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
return GetBinder((SyntaxNode)(object)node).BindParenthesizedExpression(node.Expression, diagnostics);
}
private BoundExpression BindMemberAccess(MemberAccessExpressionSyntax node, bool invoked, bool indexed, BindingDiagnosticBag diagnostics)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
ExpressionSyntax expression = node.Expression;
BoundExpression boundLeft;
if (node.Kind() == SyntaxKind.SimpleMemberAccessExpression)
{
boundLeft = BindLeftOfPotentialColorColorMemberAccess(expression, diagnostics);
}
else
{
boundLeft = BindRValueWithoutTargetType(expression, diagnostics);
BindPointerIndirectionExpressionInternal(node, boundLeft, diagnostics, out var pointedAtType, out var hasErrors);
boundLeft = (((object)pointedAtType != null) ? new BoundPointerIndirectionOperator((SyntaxNode)(object)expression, boundLeft, refersToLocation: false, pointedAtType, hasErrors)
{
WasCompilerGenerated = true
} : ToBadExpression(boundLeft));
}
return BindMemberAccessWithBoundLeft(node, boundLeft, node.Name, node.OperatorToken, invoked, indexed, diagnostics);
}
private BoundExpression BindLeftOfPotentialColorColorMemberAccess(ExpressionSyntax left, BindingDiagnosticBag diagnostics)
{
if (left is IdentifierNameSyntax left2)
{
return BindLeftIdentifierOfPotentialColorColorMemberAccess(left2, diagnostics);
}
return BindExpression(left, diagnostics);
}
[MethodImpl(MethodImplOptions.NoInlining)]
private BoundExpression BindLeftIdentifierOfPotentialColorColorMemberAccess(IdentifierNameSyntax left, BindingDiagnosticBag diagnostics)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Invalid comparison between Unknown and I4
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Invalid comparison between Unknown and I4
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Invalid comparison between Unknown and I4
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Invalid comparison between Unknown and I4
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Invalid comparison between Unknown and I4
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(diagnostics);
BoundExpression boundExpression = BindIdentifier(left, invoked: false, indexed: false, instance);
Symbol symbol = ((boundExpression.Kind != BoundKind.Conversion) ? boundExpression.ExpressionSymbol : ((BoundConversion)boundExpression).Operand.ExpressionSymbol);
if ((object)symbol != null)
{
SymbolKind kind = symbol.Kind;
if ((int)kind <= 8)
{
if ((int)kind == 6 || (int)kind == 8)
{
goto IL_0069;
}
}
else if ((int)kind == 13 || kind - 15 <= 1)
{
goto IL_0069;
}
}
goto IL_00ed;
IL_0069:
TypeSymbol type = boundExpression.Type;
SyntaxToken identifier = left.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
if (type.Name == valueText || IsUsingAliasInScope(valueText))
{
BindingDiagnosticBag instance2 = BindingDiagnosticBag.GetInstance(diagnostics);
BoundExpression boundExpression2 = BindNamespaceOrType(left, instance2);
if (TypeSymbol.Equals(boundExpression2.Type, type, (TypeCompareKind)63))
{
boundExpression = BindToNaturalType(boundExpression, instance);
return new BoundTypeOrValueExpression((SyntaxNode)(object)left, new BoundTypeOrValueData(symbol, boundExpression, ((BindingDiagnosticBag<AssemblySymbol>)(object)instance).ToReadOnlyAndFree(), boundExpression2, ((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).ToReadOnlyAndFree()), type);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).Free();
}
goto IL_00ed;
IL_00ed:
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRangeAndFree((BindingDiagnosticBag<AssemblySymbol>)(object)instance);
return boundExpression;
}
private bool IsPotentialColorColorReceiver(IdentifierNameSyntax id, TypeSymbol type)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken identifier = id.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
if (type.Name == valueText || IsUsingAliasInScope(valueText))
{
return TypeSymbol.Equals(BindNamespaceOrType(id, BindingDiagnosticBag.Discarded).Type, type, (TypeCompareKind)63);
}
return false;
}
private bool IsUsingAliasInScope(string name)
{
bool isSemanticModelBinder = IsSemanticModelBinder;
for (ImportChain importChain = ImportChain; importChain != null; importChain = importChain.ParentOpt)
{
if (IsUsingAlias(importChain.Imports.UsingAliases, name, isSemanticModelBinder))
{
return true;
}
}
return false;
}
private BoundExpression BindDynamicMemberAccess(ExpressionSyntax node, BoundExpression boundLeft, SimpleNameSyntax right, bool invoked, bool indexed, BindingDiagnosticBag diagnostics)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
SeparatedSyntaxList<TypeSyntax> typeArguments = (SeparatedSyntaxList<TypeSyntax>)((right.Kind() == SyntaxKind.GenericName) ? ((GenericNameSyntax)right).TypeArgumentList.Arguments : default(SeparatedSyntaxList<TypeSyntax>));
bool flag = typeArguments.Count > 0;
ImmutableArray<TypeWithAnnotations> immutableArray = (flag ? BindTypeArguments(typeArguments, diagnostics) : default(ImmutableArray<TypeWithAnnotations>));
bool hasErrors = false;
SyntaxToken identifier;
if (!invoked && flag)
{
object[] array = new object[2];
identifier = right.Identifier;
array[0] = ((SyntaxToken)(ref identifier)).Text;
array[1] = ((SymbolKind)15).Localize();
Error(diagnostics, ErrorCode.ERR_TypeArgsNotAllowed, (CSharpSyntaxNode)right, array);
hasErrors = true;
}
if (flag)
{
for (int i = 0; i < immutableArray.Length; i++)
{
TypeWithAnnotations typeWithAnnotations = immutableArray[i];
if (typeWithAnnotations.Type.IsPointerOrFunctionPointer() || typeWithAnnotations.Type.IsRestrictedType())
{
Error(diagnostics, ErrorCode.ERR_BadTypeArgument, (CSharpSyntaxNode)typeArguments[i], new object[1] { typeWithAnnotations.Type });
hasErrors = true;
}
}
}
ImmutableArray<TypeWithAnnotations> typeArgumentsOpt = immutableArray;
identifier = right.Identifier;
return new BoundDynamicMemberAccess((SyntaxNode)(object)node, boundLeft, typeArgumentsOpt, ((SyntaxToken)(ref identifier)).ValueText, invoked, indexed, Compilation.DynamicType, hasErrors);
}
private BoundExpression BindMemberAccessWithBoundLeft(ExpressionSyntax node, BoundExpression boundLeft, SimpleNameSyntax right, SyntaxToken operatorToken, bool invoked, bool indexed, BindingDiagnosticBag diagnostics)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
boundLeft = MakeMemberAccessValue(boundLeft, diagnostics);
TypeSymbol type = boundLeft.Type;
if ((object)type != null && type.IsDynamic())
{
boundLeft = CheckValue(boundLeft, BindValueKind.RValue, diagnostics);
return BindDynamicMemberAccess(node, boundLeft, right, invoked, indexed, diagnostics);
}
if ((object)type != null && type.IsVoidType())
{
diagnostics.Add(ErrorCode.ERR_BadUnaryOp, ((SyntaxToken)(ref operatorToken)).GetLocation(), SyntaxFacts.GetText(operatorToken.Kind()), type);
return BadExpression((SyntaxNode)(object)node, boundLeft);
}
if (boundLeft.IsLiteralDefault())
{
DiagnosticInfo info = (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, SyntaxFacts.GetText(operatorToken.Kind()), boundLeft.Display);
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic(info, ((SyntaxToken)(ref operatorToken)).GetLocation()));
return BadExpression((SyntaxNode)(object)node, boundLeft);
}
if (boundLeft.Kind == BoundKind.UnboundLambda)
{
MessageID messageID = ((UnboundLambda)boundLeft).MessageID;
diagnostics.Add(ErrorCode.ERR_BadUnaryOp, ((SyntaxNode)node).Location, SyntaxFacts.GetText(operatorToken.Kind()), messageID.Localize());
return BadExpression((SyntaxNode)(object)node, boundLeft);
}
boundLeft = BindToNaturalType(boundLeft, diagnostics);
type = boundLeft.Type;
LookupResult instance = LookupResult.GetInstance();
try
{
LookupOptions lookupOptions = LookupOptions.AllMethodsOnArityZero;
if (invoked)
{
lookupOptions |= LookupOptions.MustBeInvocableIfMember;
}
SeparatedSyntaxList<TypeSyntax> val = (SeparatedSyntaxList<TypeSyntax>)((right.Kind() == SyntaxKind.GenericName) ? ((GenericNameSyntax)right).TypeArgumentList.Arguments : default(SeparatedSyntaxList<TypeSyntax>));
ImmutableArray<TypeWithAnnotations> immutableArray = ((val.Count > 0) ? BindTypeArguments(val, diagnostics) : default(ImmutableArray<TypeWithAnnotations>));
SyntaxToken identifier = right.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
int arity = right.Arity;
switch (boundLeft.Kind)
{
case BoundKind.NamespaceExpression:
{
BoundExpression boundExpression = tryBindMemberAccessWithBoundNamespaceLeft(((BoundNamespaceExpression)boundLeft).NamespaceSymbol, node, boundLeft, right, diagnostics, instance, lookupOptions, val, immutableArray, valueText, arity);
if (boundExpression != null)
{
return boundExpression;
}
break;
}
case BoundKind.TypeExpression:
{
BoundExpression boundExpression = tryBindMemberAccessWithBoundTypeLeft(node, boundLeft, right, invoked, indexed, diagnostics, type, instance, lookupOptions, val, immutableArray, valueText, arity);
if (boundExpression != null)
{
return boundExpression;
}
break;
}
case BoundKind.TypeOrValueExpression:
return BindInstanceMemberAccess((SyntaxNode)(object)node, (SyntaxNode)(object)right, boundLeft, valueText, arity, val, immutableArray, invoked, indexed, diagnostics);
default:
if (boundLeft.Kind == BoundKind.Literal && ((BoundLiteral)boundLeft).ConstantValueOpt == ConstantValue.Null)
{
if (!boundLeft.HasAnyErrors)
{
Error(diagnostics, ErrorCode.ERR_BadUnaryOp, (CSharpSyntaxNode)node, new object[2]
{
((SyntaxToken)(ref operatorToken)).Text,
boundLeft.Display
});
}
return BadExpression((SyntaxNode)(object)node, boundLeft);
}
if ((object)type != null)
{
boundLeft = CheckValue(boundLeft, BindValueKind.RValue, diagnostics);
boundLeft = BindToNaturalType(boundLeft, diagnostics);
return BindInstanceMemberAccess((SyntaxNode)(object)node, (SyntaxNode)(object)right, boundLeft, valueText, arity, val, immutableArray, invoked, indexed, diagnostics);
}
break;
}
BindMemberAccessReportError((SyntaxNode)(object)node, (SyntaxNode)(object)right, valueText, boundLeft, instance.Error, diagnostics);
return BindMemberAccessBadResult((SyntaxNode)(object)node, valueText, boundLeft, instance.Error, instance.Symbols.ToImmutable(), instance.Kind);
}
finally
{
instance.Free();
}
[MethodImpl(MethodImplOptions.NoInlining)]
BoundExpression tryBindMemberAccessWithBoundNamespaceLeft(NamespaceSymbol ns, ExpressionSyntax expressionSyntax, BoundExpression item, SimpleNameSyntax simpleNameSyntax, BindingDiagnosticBag bindingDiagnosticBag, LookupResult lookupResult, LookupOptions options, SeparatedSyntaxList<TypeSyntax> typeArgumentsSyntax, ImmutableArray<TypeWithAnnotations> typeArguments, string rightName, int rightArity)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Invalid comparison between Unknown and I4
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(bindingDiagnosticBag);
LookupMembersWithFallback(lookupResult, ns, rightName, rightArity, ref useSiteInfo, null, options);
((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag).Add((SyntaxNode)(object)simpleNameSyntax, useSiteInfo);
ArrayBuilder<Symbol> symbols = lookupResult.Symbols;
if (lookupResult.IsMultiViable)
{
bool wasError;
Symbol symbol = ResultSymbol(lookupResult, rightName, rightArity, (SyntaxNode)(object)expressionSyntax, bindingDiagnosticBag, suppressUseSiteDiagnostics: false, out wasError, ns, options);
if (wasError)
{
return new BoundBadExpression((SyntaxNode)(object)expressionSyntax, LookupResultKind.Ambiguous, ImmutableArrayExtensions.AsImmutable<Symbol>((IEnumerable<Symbol>)lookupResult.Symbols), ImmutableArray.Create(item), CreateErrorType(rightName), hasErrors: true);
}
if ((int)symbol.Kind == 12)
{
return new BoundNamespaceExpression((SyntaxNode)(object)expressionSyntax, (NamespaceSymbol)symbol);
}
NamedTypeSymbol namedTypeSymbol = (NamedTypeSymbol)symbol;
if (!typeArguments.IsDefault)
{
namedTypeSymbol = ConstructNamedTypeUnlessTypeArgumentOmitted((SyntaxNode)(object)simpleNameSyntax, namedTypeSymbol, typeArgumentsSyntax, typeArguments, bindingDiagnosticBag);
}
ReportDiagnosticsIfObsolete(bindingDiagnosticBag, namedTypeSymbol, SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)expressionSyntax), hasBaseReceiver: false);
return new BoundTypeExpression((SyntaxNode)(object)expressionSyntax, null, namedTypeSymbol);
}
if (lookupResult.Kind == LookupResultKind.WrongArity)
{
Error(bindingDiagnosticBag, lookupResult.Error, (SyntaxNode)(object)simpleNameSyntax);
return new BoundTypeExpression((SyntaxNode)(object)expressionSyntax, null, new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(symbols[0]), symbols.ToImmutable(), lookupResult.Kind, lookupResult.Error, rightArity));
}
if (lookupResult.Kind == LookupResultKind.Empty)
{
NotFound((SyntaxNode)(object)expressionSyntax, rightName, rightArity, rightName, bindingDiagnosticBag, null, ns, options);
return new BoundBadExpression((SyntaxNode)(object)expressionSyntax, lookupResult.Kind, ImmutableArrayExtensions.AsImmutable<Symbol>((IEnumerable<Symbol>)symbols), ImmutableArray.Create(item), CreateErrorType(rightName), hasErrors: true);
}
return null;
}
[MethodImpl(MethodImplOptions.NoInlining)]
BoundExpression tryBindMemberAccessWithBoundTypeLeft(ExpressionSyntax expressionSyntax, BoundExpression boundExpression2, SimpleNameSyntax simpleNameSyntax, bool invoked2, bool indexed2, BindingDiagnosticBag bindingDiagnosticBag, TypeSymbol leftType, LookupResult lookupResult, LookupOptions options, SeparatedSyntaxList<TypeSyntax> typeArgumentsSyntax, ImmutableArray<TypeWithAnnotations> typeArguments, string rightName, int rightArity)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: 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_008c: Unknown result type (might be due to invalid IL or missing references)
if ((int)leftType.TypeKind == 11)
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(bindingDiagnosticBag);
LookupMembersWithFallback(lookupResult, leftType, rightName, rightArity, ref useSiteInfo, null, options | LookupOptions.MustNotBeInstance | LookupOptions.MustBeAbstractOrVirtual);
((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag).Add((SyntaxNode)(object)simpleNameSyntax, useSiteInfo);
if (lookupResult.IsMultiViable)
{
CheckFeatureAvailability(boundExpression2.Syntax, MessageID.IDS_FeatureStaticAbstractMembersInInterfaces, bindingDiagnosticBag);
return BindMemberOfType((SyntaxNode)(object)expressionSyntax, (SyntaxNode)(object)simpleNameSyntax, rightName, rightArity, indexed2, boundExpression2, typeArgumentsSyntax, typeArguments, lookupResult, BoundMethodGroupFlags.None, bindingDiagnosticBag);
}
if (lookupResult.IsClear)
{
Error(bindingDiagnosticBag, ErrorCode.ERR_LookupInTypeVariable, SyntaxNodeOrToken.op_Implicit(boundExpression2.Syntax), leftType);
return BadExpression((SyntaxNode)(object)expressionSyntax, LookupResultKind.NotAValue, boundExpression2);
}
}
else
{
if ((object)EnclosingNameofArgument == expressionSyntax)
{
return BindInstanceMemberAccess((SyntaxNode)(object)expressionSyntax, (SyntaxNode)(object)simpleNameSyntax, boundExpression2, rightName, rightArity, typeArgumentsSyntax, typeArguments, invoked2, indexed2, bindingDiagnosticBag);
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo2 = GetNewCompoundUseSiteInfo(bindingDiagnosticBag);
LookupMembersWithFallback(lookupResult, leftType, rightName, rightArity, ref useSiteInfo2, null, options);
((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag).Add((SyntaxNode)(object)simpleNameSyntax, useSiteInfo2);
if (lookupResult.IsMultiViable)
{
return BindMemberOfType((SyntaxNode)(object)expressionSyntax, (SyntaxNode)(object)simpleNameSyntax, rightName, rightArity, indexed2, boundExpression2, typeArgumentsSyntax, typeArguments, lookupResult, BoundMethodGroupFlags.None, bindingDiagnosticBag);
}
}
return null;
}
}
private void WarnOnAccessOfOffDefault(SyntaxNode node, BoundExpression boundLeft, BindingDiagnosticBag diagnostics)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
if ((boundLeft is BoundDefaultLiteral || boundLeft is BoundDefaultExpression) && boundLeft.ConstantValueOpt == ConstantValue.Null && Compilation.LanguageVersion < MessageID.IDS_FeatureNullableReferenceTypes.RequiredVersion())
{
Error(diagnostics, ErrorCode.WRN_DotOnDefault, SyntaxNodeOrToken.op_Implicit(node), boundLeft.Type);
}
}
private BoundExpression MakeMemberAccessValue(BoundExpression expr, BindingDiagnosticBag diagnostics)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
switch (expr.Kind)
{
case BoundKind.MethodGroup:
{
BoundMethodGroup boundMethodGroup = (BoundMethodGroup)expr;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
MethodGroupResolution methodGroupResolution = ResolveMethodGroup(boundMethodGroup, null, isMethodGroupConversion: false, ref useSiteInfo, inferWithDynamic: false, (RefKind)0, null, isFunctionPointerResolution: false, default(CallingConventionInfo));
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(expr.Syntax, useSiteInfo);
if (!expr.HasAnyErrors)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(methodGroupResolution.Diagnostics, false);
if (methodGroupResolution.MethodGroup != null && !methodGroupResolution.HasAnyErrors)
{
MethodSymbol methodSymbol = methodGroupResolution.MethodGroup.Methods[0];
Error(diagnostics, ErrorCode.ERR_BadSKunknown, SyntaxNodeOrToken.op_Implicit(boundMethodGroup.NameSyntax), methodSymbol, MessageID.IDS_SK_METHOD.Localize());
}
}
expr = BindMemberAccessBadResult(boundMethodGroup);
methodGroupResolution.Free();
return expr;
}
case BoundKind.PropertyGroup:
return BindIndexedPropertyAccess((BoundPropertyGroup)expr, mustHaveAllOptionalParameters: false, diagnostics);
default:
return BindToNaturalType(expr, diagnostics);
}
}
private BoundExpression BindInstanceMemberAccess(SyntaxNode node, SyntaxNode right, BoundExpression boundLeft, string rightName, int rightArity, SeparatedSyntaxList<TypeSyntax> typeArgumentsSyntax, ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations, bool invoked, bool indexed, BindingDiagnosticBag diagnostics, bool searchExtensionMethodsIfNecessary = true)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
TypeSymbol type = boundLeft.Type;
LookupResult instance = LookupResult.GetInstance();
try
{
bool flag = boundLeft.Kind == BoundKind.BaseReference;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupInstanceMember(instance, type, flag, rightName, rightArity, invoked, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(right, useSiteInfo);
searchExtensionMethodsIfNecessary = searchExtensionMethodsIfNecessary && !flag;
BoundMethodGroupFlags boundMethodGroupFlags = BoundMethodGroupFlags.None;
if (searchExtensionMethodsIfNecessary)
{
boundMethodGroupFlags |= BoundMethodGroupFlags.SearchExtensionMethods;
}
if (instance.IsMultiViable)
{
return BindMemberOfType(node, right, rightName, rightArity, indexed, boundLeft, typeArgumentsSyntax, typeArgumentsWithAnnotations, instance, boundMethodGroupFlags, diagnostics);
}
if (searchExtensionMethodsIfNecessary)
{
BoundExpression valueExpressionIfTypeOrValueReceiver = GetValueExpressionIfTypeOrValueReceiver(boundLeft);
if (IsPossiblyCapturingPrimaryConstructorParameterReference(valueExpressionIfTypeOrValueReceiver, out var _))
{
boundLeft = ReplaceTypeOrValueReceiver(boundLeft, useType: false, diagnostics);
}
BoundMethodGroup boundMethodGroup = new BoundMethodGroup(node, typeArgumentsWithAnnotations, boundLeft, rightName, ArrayBuilderExtensions.All<Symbol>(instance.Symbols, (Func<Symbol, bool>)((Symbol s) => (int)s.Kind == 9)) ? ArrayBuilderExtensions.SelectAsArray<Symbol, MethodSymbol>(instance.Symbols, s_toMethodSymbolFunc) : ImmutableArray<MethodSymbol>.Empty, instance, boundMethodGroupFlags, this);
if (!boundMethodGroup.HasErrors && typeArgumentsSyntax.Any<TypeSyntax>(SyntaxKind.OmittedTypeArgument))
{
Error(diagnostics, ErrorCode.ERR_OmittedTypeArgument, SyntaxNodeOrToken.op_Implicit(node));
}
return boundMethodGroup;
}
BindMemberAccessReportError(node, right, rightName, boundLeft, instance.Error, diagnostics);
return BindMemberAccessBadResult(node, rightName, boundLeft, instance.Error, instance.Symbols.ToImmutable(), instance.Kind);
}
finally
{
instance.Free();
}
}
private void LookupInstanceMember(LookupResult lookupResult, TypeSymbol leftType, bool leftIsBaseReference, string rightName, int rightArity, bool invoked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
LookupOptions lookupOptions = LookupOptions.AllMethodsOnArityZero;
if (invoked)
{
lookupOptions |= LookupOptions.MustBeInvocableIfMember;
}
if (leftIsBaseReference)
{
lookupOptions |= LookupOptions.UseBaseReferenceAccessibility;
}
LookupMembersWithFallback(lookupResult, leftType, rightName, rightArity, ref useSiteInfo, null, lookupOptions);
}
private void BindMemberAccessReportError(BoundMethodGroup node, BindingDiagnosticBag diagnostics)
{
SyntaxNode nameSyntax = node.NameSyntax;
SyntaxNode node2 = (SyntaxNode)(((object)node.MemberAccessExpressionSyntax) ?? ((object)nameSyntax));
BindMemberAccessReportError(node2, nameSyntax, node.Name, node.ReceiverOpt, node.LookupError, diagnostics);
}
private void BindMemberAccessReportError(SyntaxNode node, SyntaxNode name, string plainName, BoundExpression boundLeft, DiagnosticInfo lookupError, BindingDiagnosticBag diagnostics)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
if (!boundLeft.HasAnyErrors || boundLeft.Kind == BoundKind.TypeOrValueExpression)
{
if (lookupError != null)
{
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic(lookupError, name.Location));
}
else if (node.IsQuery())
{
ReportQueryLookupFailed(node, boundLeft, plainName, ImmutableArray<Symbol>.Empty, diagnostics);
}
else if ((object)boundLeft.Type == null)
{
Error(diagnostics, ErrorCode.ERR_NoSuchMember, SyntaxNodeOrToken.op_Implicit(name), boundLeft.Display, plainName);
}
else if (boundLeft.Kind == BoundKind.TypeExpression || boundLeft.Kind == BoundKind.BaseReference || (node.Kind() == SyntaxKind.AwaitExpression && plainName == "GetResult"))
{
Error(diagnostics, ErrorCode.ERR_NoSuchMember, SyntaxNodeOrToken.op_Implicit(name), boundLeft.Type, plainName);
}
else if (WouldUsingSystemFindExtension(boundLeft.Type, plainName))
{
Error(diagnostics, ErrorCode.ERR_NoSuchMemberOrExtensionNeedUsing, SyntaxNodeOrToken.op_Implicit(name), boundLeft.Type, plainName, "System");
}
else
{
Error(diagnostics, ErrorCode.ERR_NoSuchMemberOrExtension, SyntaxNodeOrToken.op_Implicit(name), boundLeft.Type, plainName);
}
}
}
private bool WouldUsingSystemFindExtension(TypeSymbol receiver, string methodName)
{
if (methodName == "GetAwaiter")
{
return ImplementsWinRTAsyncInterface(receiver);
}
return false;
}
private bool ImplementsWinRTAsyncInterface(TypeSymbol type)
{
if (!IsWinRTAsyncInterface(type))
{
return ImmutableArrayExtensions.Any<NamedTypeSymbol, Binder>(type.AllInterfacesNoUseSiteDiagnostics, (Func<NamedTypeSymbol, Binder, bool>)((NamedTypeSymbol i, Binder self) => self.IsWinRTAsyncInterface(i)), this);
}
return true;
}
private bool IsWinRTAsyncInterface(TypeSymbol type)
{
if (!type.IsInterfaceType())
{
return false;
}
NamedTypeSymbol constructedFrom = ((NamedTypeSymbol)type).ConstructedFrom;
if (!TypeSymbol.Equals(constructedFrom, Compilation.GetWellKnownType((WellKnownType)187), (TypeCompareKind)0) && !TypeSymbol.Equals(constructedFrom, Compilation.GetWellKnownType((WellKnownType)188), (TypeCompareKind)0) && !TypeSymbol.Equals(constructedFrom, Compilation.GetWellKnownType((WellKnownType)189), (TypeCompareKind)0))
{
return TypeSymbol.Equals(constructedFrom, Compilation.GetWellKnownType((WellKnownType)190), (TypeCompareKind)0);
}
return true;
}
private BoundExpression BindMemberAccessBadResult(BoundMethodGroup node)
{
SyntaxNode nameSyntax = node.NameSyntax;
SyntaxNode node2 = (SyntaxNode)(((object)node.MemberAccessExpressionSyntax) ?? ((object)nameSyntax));
return BindMemberAccessBadResult(node2, node.Name, node.ReceiverOpt, node.LookupError, StaticCast<Symbol>.From<MethodSymbol>(node.Methods), node.ResultKind);
}
private BoundExpression BindMemberAccessBadResult(SyntaxNode node, string nameString, BoundExpression boundLeft, DiagnosticInfo lookupError, ImmutableArray<Symbol> symbols, LookupResultKind lookupKind)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Invalid comparison between Unknown and I4
if (symbols.Length > 0 && (int)symbols[0].Kind == 9)
{
ArrayBuilder<MethodSymbol> instance = ArrayBuilder<MethodSymbol>.GetInstance();
ImmutableArray<Symbol>.Enumerator enumerator = symbols.GetEnumerator();
while (enumerator.MoveNext())
{
if (enumerator.Current is MethodSymbol methodSymbol)
{
instance.Add(methodSymbol);
}
}
ImmutableArray<MethodSymbol> methods = instance.ToImmutableAndFree();
return new BoundMethodGroup(node, default(ImmutableArray<TypeWithAnnotations>), nameString, methods, (methods.Length == 1) ? methods[0] : null, lookupError, BoundMethodGroupFlags.None, null, boundLeft, lookupKind, hasErrors: true);
}
Symbol symbol = ((symbols.Length == 1) ? symbols[0] : null);
return new BoundBadExpression(node, lookupKind, ((object)symbol == null) ? ImmutableArray<Symbol>.Empty : ImmutableArray.Create(symbol), (boundLeft == null) ? ImmutableArray<BoundExpression>.Empty : ImmutableArray.Create(BindToTypeForErrorRecovery(boundLeft)), GetNonMethodMemberType(symbol));
}
private TypeSymbol GetNonMethodMemberType(Symbol symbolOpt)
{
//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)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Invalid comparison between Unknown and I4
TypeSymbol typeSymbol = null;
if ((object)symbolOpt != null)
{
SymbolKind kind = symbolOpt.Kind;
if ((int)kind != 5)
{
if ((int)kind != 6)
{
if ((int)kind == 15)
{
typeSymbol = ((PropertySymbol)symbolOpt).Type;
}
}
else
{
typeSymbol = ((FieldSymbol)symbolOpt).GetFieldType(FieldsBeingBound).Type;
}
}
else
{
typeSymbol = ((EventSymbol)symbolOpt).Type;
}
}
return typeSymbol ?? CreateErrorType();
}
private static void CombineExtensionMethodArguments(BoundExpression receiver, AnalyzedArguments originalArguments, AnalyzedArguments extensionMethodArguments)
{
extensionMethodArguments.IsExtensionMethodInvocation = true;
extensionMethodArguments.Arguments.Add(receiver);
extensionMethodArguments.Arguments.AddRange(originalArguments.Arguments);
if (originalArguments.Names.Count > 0)
{
extensionMethodArguments.Names.Add(((string, Location)?)null);
extensionMethodArguments.Names.AddRange(originalArguments.Names);
}
if (originalArguments.RefKinds.Count > 0)
{
extensionMethodArguments.RefKinds.Add((RefKind)0);
extensionMethodArguments.RefKinds.AddRange(originalArguments.RefKinds);
}
}
private BoundExpression BindMemberOfType(SyntaxNode node, SyntaxNode right, string plainName, int arity, bool indexed, BoundExpression left, SeparatedSyntaxList<TypeSyntax> typeArgumentsSyntax, ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations, LookupResult lookupResult, BoundMethodGroupFlags methodGroupFlags, BindingDiagnosticBag diagnostics)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Invalid comparison between Unknown and I4
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Invalid comparison between Unknown and I4
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Invalid comparison between Unknown and I4
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected I4, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Invalid comparison between Unknown and I4
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Invalid comparison between Unknown and I4
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
ArrayBuilder<Symbol> instance = ArrayBuilder<Symbol>.GetInstance();
bool wasError;
Symbol symbolOrMethodOrPropertyGroup = GetSymbolOrMethodOrPropertyGroup(lookupResult, right, plainName, arity, instance, diagnostics, out wasError, (left is BoundTypeExpression boundTypeExpression) ? boundTypeExpression.Type : null);
BoundExpression result;
if ((object)symbolOrMethodOrPropertyGroup == null)
{
result = ConstructBoundMemberGroupAndReportOmittedTypeArguments(node, typeArgumentsSyntax, typeArgumentsWithAnnotations, left, plainName, instance, lookupResult, methodGroupFlags, wasError, diagnostics);
}
else
{
left = ReplaceTypeOrValueReceiver(left, symbolOrMethodOrPropertyGroup.IsStatic || (int)symbolOrMethodOrPropertyGroup.Kind == 11, diagnostics);
SymbolKind kind = symbolOrMethodOrPropertyGroup.Kind;
if (((int)kind != 5 && (int)kind != 15) || 1 == 0)
{
ReportDiagnosticsIfObsolete(diagnostics, symbolOrMethodOrPropertyGroup, SyntaxNodeOrToken.op_Implicit(node), left.Kind == BoundKind.BaseReference);
}
kind = symbolOrMethodOrPropertyGroup.Kind;
switch (kind - 4)
{
default:
if ((int)kind != 11)
{
if ((int)kind == 15)
{
result = BindPropertyAccess(node, left, (PropertySymbol)symbolOrMethodOrPropertyGroup, diagnostics, lookupResult.Kind, wasError);
break;
}
throw ExceptionUtilities.UnexpectedValue((object)symbolOrMethodOrPropertyGroup.Kind);
}
goto case 0;
case 0:
{
if (IsInstanceReceiver(left) == true && !wasError)
{
Error(diagnostics, ErrorCode.ERR_BadTypeReference, SyntaxNodeOrToken.op_Implicit(right), plainName, symbolOrMethodOrPropertyGroup);
wasError = true;
}
NamedTypeSymbol namedTypeSymbol = (NamedTypeSymbol)symbolOrMethodOrPropertyGroup;
if (!typeArgumentsWithAnnotations.IsDefault)
{
namedTypeSymbol = ConstructNamedTypeUnlessTypeArgumentOmitted(right, namedTypeSymbol, typeArgumentsSyntax, typeArgumentsWithAnnotations, diagnostics);
}
result = new BoundTypeExpression(node, null, left as BoundTypeExpression, ImmutableArray<BoundExpression>.Empty, TypeWithAnnotations.Create(namedTypeSymbol));
break;
}
case 1:
result = BindEventAccess(node, left, (EventSymbol)symbolOrMethodOrPropertyGroup, diagnostics, lookupResult.Kind, wasError);
break;
case 2:
result = BindFieldAccess(node, left, (FieldSymbol)symbolOrMethodOrPropertyGroup, diagnostics, lookupResult.Kind, indexed, wasError);
break;
}
}
instance.Free();
return result;
}
protected MethodGroupResolution BindExtensionMethod(SyntaxNode expression, string methodName, AnalyzedArguments analyzedArguments, BoundExpression left, ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations, bool isMethodGroupConversion, RefKind returnRefKind, TypeSymbol returnType, bool withDependencies)
{
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
MethodGroupResolution result = default(MethodGroupResolution);
AnalyzedArguments analyzedArguments2 = null;
ExtensionMethodScopeEnumerator enumerator = new ExtensionMethodScopes(this).GetEnumerator();
while (enumerator.MoveNext())
{
ExtensionMethodScope current = enumerator.Current;
MethodGroup instance = MethodGroup.GetInstance();
BindingDiagnosticBag instance2 = BindingDiagnosticBag.GetInstance(withDiagnostics: true, withDependencies);
PopulateExtensionMethodsFromSingleBinder(current, instance, expression, left, methodName, typeArgumentsWithAnnotations, instance2);
if (analyzedArguments == null)
{
if (expression == EnclosingNameofArgument)
{
for (int num = instance.Methods.Count - 1; num >= 0; num--)
{
if ((object)instance.Methods[num].ReduceExtensionMethod(left.Type, Compilation) == null)
{
instance.Methods.RemoveAt(num);
}
}
}
if (instance.Methods.Count != 0)
{
return new MethodGroupResolution(instance, ((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).ToReadOnlyAndFree());
}
}
if (instance.Methods.Count == 0)
{
instance.Free();
((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).Free();
continue;
}
if (analyzedArguments2 == null)
{
analyzedArguments2 = AnalyzedArguments.GetInstance();
CombineExtensionMethodArguments(left, analyzedArguments, analyzedArguments2);
}
OverloadResolutionResult<MethodSymbol> instance3 = OverloadResolutionResult<MethodSymbol>.GetInstance();
bool allowRefOmittedArguments = instance.Receiver.IsExpressionOfComImportType();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(instance2);
OverloadResolution.MethodInvocationOverloadResolution(instance.Methods, instance.TypeArguments, instance.Receiver, analyzedArguments2, instance3, ref useSiteInfo, isMethodGroupConversion, allowRefOmittedArguments, inferWithDynamic: false, allowUnexpandedForm: true, returnRefKind, returnType, isFunctionPointerResolution: false, isExtensionMethodResolution: true, default(CallingConventionInfo));
((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).Add(expression, useSiteInfo);
ImmutableBindingDiagnostic<AssemblySymbol> diagnostics = ((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).ToReadOnlyAndFree();
MethodGroupResolution methodGroupResolution = new MethodGroupResolution(instance, null, instance3, AnalyzedArguments.GetInstance(analyzedArguments2), instance.ResultKind, diagnostics);
if (methodGroupResolution.HasAnyApplicableMethod)
{
if (!result.IsEmpty)
{
result.MethodGroup.Free();
result.OverloadResolutionResult.Free();
}
return methodGroupResolution;
}
if (result.IsEmpty)
{
result = methodGroupResolution;
continue;
}
instance3.Free();
instance.Free();
}
analyzedArguments2?.Free();
return result;
}
private void PopulateExtensionMethodsFromSingleBinder(ExtensionMethodScope scope, MethodGroup methodGroup, SyntaxNode node, BoundExpression left, string rightName, ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations, BindingDiagnosticBag diagnostics)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
int arity = ((!typeArgumentsWithAnnotations.IsDefault) ? typeArgumentsWithAnnotations.Length : 0);
LookupResult instance = LookupResult.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupExtensionMethods(instance, scope, rightName, arity, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
if (instance.IsMultiViable)
{
ArrayBuilder<Symbol> instance2 = ArrayBuilder<Symbol>.GetInstance();
GetSymbolOrMethodOrPropertyGroup(instance, node, rightName, arity, instance2, diagnostics, out var _, null);
methodGroup.PopulateWithExtensionMethods(left, instance2, typeArgumentsWithAnnotations, instance.Kind);
instance2.Free();
}
instance.Free();
}
private void LookupExtensionMethods(LookupResult lookupResult, ExtensionMethodScope scope, string rightName, int arity, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
LookupOptions options = ((arity == 0) ? LookupOptions.AllMethodsOnArityZero : LookupOptions.Default);
LookupExtensionMethodsInSingleBinder(scope, lookupResult, rightName, arity, options, ref useSiteInfo);
}
protected BoundExpression BindFieldAccess(SyntaxNode node, BoundExpression receiver, FieldSymbol fieldSymbol, BindingDiagnosticBag diagnostics, LookupResultKind resultKind, bool indexed, bool hasErrors)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
NamedTypeSymbol containingType = fieldSymbol.ContainingType;
bool flag2 = fieldSymbol.IsStatic && containingType.IsEnumType();
if (flag2 && !containingType.IsValidEnumType())
{
Error(diagnostics, ErrorCode.ERR_BindToBogus, SyntaxNodeOrToken.op_Implicit(node), fieldSymbol);
flag = true;
}
if (!flag)
{
flag = CheckInstanceOrStatic(node, receiver, fieldSymbol, ref resultKind, diagnostics);
}
if (!flag && fieldSymbol.IsFixedSizeBuffer && !IsInsideNameof)
{
TypeSymbol type = receiver.Type;
flag = (object)type == null || !type.IsValueType;
if (!flag)
{
bool flag3 = SyntaxFacts.IsFixedStatementExpression(node);
if (IsMoveableVariable(receiver, out var _) != flag3)
{
if (indexed)
{
CheckFeatureAvailability(node, MessageID.IDS_FeatureIndexingMovableFixedBuffers, diagnostics);
}
else
{
Error(diagnostics, flag3 ? ErrorCode.ERR_FixedNotNeeded : ErrorCode.ERR_FixedBufferNotFixed, SyntaxNodeOrToken.op_Implicit(node));
hasErrors = (flag = true);
}
}
}
if (!flag)
{
flag = !CheckValueKind(node, receiver, BindValueKind.FixedReceiver, checkingReceiver: false, diagnostics);
}
}
ConstantValue val = null;
if (fieldSymbol.IsConst && !IsInsideNameof)
{
val = fieldSymbol.GetConstantValue(ConstantFieldsInProgress, IsEarlyAttributeBinder);
if (val == ConstantValue.Unset)
{
val = ConstantValue.Bad;
}
}
if (!fieldSymbol.IsStatic)
{
WarnOnAccessOfOffDefault(node, receiver, diagnostics);
}
if (!IsBadBaseAccess(node, receiver, fieldSymbol, diagnostics))
{
CheckReceiverAndRuntimeSupportForSymbolAccess(node, receiver, fieldSymbol, diagnostics);
}
if ((object)Compilation.SourceModule != fieldSymbol.OriginalDefinition.ContainingModule && (int)fieldSymbol.RefKind != 0)
{
CheckFeatureAvailability(node, MessageID.IDS_FeatureRefFields, diagnostics);
if (!Compilation.Assembly.RuntimeSupportsByRefFields)
{
diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportRefFields, node.Location);
}
}
TypeSymbol type2 = fieldSymbol.GetFieldType(FieldsBeingBound).Type;
BoundExpression boundExpression = new BoundFieldAccess(node, receiver, fieldSymbol, val, resultKind, type2, hasErrors || flag);
if (InEnumMemberInitializer())
{
NamedTypeSymbol namedTypeSymbol = null;
if (flag2)
{
namedTypeSymbol = containingType;
}
else if (val != (ConstantValue)null && type2.IsEnumType())
{
namedTypeSymbol = (NamedTypeSymbol)type2;
}
if ((object)namedTypeSymbol != null)
{
NamedTypeSymbol enumUnderlyingType = namedTypeSymbol.EnumUnderlyingType;
boundExpression = new BoundConversion(node, boundExpression, Conversion.ImplicitNumeric, @checked: true, explicitCastInCode: false, null, boundExpression.ConstantValueOpt, enumUnderlyingType);
}
}
return boundExpression;
}
private bool InEnumMemberInitializer()
{
NamedTypeSymbol containingType = ContainingType;
if (InFieldInitializer && (object)containingType != null)
{
return containingType.IsEnumType();
}
return false;
}
private BoundExpression BindPropertyAccess(SyntaxNode node, BoundExpression? receiver, PropertySymbol propertySymbol, BindingDiagnosticBag diagnostics, LookupResultKind lookupResult, bool hasErrors)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
ReportDiagnosticsIfObsolete(diagnostics, propertySymbol, SyntaxNodeOrToken.op_Implicit(node), receiver != null && receiver.Kind == BoundKind.BaseReference);
bool flag = CheckInstanceOrStatic(node, receiver, propertySymbol, ref lookupResult, diagnostics);
if (!propertySymbol.IsStatic)
{
WarnOnAccessOfOffDefault(node, receiver, diagnostics);
}
return new BoundPropertyAccess(node, receiver, ReceiverIsSubjectToCloning(receiver, propertySymbol), propertySymbol, lookupResult, propertySymbol.Type, hasErrors || flag);
}
private void CheckReceiverAndRuntimeSupportForSymbolAccess(SyntaxNode node, BoundExpression receiverOpt, Symbol symbol, BindingDiagnosticBag diagnostics)
{
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Invalid comparison between Unknown and I4
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Invalid comparison between Unknown and I4
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Invalid comparison between Unknown and I4
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol containingType = symbol.ContainingType;
if ((object)containingType == null || !containingType.IsInterface)
{
return;
}
if (symbol.IsStatic && (symbol.IsAbstract || symbol.IsVirtual))
{
if (receiverOpt is BoundQueryClause boundQueryClause)
{
BoundExpression value = boundQueryClause.Value;
receiverOpt = value;
}
if (receiverOpt is BoundTypeExpression boundTypeExpression)
{
TypeSymbol type = boundTypeExpression.Type;
if ((object)type != null && (int)type.TypeKind == 11)
{
if (!Compilation.Assembly.RuntimeSupportsStaticAbstractMembersInInterfaces && Compilation.SourceModule != symbol.ContainingModule)
{
Error(diagnostics, ErrorCode.ERR_RuntimeDoesNotSupportStaticAbstractMembersInInterfaces, SyntaxNodeOrToken.op_Implicit(node));
return;
}
goto IL_00b7;
}
}
Error(diagnostics, ErrorCode.ERR_BadAbstractStaticMemberAccess, SyntaxNodeOrToken.op_Implicit(node));
return;
}
goto IL_00b7;
IL_00b7:
if (Compilation.Assembly.RuntimeSupportsDefaultInterfaceImplementation || !(Compilation.SourceModule != symbol.ContainingModule))
{
return;
}
if (!symbol.IsStatic && !(symbol is TypeSymbol) && !symbol.IsImplementableInterfaceMember())
{
Error(diagnostics, ErrorCode.ERR_RuntimeDoesNotSupportDefaultInterfaceImplementation, SyntaxNodeOrToken.op_Implicit(node));
return;
}
Accessibility declaredAccessibility = symbol.DeclaredAccessibility;
if (declaredAccessibility - 2 <= 1 || (int)declaredAccessibility == 5)
{
Error(diagnostics, ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, SyntaxNodeOrToken.op_Implicit(node));
}
}
private BoundExpression BindEventAccess(SyntaxNode node, BoundExpression receiver, EventSymbol eventSymbol, BindingDiagnosticBag diagnostics, LookupResultKind lookupResult, bool hasErrors)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
bool isUsableAsField = eventSymbol.HasAssociatedField && IsAccessible(eventSymbol.AssociatedField, ref useSiteInfo, receiver?.Type);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
bool flag = CheckInstanceOrStatic(node, receiver, eventSymbol, ref lookupResult, diagnostics);
if (!eventSymbol.IsStatic)
{
WarnOnAccessOfOffDefault(node, receiver, diagnostics);
}
return new BoundEventAccess(node, receiver, eventSymbol, isUsableAsField, lookupResult, eventSymbol.Type, hasErrors || flag);
}
private static bool? IsInstanceReceiver(BoundExpression receiver)
{
if (receiver == null)
{
return false;
}
return receiver.Kind switch
{
BoundKind.PreviousSubmissionReference => null,
BoundKind.TypeExpression => false,
BoundKind.QueryClause => IsInstanceReceiver(((BoundQueryClause)receiver).Value),
_ => true,
};
}
private bool CheckInstanceOrStatic(SyntaxNode node, BoundExpression receiver, Symbol symbol, ref LookupResultKind resultKind, BindingDiagnosticBag diagnostics)
{
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
bool? flag = IsInstanceReceiver(receiver);
if (!symbol.RequiresInstanceReceiver())
{
if (flag == true)
{
if (!IsInsideNameof)
{
ErrorCode code = (Flags.Includes(BinderFlags.ObjectInitializerMember) ? ErrorCode.ERR_StaticMemberInObjectInitializer : ErrorCode.ERR_ObjectProhibited);
Error(diagnostics, code, SyntaxNodeOrToken.op_Implicit(node), symbol);
}
else if (CheckFeatureAvailability(node, MessageID.IDS_FeatureInstanceMemberInNameof, diagnostics))
{
return false;
}
resultKind = LookupResultKind.StaticInstanceMismatch;
return true;
}
}
else if (flag == false && !IsInsideNameof)
{
Error(diagnostics, ErrorCode.ERR_ObjectRequired, SyntaxNodeOrToken.op_Implicit(node), symbol);
resultKind = LookupResultKind.StaticInstanceMismatch;
return true;
}
return false;
}
private Symbol GetSymbolOrMethodOrPropertyGroup(LookupResult result, SyntaxNode node, string plainName, int arity, ArrayBuilder<Symbol> methodOrPropertyGroup, BindingDiagnosticBag diagnostics, out bool wasError, NamespaceOrTypeSymbol qualifierOpt)
{
//IL_0019: 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_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Invalid comparison between Unknown and I4
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Invalid comparison between Unknown and I4
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Invalid comparison between Unknown and I4
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Invalid comparison between Unknown and I4
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Invalid comparison between Unknown and I4
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Invalid comparison between Unknown and I4
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Invalid comparison between Unknown and I4
node = (SyntaxNode)(((object)GetNameSyntax(node)) ?? ((object)node));
wasError = false;
Symbol symbol = null;
Enumerator<Symbol> enumerator = result.Symbols.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
SymbolKind kind = current.Kind;
if (methodOrPropertyGroup.Count > 0)
{
SymbolKind kind2 = methodOrPropertyGroup[0].Kind;
if (kind2 != kind)
{
if ((int)kind2 == 9 || ((int)kind2 == 15 && (int)kind != 9))
{
symbol = current;
continue;
}
symbol = methodOrPropertyGroup[0];
methodOrPropertyGroup.Clear();
}
}
if ((int)kind == 9 || (int)kind == 15)
{
methodOrPropertyGroup.Add(current);
}
else
{
symbol = current;
}
}
if (methodOrPropertyGroup.Count > 0 && IsMethodOrPropertyGroup(methodOrPropertyGroup) && ((int)methodOrPropertyGroup[0].Kind == 9 || (object)symbol == null))
{
if (result.Error != null)
{
Error(diagnostics, result.Error, node);
wasError = (int)result.Error.Severity == 3;
}
return null;
}
methodOrPropertyGroup.Clear();
return ResultSymbol(result, plainName, arity, node, diagnostics, suppressUseSiteDiagnostics: false, out wasError, qualifierOpt);
}
private static bool IsMethodOrPropertyGroup(ArrayBuilder<Symbol> members)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Invalid comparison between Unknown and I4
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
Symbol symbol = members[0];
SymbolKind kind = symbol.Kind;
if ((int)kind != 9)
{
if ((int)kind == 15)
{
Enumerator<Symbol> enumerator = members.GetEnumerator();
while (enumerator.MoveNext())
{
if (((PropertySymbol)enumerator.Current).IsIndexedProperty)
{
return true;
}
}
return false;
}
throw ExceptionUtilities.UnexpectedValue((object)symbol.Kind);
}
return true;
}
private BoundExpression BindElementAccess(ElementAccessExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
BoundExpression receiver = BindExpression(node.Expression, diagnostics, invoked: false, indexed: true);
return BindElementAccess(node, receiver, node.ArgumentList, allowInlineArrayElementAccess: true, diagnostics);
}
private BoundExpression BindElementAccess(ExpressionSyntax node, BoundExpression receiver, BracketedArgumentListSyntax argumentList, bool allowInlineArrayElementAccess, BindingDiagnosticBag diagnostics)
{
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
try
{
BindArgumentsAndNames(argumentList, diagnostics, instance);
if (receiver.Kind == BoundKind.PropertyGroup)
{
BoundPropertyGroup boundPropertyGroup = (BoundPropertyGroup)receiver;
return BindIndexedPropertyAccess((SyntaxNode)(object)node, boundPropertyGroup.ReceiverOpt, boundPropertyGroup.Properties, instance, diagnostics);
}
receiver = CheckValue(receiver, BindValueKind.RValue, diagnostics);
receiver = BindToNaturalType(receiver, diagnostics);
return BindElementOrIndexerAccess(node, receiver, instance, allowInlineArrayElementAccess, diagnostics);
}
finally
{
instance.Free();
}
}
private BoundExpression BindElementOrIndexerAccess(ExpressionSyntax node, BoundExpression expr, AnalyzedArguments analyzedArguments, bool allowInlineArrayElementAccess, BindingDiagnosticBag diagnostics)
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
if ((object)expr.Type == null)
{
return BadIndexerExpression((SyntaxNode)(object)node, expr, analyzedArguments, null, diagnostics);
}
WarnOnAccessOfOffDefault((SyntaxNode)(object)node, expr, diagnostics);
if (analyzedArguments.HasErrors || expr.HasAnyErrors)
{
diagnostics = BindingDiagnosticBag.Discarded;
}
bool flag = false;
if (allowInlineArrayElementAccess && !InAttributeArgument && !InParameterDefaultValue && expr.Type.HasInlineArrayAttribute(out var length))
{
FieldSymbol fieldSymbol = expr.Type.TryGetPossiblyUnsupportedByLanguageInlineArrayElementField();
if ((object)fieldSymbol != null)
{
flag = true;
if (analyzedArguments.Arguments.Count == 1)
{
WellKnownType indexOrRangeWellknownType;
BoundExpression boundExpression = tryImplicitConversionToInlineArrayIndex(node, analyzedArguments.Arguments[0], diagnostics, out indexOrRangeWellknownType);
if (boundExpression != null)
{
if (!TypeSymbol.IsInlineArrayElementFieldSupported(fieldSymbol))
{
return BadIndexerExpression((SyntaxNode)(object)node, expr, analyzedArguments, null, diagnostics);
}
return bindInlineArrayElementAccess(node, expr, length, analyzedArguments, boundExpression, indexOrRangeWellknownType, fieldSymbol, diagnostics);
}
}
}
}
BindingDiagnosticBag bindingDiagnosticBag = diagnostics;
if (flag && ((BindingDiagnosticBag)diagnostics).AccumulatesDiagnostics)
{
bindingDiagnosticBag = BindingDiagnosticBag.GetInstance(diagnostics);
}
BoundExpression result = BindElementAccessCore((SyntaxNode)(object)node, expr, analyzedArguments, bindingDiagnosticBag);
if (bindingDiagnosticBag != diagnostics)
{
Diagnostic val = EnumerableExtensions.AsSingleton<Diagnostic>(((BindingDiagnosticBag)bindingDiagnosticBag).DiagnosticBag.AsEnumerableWithoutResolution());
if (val != null && val.Code == 21)
{
IReadOnlyList<object> arguments = val.Arguments;
if (arguments != null && arguments.Count == 1 && arguments[0] is TypeSymbol typeSymbol && typeSymbol.Equals(expr.Type, (TypeCompareKind)0))
{
((BindingDiagnosticBag)bindingDiagnosticBag).DiagnosticBag.Clear();
Error(bindingDiagnosticBag, ErrorCode.ERR_InlineArrayBadIndex, ((SyntaxNode)node).Location);
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRangeAndFree((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag);
}
return result;
BoundExpression bindInlineArrayElementAccess(ExpressionSyntax expressionSyntax, BoundExpression boundExpression2, int num, AnalyzedArguments analyzedArguments2, BoundExpression convertedIndex, WellKnownType val2, FieldSymbol elementField, BindingDiagnosticBag bindingDiagnosticBag2)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Invalid comparison between Unknown and I4
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Invalid comparison between Unknown and I4
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Invalid comparison between Unknown and I4
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Invalid comparison between Unknown and I4
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Invalid comparison between Unknown and I4
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Invalid comparison between Unknown and I4
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02b1: Invalid comparison between Unknown and I4
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Invalid comparison between Unknown and I4
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Invalid comparison between Unknown and I4
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
if ((int)val2 != 0)
{
if ((int)val2 == 285)
{
GetWellKnownTypeMember((WellKnownMember)423, bindingDiagnosticBag2, null, (SyntaxNode)(object)expressionSyntax);
GetWellKnownTypeMember((WellKnownMember)424, bindingDiagnosticBag2, null, (SyntaxNode)(object)expressionSyntax);
}
GetWellKnownTypeMember((WellKnownMember)418, bindingDiagnosticBag2, null, (SyntaxNode)(object)expressionSyntax);
}
if (analyzedArguments2.Names.Count > 0)
{
Error(bindingDiagnosticBag2, ErrorCode.ERR_NamedArgumentForInlineArray, (CSharpSyntaxNode)expressionSyntax);
}
ReportRefOrOutArgument(analyzedArguments2, bindingDiagnosticBag2);
bool isValue = false;
WellKnownMember member;
WellKnownMember val3;
if (CheckValueKind((SyntaxNode)(object)expressionSyntax, boundExpression2, BindValueKind.Assignable | BindValueKind.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
{
member = (WellKnownMember)99;
val3 = (WellKnownMember)(((int)val2 == 285) ? 402 : 400);
}
else
{
member = (WellKnownMember)100;
val3 = (WellKnownMember)(((int)val2 == 285) ? 408 : 406);
GetWellKnownTypeMember((WellKnownMember)131, bindingDiagnosticBag2, null, (SyntaxNode)(object)expressionSyntax);
if (!CheckValueKind((SyntaxNode)(object)expressionSyntax, boundExpression2, BindValueKind.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
{
if ((int)val2 == 285)
{
Location location;
if (boundExpression2.Syntax.Parent is ConditionalAccessExpressionSyntax conditionalAccessExpressionSyntax && (object)conditionalAccessExpressionSyntax.Expression == boundExpression2.Syntax)
{
SyntaxTree syntaxTree = boundExpression2.Syntax.SyntaxTree;
int spanStart = boundExpression2.Syntax.SpanStart;
SyntaxToken operatorToken = conditionalAccessExpressionSyntax.OperatorToken;
TextSpan span = ((SyntaxToken)(ref operatorToken)).Span;
location = syntaxTree.GetLocation(TextSpan.FromBounds(spanStart, ((TextSpan)(ref span)).End));
}
else
{
location = boundExpression2.Syntax.GetLocation();
}
Error(bindingDiagnosticBag2, ErrorCode.ERR_RefReturnLvalueExpected, location);
}
else
{
isValue = true;
}
}
}
ConstantValue constantValueOpt = convertedIndex.ConstantValueOpt;
if (constantValueOpt != null && (int)constantValueOpt.SpecialType == 13)
{
int int32Value = constantValueOpt.Int32Value;
checkInlineArrayBounds(convertedIndex.Syntax, int32Value, num, excludeEnd: true, bindingDiagnosticBag2);
}
else if ((int)val2 == 284)
{
checkInlineArrayBoundsForSystemIndex(convertedIndex, num, excludeEnd: true, bindingDiagnosticBag2);
}
else if ((int)val2 == 285 && convertedIndex is BoundRangeExpression boundRangeExpression)
{
BoundExpression leftOperandOpt = boundRangeExpression.LeftOperandOpt;
if (leftOperandOpt != null)
{
checkInlineArrayBoundsForSystemIndex(leftOperandOpt, num, excludeEnd: false, bindingDiagnosticBag2);
}
BoundExpression rightOperandOpt = boundRangeExpression.RightOperandOpt;
if (rightOperandOpt != null)
{
checkInlineArrayBoundsForSystemIndex(rightOperandOpt, num, excludeEnd: false, bindingDiagnosticBag2);
}
}
GetWellKnownTypeMember((WellKnownMember)130, bindingDiagnosticBag2, null, (SyntaxNode)(object)expressionSyntax);
GetWellKnownTypeMember(member, bindingDiagnosticBag2, null, (SyntaxNode)(object)expressionSyntax);
Symbol wellKnownTypeMember = GetWellKnownTypeMember(val3, bindingDiagnosticBag2, null, (SyntaxNode)(object)expressionSyntax);
if ((object)wellKnownTypeMember != null)
{
NamedTypeSymbol containingType = wellKnownTypeMember.ContainingType;
if ((object)containingType != null && (int)containingType.Kind == 11)
{
containingType.Construct(ImmutableArray.Create(elementField.TypeWithAnnotations)).CheckConstraints(new ConstraintsHelper.CheckConstraintsArgs(Compilation, Conversions, expressionSyntax.GetLocation(), bindingDiagnosticBag2));
}
}
if (!Compilation.Assembly.RuntimeSupportsInlineArrayTypes)
{
Error(bindingDiagnosticBag2, ErrorCode.ERR_RuntimeDoesNotSupportInlineArrayTypes, (CSharpSyntaxNode)expressionSyntax);
}
CheckFeatureAvailability((SyntaxNode)(object)expressionSyntax, MessageID.IDS_FeatureInlineArrays, bindingDiagnosticBag2);
bindingDiagnosticBag2.ReportUseSite(elementField, (SyntaxNode)(object)expressionSyntax);
TypeSymbol type = (((int)val2 != 285) ? elementField.Type : Compilation.GetWellKnownType((WellKnownType)(((int)val3 == 408) ? 276 : 275)).Construct(ImmutableArray.Create(elementField.TypeWithAnnotations)));
return new BoundInlineArrayAccess((SyntaxNode)(object)expressionSyntax, boundExpression2, convertedIndex, isValue, val3, type);
}
static void checkInlineArrayBounds(SyntaxNode location, int index, int end, bool excludeEnd, BindingDiagnosticBag diagnostics2)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if (index < 0 || (excludeEnd ? (index >= end) : (index > end)))
{
Error(diagnostics2, ErrorCode.ERR_InlineArrayIndexOutOfRange, SyntaxNodeOrToken.op_Implicit(location));
}
}
void checkInlineArrayBoundsForSystemIndex(BoundExpression convertedIndex, int num2, bool excludeEnd, BindingDiagnosticBag diagnostics2)
{
SyntaxNode location;
int? num = InferConstantIndexFromSystemIndex(Compilation, convertedIndex, num2, out location);
if (num.HasValue)
{
checkInlineArrayBounds(location, num.GetValueOrDefault(), num2, excludeEnd, diagnostics2);
}
}
BoundExpression tryImplicitConversionToInlineArrayIndex(ExpressionSyntax node2, BoundExpression index, BindingDiagnosticBag diagnostics2, out WellKnownType reference)
{
reference = (WellKnownType)0;
BoundExpression boundExpression2 = TryImplicitConversionToArrayIndex(index, (SpecialType)13, (SyntaxNode)(object)node2, diagnostics2);
if (boundExpression2 == null)
{
boundExpression2 = TryImplicitConversionToArrayIndex(index, (WellKnownType)284, (SyntaxNode)(object)node2, diagnostics2);
if (boundExpression2 == null)
{
boundExpression2 = TryImplicitConversionToArrayIndex(index, (WellKnownType)285, (SyntaxNode)(object)node2, diagnostics2);
if (boundExpression2 != null)
{
reference = (WellKnownType)285;
}
}
else
{
reference = (WellKnownType)284;
}
}
return boundExpression2;
}
}
internal static int? InferConstantIndexFromSystemIndex(CSharpCompilation compilation, BoundExpression convertedIndex, int length, out SyntaxNode location)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Invalid comparison between Unknown and I4
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Invalid comparison between Unknown and I4
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Invalid comparison between Unknown and I4
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Invalid comparison between Unknown and I4
int? result = null;
location = null;
if (TypeSymbol.Equals(convertedIndex.Type, compilation.GetWellKnownType((WellKnownType)284), (TypeCompareKind)63))
{
if (convertedIndex is BoundFromEndIndexExpression boundFromEndIndexExpression)
{
ConstantValue constantValueOpt = boundFromEndIndexExpression.Operand.ConstantValueOpt;
if (constantValueOpt != null && (int)constantValueOpt.SpecialType == 13)
{
int int32Value = constantValueOpt.Int32Value;
location = boundFromEndIndexExpression.Syntax;
result = length - int32Value;
}
}
else
{
if (convertedIndex is BoundConversion boundConversion)
{
BoundExpression operand = boundConversion.Operand;
if (operand != null)
{
ConstantValue constantValueOpt = operand.ConstantValueOpt;
if (constantValueOpt != null && (int)constantValueOpt.SpecialType == 13)
{
int int32Value2 = constantValueOpt.Int32Value;
location = operand.Syntax;
result = int32Value2;
goto IL_0192;
}
}
}
if (convertedIndex is BoundObjectCreationExpression boundObjectCreationExpression)
{
MethodSymbol constructor = boundObjectCreationExpression.Constructor;
if ((object)constructor != null)
{
ImmutableArray<BoundExpression> arguments = boundObjectCreationExpression.Arguments;
if (arguments.Length == 2 && boundObjectCreationExpression.ArgsToParamsOpt.IsDefaultOrEmpty && boundObjectCreationExpression.InitializerExpressionOpt == null && (object)constructor == compilation.GetWellKnownTypeMember((WellKnownMember)417))
{
BoundExpression boundExpression = arguments[0];
if (boundExpression != null)
{
ConstantValue constantValueOpt = boundExpression.ConstantValueOpt;
if (constantValueOpt != null && (int)constantValueOpt.SpecialType == 13)
{
int int32Value3 = constantValueOpt.Int32Value;
BoundExpression boundExpression2 = arguments[1];
if (boundExpression2 != null)
{
constantValueOpt = boundExpression2.ConstantValueOpt;
if (constantValueOpt != null && (int)constantValueOpt.SpecialType == 7)
{
bool booleanValue = constantValueOpt.BooleanValue;
location = boundExpression.Syntax;
result = (booleanValue ? (length - int32Value3) : int32Value3);
}
}
}
}
}
}
}
}
}
goto IL_0192;
IL_0192:
return result;
}
private BoundExpression BadIndexerExpression(SyntaxNode node, BoundExpression expr, AnalyzedArguments analyzedArguments, DiagnosticInfo errorOpt, BindingDiagnosticBag diagnostics)
{
if (!expr.HasAnyErrors)
{
diagnostics.Add((DiagnosticInfo?)(((object)errorOpt) ?? ((object)new CSDiagnosticInfo(ErrorCode.ERR_BadIndexLHS, expr.Display))), node.Location);
}
ImmutableArray<BoundExpression> childBoundNodes = BuildArgumentsForErrorRecovery(analyzedArguments).Add(expr);
return new BoundBadExpression(node, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, childBoundNodes, CreateErrorType(), hasErrors: true);
}
private BoundExpression BindElementAccessCore(SyntaxNode node, BoundExpression expr, AnalyzedArguments arguments, BindingDiagnosticBag diagnostics)
{
//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)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected I4, but got Unknown
TypeKind typeKind = expr.Type.TypeKind;
switch (typeKind - 1)
{
case 0:
return BindArrayAccess(node, expr, arguments, diagnostics);
case 3:
return BindDynamicIndexer(node, expr, arguments, ImmutableArray<PropertySymbol>.Empty, diagnostics);
case 8:
return BindPointerElementAccess(node, expr, arguments, diagnostics);
case 1:
case 6:
case 9:
case 10:
return BindIndexerAccess(node, expr, arguments, diagnostics);
default:
return BadIndexerExpression(node, expr, arguments, null, diagnostics);
}
}
private BoundExpression BindArrayAccess(SyntaxNode node, BoundExpression expr, AnalyzedArguments arguments, BindingDiagnosticBag diagnostics)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Invalid comparison between Unknown and I4
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Invalid comparison between Unknown and I4
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
if (arguments.Names.Count > 0)
{
Error(diagnostics, ErrorCode.ERR_NamedArgumentForArray, SyntaxNodeOrToken.op_Implicit(node));
}
ReportRefOrOutArgument(arguments, diagnostics);
ArrayTypeSymbol arrayTypeSymbol = (ArrayTypeSymbol)expr.Type;
int rank = arrayTypeSymbol.Rank;
if (arguments.Arguments.Count != rank)
{
Error(diagnostics, ErrorCode.ERR_BadIndexCount, SyntaxNodeOrToken.op_Implicit(node), rank);
return new BoundArrayAccess(node, expr, BuildArgumentsForErrorRecovery(arguments), arrayTypeSymbol.ElementType, hasErrors: true);
}
BoundExpression[] array = new BoundExpression[arguments.Arguments.Count];
WellKnownType indexOrRangeWellknownType = (WellKnownType)0;
for (int i = 0; i < arguments.Arguments.Count; i++)
{
BoundExpression index = arguments.Arguments[i];
BoundExpression boundExpression = (array[i] = ConvertToArrayIndex(index, diagnostics, rank == 1, out indexOrRangeWellknownType));
if (rank == 1 && !boundExpression.HasAnyErrors)
{
ConstantValue constantValueOpt = boundExpression.ConstantValueOpt;
if (constantValueOpt != (ConstantValue)null && constantValueOpt.IsNegativeNumeric)
{
Error(diagnostics, ErrorCode.WRN_NegativeArrayIndex, SyntaxNodeOrToken.op_Implicit(boundExpression.Syntax));
}
}
}
TypeSymbol type = (((int)indexOrRangeWellknownType == 285) ? arrayTypeSymbol : arrayTypeSymbol.ElementType);
if ((int)indexOrRangeWellknownType == 284)
{
NamedTypeSymbol specialType = GetSpecialType((SpecialType)13, diagnostics, node);
BoundImplicitIndexerReceiverPlaceholder boundImplicitIndexerReceiverPlaceholder = new BoundImplicitIndexerReceiverPlaceholder(expr.Syntax, expr.IsEquivalentToThisReference, expr.Type)
{
WasCompilerGenerated = true
};
ImmutableArray<BoundImplicitIndexerValuePlaceholder> immutableArray = ImmutableArray.Create(new BoundImplicitIndexerValuePlaceholder(array[0].Syntax, specialType)
{
WasCompilerGenerated = true
});
return new BoundImplicitIndexerAccess(node, expr, array[0], new BoundArrayLength(node, boundImplicitIndexerReceiverPlaceholder, specialType)
{
WasCompilerGenerated = true
}, boundImplicitIndexerReceiverPlaceholder, new BoundArrayAccess(node, boundImplicitIndexerReceiverPlaceholder, ImmutableArray<BoundExpression>.CastUp(immutableArray), type)
{
WasCompilerGenerated = true
}, immutableArray, type);
}
return new BoundArrayAccess(node, expr, ImmutableArrayExtensions.AsImmutableOrNull<BoundExpression>(array), type);
}
private BoundExpression ConvertToArrayIndex(BoundExpression index, BindingDiagnosticBag diagnostics, bool allowIndexAndRange, out WellKnownType indexOrRangeWellknownType)
{
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: 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)
indexOrRangeWellknownType = (WellKnownType)0;
if (index.Kind == BoundKind.OutVariablePendingInference)
{
return ((OutVariablePendingInference)index).FailInference(this, diagnostics);
}
if (index.Kind == BoundKind.DiscardExpression && !index.HasExpressionType())
{
return ((BoundDiscardExpression)index).FailInference(this, diagnostics);
}
SyntaxNode syntax = index.Syntax;
BoundExpression boundExpression = TryImplicitConversionToArrayIndex(index, (SpecialType)13, syntax, diagnostics) ?? TryImplicitConversionToArrayIndex(index, (SpecialType)14, syntax, diagnostics) ?? TryImplicitConversionToArrayIndex(index, (SpecialType)15, syntax, diagnostics) ?? TryImplicitConversionToArrayIndex(index, (SpecialType)16, syntax, diagnostics);
if (boundExpression == null && allowIndexAndRange)
{
boundExpression = TryImplicitConversionToArrayIndex(index, (WellKnownType)284, syntax, diagnostics);
if (boundExpression == null)
{
boundExpression = TryImplicitConversionToArrayIndex(index, (WellKnownType)285, syntax, diagnostics);
if (boundExpression != null)
{
indexOrRangeWellknownType = (WellKnownType)285;
GetWellKnownTypeMember((WellKnownMember)127, diagnostics, null, syntax);
}
}
else
{
indexOrRangeWellknownType = (WellKnownType)284;
GetWellKnownTypeMember((WellKnownMember)418, diagnostics, null, syntax);
}
}
if (boundExpression == null)
{
NamedTypeSymbol specialType = GetSpecialType((SpecialType)13, diagnostics, syntax);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyConversionFromExpression(index, specialType, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(syntax, useSiteInfo);
GenerateImplicitConversionError(diagnostics, syntax, conversion, index, specialType);
return CreateConversion(syntax, index, conversion, isCast: false, null, specialType, BindingDiagnosticBag.Discarded);
}
return boundExpression;
}
private BoundExpression TryImplicitConversionToArrayIndex(BoundExpression expr, WellKnownType wellKnownType, SyntaxNode node, BindingDiagnosticBag diagnostics)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
TypeSymbol wellKnownType2 = GetWellKnownType(wellKnownType, ref useSiteInfo);
if (wellKnownType2.IsErrorType())
{
return null;
}
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(diagnostics);
BoundExpression boundExpression = TryImplicitConversionToArrayIndex(expr, wellKnownType2, node, instance);
if (boundExpression != null)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
return boundExpression;
}
private BoundExpression TryImplicitConversionToArrayIndex(BoundExpression expr, SpecialType specialType, SyntaxNode node, BindingDiagnosticBag diagnostics)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(diagnostics);
TypeSymbol specialType2 = GetSpecialType(specialType, instance, node);
BoundExpression boundExpression = TryImplicitConversionToArrayIndex(expr, specialType2, node, instance);
if (boundExpression != null)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
return boundExpression;
}
private BoundExpression TryImplicitConversionToArrayIndex(BoundExpression expr, TypeSymbol targetType, SyntaxNode node, BindingDiagnosticBag diagnostics)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyImplicitConversionFromExpression(expr, targetType, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
if (!conversion.Exists)
{
return null;
}
if (conversion.IsDynamic)
{
conversion = conversion.SetArrayIndexConversionForDynamic();
}
return CreateConversion(expr.Syntax, expr, conversion, isCast: false, null, targetType, diagnostics);
}
private BoundExpression BindPointerElementAccess(SyntaxNode node, BoundExpression expr, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
if (analyzedArguments.Names.Count > 0)
{
Error(diagnostics, ErrorCode.ERR_NamedArgumentForArray, SyntaxNodeOrToken.op_Implicit(node));
flag = true;
}
flag = flag || ReportRefOrOutArgument(analyzedArguments, diagnostics);
TypeSymbol pointedAtType = ((PointerTypeSymbol)expr.Type).PointedAtType;
ArrayBuilder<BoundExpression> arguments = analyzedArguments.Arguments;
if (arguments.Count != 1)
{
if (!flag)
{
Error(diagnostics, ErrorCode.ERR_PtrIndexSingle, SyntaxNodeOrToken.op_Implicit(node));
}
return new BoundPointerElementAccess(node, expr, BadExpression(node, BuildArgumentsForErrorRecovery(analyzedArguments)).MakeCompilerGenerated(), CheckOverflowAtRuntime, refersToLocation: false, pointedAtType, hasErrors: true);
}
if (pointedAtType.IsVoidType())
{
Error(diagnostics, ErrorCode.ERR_VoidError, SyntaxNodeOrToken.op_Implicit(expr.Syntax));
flag = true;
}
BoundExpression index = arguments[0];
index = ConvertToArrayIndex(index, diagnostics, allowIndexAndRange: false, out var _);
return new BoundPointerElementAccess(node, expr, index, CheckOverflowAtRuntime, refersToLocation: false, pointedAtType, flag);
}
private static bool ReportRefOrOutArgument(AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
int count = analyzedArguments.Arguments.Count;
for (int i = 0; i < count; i++)
{
RefKind val = analyzedArguments.RefKind(i);
if ((int)val != 0)
{
Error(diagnostics, ErrorCode.ERR_BadArgExtraRef, SyntaxNodeOrToken.op_Implicit(analyzedArguments.Argument(i).Syntax), i + 1, RefKindExtensions.ToArgumentDisplayString(val));
return true;
}
}
return false;
}
private BoundExpression BindIndexerAccess(SyntaxNode node, BoundExpression expr, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
LookupResult instance = LookupResult.GetInstance();
LookupOptions options = ((expr.Kind == BoundKind.BaseReference) ? LookupOptions.UseBaseReferenceAccessibility : LookupOptions.Default);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupMembersWithFallback(instance, expr.Type, "this[]", 0, ref useSiteInfo, null, options);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
BoundExpression result;
if (!instance.IsMultiViable)
{
result = ((!TryBindIndexOrRangeImplicitIndexer(node, expr, analyzedArguments, diagnostics, out BoundImplicitIndexerAccess implicitIndexerAccess)) ? BadIndexerExpression(node, expr, analyzedArguments, instance.Error, diagnostics) : implicitIndexerAccess);
}
else
{
ArrayBuilder<PropertySymbol> instance2 = ArrayBuilder<PropertySymbol>.GetInstance();
Enumerator<Symbol> enumerator = instance.Symbols.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
instance2.Add((PropertySymbol)current);
}
result = BindIndexerOrIndexedPropertyAccess(node, expr, instance2, analyzedArguments, diagnostics);
instance2.Free();
}
instance.Free();
return result;
}
private BoundExpression BindIndexedPropertyAccess(BoundPropertyGroup propertyGroup, bool mustHaveAllOptionalParameters, BindingDiagnosticBag diagnostics)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
SyntaxNode syntax = propertyGroup.Syntax;
BoundExpression receiverOpt = propertyGroup.ReceiverOpt;
ImmutableArray<PropertySymbol> properties = propertyGroup.Properties;
if (properties.All(s_isIndexedPropertyWithNonOptionalArguments))
{
Error(diagnostics, mustHaveAllOptionalParameters ? ErrorCode.ERR_IndexedPropertyMustHaveAllOptionalParams : ErrorCode.ERR_IndexedPropertyRequiresParams, SyntaxNodeOrToken.op_Implicit(syntax), properties[0].ToDisplayString(s_propertyGroupFormat));
return BoundIndexerAccess.ErrorAccess(syntax, receiverOpt, CreateErrorPropertySymbol(properties), ImmutableArray<BoundExpression>.Empty, default(ImmutableArray<string>), default(ImmutableArray<RefKind>), properties);
}
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
BoundExpression result = BindIndexedPropertyAccess(syntax, receiverOpt, properties, instance, diagnostics);
instance.Free();
return result;
}
private BoundExpression BindIndexedPropertyAccess(SyntaxNode syntax, BoundExpression receiver, ImmutableArray<PropertySymbol> propertyGroup, AnalyzedArguments arguments, BindingDiagnosticBag diagnostics)
{
ArrayBuilder<PropertySymbol> instance = ArrayBuilder<PropertySymbol>.GetInstance();
instance.AddRange(propertyGroup);
BoundExpression result = BindIndexerOrIndexedPropertyAccess(syntax, receiver, instance, arguments, diagnostics);
instance.Free();
return result;
}
private BoundExpression BindDynamicIndexer(SyntaxNode syntax, BoundExpression receiver, AnalyzedArguments arguments, ImmutableArray<PropertySymbol> applicableProperties, BindingDiagnosticBag diagnostics)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
switch (receiver.Kind)
{
case BoundKind.BaseReference:
Error(diagnostics, ErrorCode.ERR_NoDynamicPhantomOnBaseIndexer, SyntaxNodeOrToken.op_Implicit(syntax));
flag = true;
break;
case BoundKind.TypeOrValueExpression:
{
BoundTypeOrValueExpression boundTypeOrValueExpression = (BoundTypeOrValueExpression)receiver;
bool inStaticContext;
bool useType = IsInstance(boundTypeOrValueExpression.Data.ValueSymbol) && !HasThis(isExplicit: false, out inStaticContext);
receiver = ReplaceTypeOrValueReceiver(boundTypeOrValueExpression, useType, diagnostics);
break;
}
}
ImmutableArray<BoundExpression> arguments2 = BuildArgumentsForDynamicInvocation(arguments, diagnostics);
ImmutableArray<RefKind> immutableArray = arguments.RefKinds.ToImmutableOrNull();
flag &= ReportBadDynamicArguments(syntax, arguments2, immutableArray, diagnostics, null);
return new BoundDynamicIndexerAccess(syntax, receiver, arguments2, arguments.GetNames(), immutableArray, applicableProperties, AssemblySymbol.DynamicType, flag);
}
private BoundExpression BindIndexerOrIndexedPropertyAccess(SyntaxNode syntax, BoundExpression receiver, ArrayBuilder<PropertySymbol> propertyGroup, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
OverloadResolutionResult<PropertySymbol> instance = OverloadResolutionResult<PropertySymbol>.GetInstance();
bool allowRefOmittedArguments = receiver.IsExpressionOfComImportType();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
OverloadResolution.PropertyOverloadResolution(propertyGroup, receiver, analyzedArguments, instance, allowRefOmittedArguments, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(syntax, useSiteInfo);
if (analyzedArguments.HasDynamicArgument && instance.HasAnyApplicableMember)
{
ImmutableArray<PropertySymbol> candidatesPassingFinalValidation = GetCandidatesPassingFinalValidation(syntax, instance, receiver, default(ImmutableArray<TypeWithAnnotations>), diagnostics);
instance.Free();
return BindDynamicIndexer(syntax, receiver, analyzedArguments, candidatesPassingFinalValidation, diagnostics);
}
ImmutableArray<string> names = analyzedArguments.GetNames();
ImmutableArray<RefKind> immutableArray = analyzedArguments.RefKinds.ToImmutableOrNull();
BoundExpression result;
if (!instance.Succeeded)
{
ImmutableArray<PropertySymbol> immutableArray2 = propertyGroup.ToImmutable();
if (TryBindIndexOrRangeImplicitIndexer(syntax, receiver, analyzedArguments, diagnostics, out BoundImplicitIndexerAccess implicitIndexerAccess))
{
return implicitIndexerAccess;
}
PropertySymbol propertySymbol = immutableArray2[0];
string name = (propertySymbol.IsIndexer ? SyntaxFacts.GetText(SyntaxKind.ThisKeyword) : propertySymbol.Name);
instance.ReportDiagnostics(this, syntax.Location, syntax, diagnostics, name, null, null, analyzedArguments, immutableArray2, null, null);
ImmutableArray<BoundExpression> arguments = BuildArgumentsForErrorRecovery(analyzedArguments, immutableArray2);
PropertySymbol indexer = ((immutableArray2.Length == 1) ? immutableArray2[0] : CreateErrorPropertySymbol(immutableArray2));
result = BoundIndexerAccess.ErrorAccess(syntax, receiver, indexer, arguments, names, immutableArray, immutableArray2);
}
else
{
MemberResolutionResult<PropertySymbol> validResult = instance.ValidResult;
PropertySymbol member = validResult.Member;
bool expanded = validResult.Result.Kind == MemberResolutionKind.ApplicableInExpandedForm;
ImmutableArray<int> argsToParamsOpt = validResult.Result.ArgsToParamsOpt;
ReportDiagnosticsIfObsolete(diagnostics, member, SyntaxNodeOrToken.op_Implicit(syntax), receiver != null && receiver.Kind == BoundKind.BaseReference);
bool flag = MemberGroupFinalValidationAccessibilityChecks(receiver, member, syntax, diagnostics, invokedAsExtensionMethod: false);
receiver = ReplaceTypeOrValueReceiver(receiver, member.IsStatic, diagnostics);
CheckAndCoerceArguments(validResult, analyzedArguments, diagnostics, receiver, invokedAsExtensionMethod: false);
if (!flag && receiver != null && receiver.Kind == BoundKind.ThisReference && receiver.WasCompilerGenerated)
{
flag = IsRefOrOutThisParameterCaptured(SyntaxNodeOrToken.op_Implicit(syntax), diagnostics);
}
ImmutableArray<BoundExpression> arguments2 = analyzedArguments.Arguments.ToImmutable();
result = new BoundIndexerAccess(syntax, receiver, ReceiverIsSubjectToCloning(receiver, member), member, arguments2, names, immutableArray, expanded, argsToParamsOpt, default(BitVector), member.Type, flag);
}
instance.Free();
return result;
}
private bool TryBindIndexOrRangeImplicitIndexer(SyntaxNode syntax, BoundExpression receiver, AnalyzedArguments arguments, BindingDiagnosticBag diagnostics, [NotNullWhen(true)] out BoundImplicitIndexerAccess? implicitIndexerAccess)
{
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
implicitIndexerAccess = null;
if (arguments.Arguments.Count != 1)
{
return false;
}
BoundExpression boundExpression = arguments.Arguments[0];
TypeSymbol type = boundExpression.Type;
ThreeState val = (ThreeState)(TypeSymbol.Equals(type, Compilation.GetWellKnownType((WellKnownType)284), (TypeCompareKind)0) ? 2 : (TypeSymbol.Equals(type, Compilation.GetWellKnownType((WellKnownType)285), (TypeCompareKind)0) ? 1 : 0));
if (!ThreeStateHelpers.HasValue(val))
{
return false;
}
bool flag = ThreeStateHelpers.Value(val);
BoundImplicitIndexerReceiverPlaceholder receiverPlaceholder = new BoundImplicitIndexerReceiverPlaceholder(receiver.Syntax, receiver.IsEquivalentToThisReference, receiver.Type)
{
WasCompilerGenerated = true
};
if (!TryBindIndexOrRangeImplicitIndexerParts(syntax, receiverPlaceholder, flag, out BoundExpression lengthOrCountAccess, out BoundExpression indexerOrSliceAccess, out ImmutableArray<BoundImplicitIndexerValuePlaceholder> argumentPlaceholders, diagnostics))
{
return false;
}
implicitIndexerAccess = new BoundImplicitIndexerAccess(syntax, receiver, BindToNaturalType(boundExpression, diagnostics), lengthOrCountAccess, receiverPlaceholder, indexerOrSliceAccess, argumentPlaceholders, indexerOrSliceAccess.Type);
if (!flag)
{
checkWellKnown((WellKnownMember)423);
checkWellKnown((WellKnownMember)424);
}
checkWellKnown((WellKnownMember)418);
MessageID.IDS_FeatureIndexOperator.CheckFeatureAvailability(diagnostics, syntax);
if (arguments.Names.Count > 0)
{
diagnostics.Add(flag ? ErrorCode.ERR_ImplicitIndexIndexerWithName : ErrorCode.ERR_ImplicitRangeIndexerWithName, arguments.Names[0].GetValueOrDefault().Item2);
}
return true;
void checkWellKnown(WellKnownMember member)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
GetWellKnownTypeMember(member, diagnostics, null, syntax);
}
}
private bool TryBindIndexOrRangeImplicitIndexerParts(SyntaxNode syntax, BoundImplicitIndexerReceiverPlaceholder receiverPlaceholder, bool argIsIndex, [NotNullWhen(true)] out BoundExpression? lengthOrCountAccess, [NotNullWhen(true)] out BoundExpression? indexerOrSliceAccess, out ImmutableArray<BoundImplicitIndexerValuePlaceholder> argumentPlaceholders, BindingDiagnosticBag diagnostics)
{
if (TryBindLengthOrCount(syntax, receiverPlaceholder, out lengthOrCountAccess, diagnostics) && tryBindUnderlyingIndexerOrSliceAccess(syntax, receiverPlaceholder, argIsIndex, out indexerOrSliceAccess, out argumentPlaceholders, diagnostics))
{
return true;
}
lengthOrCountAccess = null;
indexerOrSliceAccess = null;
argumentPlaceholders = default(ImmutableArray<BoundImplicitIndexerValuePlaceholder>);
return false;
void makeCall(SyntaxNode val, BoundExpression receiver, MethodSymbol method, out BoundExpression reference2, out ImmutableArray<BoundImplicitIndexerValuePlaceholder> reference)
{
BoundImplicitIndexerValuePlaceholder boundImplicitIndexerValuePlaceholder = new BoundImplicitIndexerValuePlaceholder(val, Compilation.GetSpecialType((SpecialType)13))
{
WasCompilerGenerated = true
};
BoundImplicitIndexerValuePlaceholder boundImplicitIndexerValuePlaceholder2 = new BoundImplicitIndexerValuePlaceholder(val, Compilation.GetSpecialType((SpecialType)13))
{
WasCompilerGenerated = true
};
reference = ImmutableArray.Create(boundImplicitIndexerValuePlaceholder, boundImplicitIndexerValuePlaceholder2);
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
instance.Arguments.Add((BoundExpression)boundImplicitIndexerValuePlaceholder);
instance.Arguments.Add((BoundExpression)boundImplicitIndexerValuePlaceholder2);
BoundMethodGroup methodGroup = new BoundMethodGroup(val, default(ImmutableArray<TypeWithAnnotations>), method.Name, ImmutableArray.Create(method), method, null, BoundMethodGroupFlags.None, null, receiver, LookupResultKind.Viable)
{
WasCompilerGenerated = true
};
reference2 = BindMethodGroupInvocation(val, val, method.Name, methodGroup, instance, diagnostics, null, allowUnexpandedForm: false, out var _).MakeCompilerGenerated();
instance.Free();
}
bool tryBindUnderlyingIndexerOrSliceAccess(SyntaxNode val, BoundImplicitIndexerReceiverPlaceholder receiver, bool flag, [NotNullWhen(true)] out BoundExpression? reference2, out ImmutableArray<BoundImplicitIndexerValuePlaceholder> reference, BindingDiagnosticBag bindingDiagnosticBag)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Invalid comparison between Unknown and I4
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Invalid comparison between Unknown and I4
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Invalid comparison between Unknown and I4
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(bindingDiagnosticBag);
LookupResult instance = LookupResult.GetInstance();
if (flag)
{
LookupMembersInType(instance, receiver.Type, "this[]", 0, null, LookupOptions.Default, this, diagnose: false, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag).Add(val, useSiteInfo);
if (instance.IsMultiViable)
{
Enumerator<Symbol> enumerator = instance.Symbols.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
if (!current.IsStatic && current is PropertySymbol propertySymbol && IsAccessible(propertySymbol, val, bindingDiagnosticBag))
{
PropertySymbol originalDefinition = propertySymbol.OriginalDefinition;
if ((object)originalDefinition != null && originalDefinition.ParameterCount == 1)
{
ParameterSymbol parameterSymbol = originalDefinition.Parameters[0];
if ((object)parameterSymbol != null)
{
TypeSymbol type = parameterSymbol.Type;
if ((object)type != null && (int)type.SpecialType == 13 && (int)parameterSymbol.RefKind == 0)
{
BoundImplicitIndexerValuePlaceholder boundImplicitIndexerValuePlaceholder = new BoundImplicitIndexerValuePlaceholder(val, Compilation.GetSpecialType((SpecialType)13))
{
WasCompilerGenerated = true
};
reference = ImmutableArray.Create(boundImplicitIndexerValuePlaceholder);
AnalyzedArguments instance2 = AnalyzedArguments.GetInstance();
instance2.Arguments.Add((BoundExpression)boundImplicitIndexerValuePlaceholder);
ArrayBuilder<PropertySymbol> instance3 = ArrayBuilder<PropertySymbol>.GetInstance();
instance3.AddRange(new PropertySymbol[1] { propertySymbol });
reference2 = BindIndexerOrIndexedPropertyAccess(val, receiver, instance3, instance2, bindingDiagnosticBag).MakeCompilerGenerated();
instance3.Free();
instance2.Free();
instance.Free();
return true;
}
}
}
}
}
}
}
else if ((int)receiver.Type.SpecialType == 20)
{
MethodSymbol methodSymbol = (MethodSymbol)GetSpecialTypeMember((SpecialMember)14, bindingDiagnosticBag, val);
if ((object)methodSymbol != null)
{
makeCall(val, receiver, methodSymbol, out reference2, out reference);
instance.Free();
return true;
}
}
else
{
LookupMembersInType(instance, receiver.Type, "Slice", 0, null, LookupOptions.Default, this, diagnose: false, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag).Add(val, useSiteInfo);
if (instance.IsMultiViable)
{
Enumerator<Symbol> enumerator = instance.Symbols.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current2 = enumerator.Current;
if (!current2.IsStatic && IsAccessible(current2, val, bindingDiagnosticBag) && current2 is MethodSymbol method && MethodHasValidSliceSignature(method))
{
makeCall(val, receiver, method, out reference2, out reference);
instance.Free();
return true;
}
}
}
}
reference2 = null;
reference = default(ImmutableArray<BoundImplicitIndexerValuePlaceholder>);
instance.Free();
return false;
}
}
internal static bool MethodHasValidSliceSignature(MethodSymbol method)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Invalid comparison between Unknown and I4
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Invalid comparison between Unknown and I4
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Invalid comparison between Unknown and I4
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Invalid comparison between Unknown and I4
MethodSymbol originalDefinition = method.OriginalDefinition;
if (!originalDefinition.ReturnsVoid && originalDefinition.ParameterCount == 2)
{
ParameterSymbol parameterSymbol = originalDefinition.Parameters[0];
if ((object)parameterSymbol != null)
{
TypeSymbol type = parameterSymbol.Type;
if ((object)type != null && (int)type.SpecialType == 13 && (int)parameterSymbol.RefKind == 0)
{
parameterSymbol = originalDefinition.Parameters[1];
if ((object)parameterSymbol != null)
{
type = parameterSymbol.Type;
if ((object)type != null && (int)type.SpecialType == 13)
{
return (int)parameterSymbol.RefKind == 0;
}
}
return false;
}
}
}
return false;
}
private bool TryBindLengthOrCount(SyntaxNode syntax, BoundValuePlaceholderBase receiverPlaceholder, out BoundExpression lengthOrCountAccess, BindingDiagnosticBag diagnostics)
{
LookupResult instance = LookupResult.GetInstance();
if (TryLookupLengthOrCount(syntax, receiverPlaceholder.Type, instance, out PropertySymbol lengthOrCountProperty, diagnostics))
{
diagnostics.ReportUseSite(lengthOrCountProperty, syntax);
lengthOrCountAccess = BindPropertyAccess(syntax, receiverPlaceholder, lengthOrCountProperty, diagnostics, instance.Kind, hasErrors: false).MakeCompilerGenerated();
lengthOrCountAccess = CheckValue(lengthOrCountAccess, BindValueKind.RValue, diagnostics);
instance.Free();
return true;
}
lengthOrCountAccess = BadExpression(syntax);
instance.Free();
return false;
}
private bool TryLookupLengthOrCount(SyntaxNode syntax, TypeSymbol receiverType, LookupResult lookupResult, [NotNullWhen(true)] out PropertySymbol? lengthOrCountProperty, BindingDiagnosticBag diagnostics)
{
if (tryLookupLengthOrCount(syntax, "Length", out lengthOrCountProperty, diagnostics) || tryLookupLengthOrCount(syntax, "Count", out lengthOrCountProperty, diagnostics))
{
return true;
}
return false;
bool tryLookupLengthOrCount(SyntaxNode val, string propertyName, [NotNullWhen(true)] out PropertySymbol? valid, BindingDiagnosticBag bindingDiagnosticBag)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Invalid comparison between Unknown and I4
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(bindingDiagnosticBag);
LookupMembersInType(lookupResult, receiverType, propertyName, 0, null, LookupOptions.Default, this, diagnose: false, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag).Add(val, useSiteInfo);
if (lookupResult.IsSingleViable && lookupResult.Symbols[0] is PropertySymbol propertySymbol)
{
MethodSymbol methodSymbol = propertySymbol.GetOwnOrInheritedGetMethod()?.OriginalDefinition;
if ((object)methodSymbol != null && (int)methodSymbol.ReturnType.SpecialType == 13 && (int)methodSymbol.RefKind == 0 && !methodSymbol.IsStatic && IsAccessible(methodSymbol, val, bindingDiagnosticBag))
{
lookupResult.Clear();
valid = propertySymbol;
return true;
}
}
lookupResult.Clear();
valid = null;
return false;
}
}
private ErrorPropertySymbol CreateErrorPropertySymbol(ImmutableArray<PropertySymbol> propertyGroup)
{
TypeSymbol type = GetCommonTypeOrReturnType(propertyGroup) ?? CreateErrorType();
PropertySymbol propertySymbol = propertyGroup[0];
return new ErrorPropertySymbol(propertySymbol.ContainingType, type, propertySymbol.Name, propertySymbol.IsIndexer, propertySymbol.IsIndexedProperty);
}
internal MethodGroupResolution ResolveMethodGroup(BoundMethodGroup node, AnalyzedArguments analyzedArguments, bool isMethodGroupConversion, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool inferWithDynamic = false, RefKind returnRefKind = (RefKind)0, TypeSymbol returnType = null, bool isFunctionPointerResolution = false, in CallingConventionInfo callingConventionInfo = default(CallingConventionInfo))
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
return ResolveMethodGroup(node, node.Syntax, node.Name, analyzedArguments, isMethodGroupConversion, ref useSiteInfo, inferWithDynamic, allowUnexpandedForm: true, returnRefKind, returnType, isFunctionPointerResolution, in callingConventionInfo);
}
internal MethodGroupResolution ResolveMethodGroup(BoundMethodGroup node, SyntaxNode expression, string methodName, AnalyzedArguments analyzedArguments, bool isMethodGroupConversion, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool inferWithDynamic = false, bool allowUnexpandedForm = true, RefKind returnRefKind = (RefKind)0, TypeSymbol returnType = null, bool isFunctionPointerResolution = false, in CallingConventionInfo callingConventionInfo = default(CallingConventionInfo))
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
MethodGroupResolution result = ResolveMethodGroupInternal(node, expression, methodName, analyzedArguments, isMethodGroupConversion, ref useSiteInfo, inferWithDynamic, allowUnexpandedForm, returnRefKind, returnType, isFunctionPointerResolution, in callingConventionInfo);
if (result.IsEmpty && !result.HasAnyErrors)
{
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(withDiagnostics: true, useSiteInfo.AccumulatesDependencies);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).AddRange(result.Diagnostics, false);
BindMemberAccessReportError(node, instance);
return new MethodGroupResolution(result.MethodGroup, result.OtherSymbol, result.OverloadResolutionResult, result.AnalyzedArguments, result.ResultKind, ((BindingDiagnosticBag<AssemblySymbol>)(object)instance).ToReadOnlyAndFree());
}
return result;
}
internal MethodGroupResolution ResolveMethodGroupForFunctionPointer(BoundMethodGroup methodGroup, AnalyzedArguments analyzedArguments, TypeSymbol returnType, RefKind returnRefKind, in CallingConventionInfo callingConventionInfo, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
return ResolveDefaultMethodGroup(methodGroup, analyzedArguments, isMethodGroupConversion: true, ref useSiteInfo, inferWithDynamic: false, allowUnexpandedForm: true, returnRefKind, returnType, isFunctionPointerResolution: true, in callingConventionInfo);
}
private MethodGroupResolution ResolveMethodGroupInternal(BoundMethodGroup methodGroup, SyntaxNode expression, string methodName, AnalyzedArguments analyzedArguments, bool isMethodGroupConversion, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool inferWithDynamic = false, bool allowUnexpandedForm = true, RefKind returnRefKind = (RefKind)0, TypeSymbol returnType = null, bool isFunctionPointerResolution = false, in CallingConventionInfo callingConvention = default(CallingConventionInfo))
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
MethodGroupResolution result = ResolveDefaultMethodGroup(methodGroup, analyzedArguments, isMethodGroupConversion, ref useSiteInfo, inferWithDynamic, allowUnexpandedForm, returnRefKind, returnType, isFunctionPointerResolution, in callingConvention);
if (!methodGroup.SearchExtensionMethods || result.HasAnyApplicableMethod || methodGroup.MethodGroupReceiverIsDynamic())
{
return result;
}
MethodGroupResolution result2 = BindExtensionMethod(expression, methodName, analyzedArguments, methodGroup.ReceiverOpt, methodGroup.TypeArgumentsOpt, isMethodGroupConversion, returnRefKind, returnType, useSiteInfo.AccumulatesDependencies);
bool flag = false;
if (result2.HasAnyApplicableMethod)
{
flag = true;
}
else if (result2.IsEmpty)
{
flag = false;
}
else if (result.IsEmpty)
{
flag = true;
}
else
{
LookupResultKind resultKind = result.ResultKind;
LookupResultKind resultKind2 = result2.ResultKind;
if (resultKind != resultKind2 && resultKind == resultKind2.WorseResultKind(resultKind))
{
flag = true;
}
}
if (flag)
{
result.Free();
return result2;
}
result2.Free();
return result;
}
private MethodGroupResolution ResolveDefaultMethodGroup(BoundMethodGroup node, AnalyzedArguments analyzedArguments, bool isMethodGroupConversion, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool inferWithDynamic = false, bool allowUnexpandedForm = true, RefKind returnRefKind = (RefKind)0, TypeSymbol returnType = null, bool isFunctionPointerResolution = false, in CallingConventionInfo callingConvention = default(CallingConventionInfo))
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
ImmutableArray<MethodSymbol> methods = node.Methods;
if (methods.Length == 0 && node.LookupSymbolOpt is MethodSymbol item)
{
methods = ImmutableArray.Create(item);
}
ImmutableBindingDiagnostic<AssemblySymbol> diagnostics = ImmutableBindingDiagnostic<AssemblySymbol>.Empty;
if (node.LookupError != null)
{
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(withDiagnostics: true, withDependencies: false);
Error(instance, node.LookupError, node.NameSyntax);
diagnostics = ((BindingDiagnosticBag<AssemblySymbol>)(object)instance).ToReadOnlyAndFree();
}
if (methods.Length == 0)
{
return new MethodGroupResolution(node.LookupSymbolOpt, node.ResultKind, diagnostics);
}
MethodGroup instance2 = MethodGroup.GetInstance();
instance2.PopulateWithNonExtensionMethods(node.ReceiverOpt, methods, node.TypeArgumentsOpt, node.ResultKind, node.LookupError);
if (node.LookupError != null)
{
return new MethodGroupResolution(instance2, diagnostics);
}
if (analyzedArguments == null)
{
return new MethodGroupResolution(instance2, diagnostics);
}
OverloadResolutionResult<MethodSymbol> instance3 = OverloadResolutionResult<MethodSymbol>.GetInstance();
bool allowRefOmittedArguments = instance2.Receiver.IsExpressionOfComImportType();
OverloadResolution.MethodInvocationOverloadResolution(instance2.Methods, instance2.TypeArguments, instance2.Receiver, analyzedArguments, instance3, ref useSiteInfo, isMethodGroupConversion, allowRefOmittedArguments, inferWithDynamic, allowUnexpandedForm, returnRefKind, returnType, isFunctionPointerResolution, isExtensionMethodResolution: false, in callingConvention);
return new MethodGroupResolution(instance2, null, instance3, AnalyzedArguments.GetInstance(analyzedArguments), instance2.ResultKind, diagnostics);
}
internal NamedTypeSymbol? GetMethodGroupDelegateType(BoundMethodGroup node)
{
MethodSymbol uniqueSignatureFromMethodGroup = GetUniqueSignatureFromMethodGroup(node);
if ((object)uniqueSignatureFromMethodGroup == null)
{
return null;
}
return GetMethodGroupOrLambdaDelegateType(node.Syntax, uniqueSignatureFromMethodGroup);
}
private MethodSymbol? GetUniqueSignatureFromMethodGroup(BoundMethodGroup node)
{
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
MethodSymbol method = null;
ImmutableArray<MethodSymbol>.Enumerator enumerator = node.Methods.GetEnumerator();
while (enumerator.MoveNext())
{
MethodSymbol current = enumerator.Current;
BoundExpression receiverOpt = node.ReceiverOpt;
if (!(receiverOpt is BoundTypeExpression) && receiverOpt != null)
{
if ((!(receiverOpt is BoundThisReference) || !receiverOpt.WasCompilerGenerated) && current.IsStatic)
{
continue;
}
}
else if (!current.IsStatic)
{
continue;
}
if (!isCandidateUnique(ref method, current))
{
return null;
}
}
if (node.SearchExtensionMethods)
{
BoundExpression receiverOpt2 = node.ReceiverOpt;
ExtensionMethodScopeEnumerator enumerator2 = new ExtensionMethodScopes(this).GetEnumerator();
while (enumerator2.MoveNext())
{
ExtensionMethodScope current2 = enumerator2.Current;
MethodGroup instance = MethodGroup.GetInstance();
PopulateExtensionMethodsFromSingleBinder(current2, instance, node.Syntax, receiverOpt2, node.Name, node.TypeArgumentsOpt, BindingDiagnosticBag.Discarded);
Enumerator<MethodSymbol> enumerator3 = instance.Methods.GetEnumerator();
while (enumerator3.MoveNext())
{
MethodSymbol methodSymbol = enumerator3.Current.ReduceExtensionMethod(receiverOpt2.Type, Compilation);
if ((object)methodSymbol != null && !isCandidateUnique(ref method, methodSymbol))
{
instance.Free();
return null;
}
}
instance.Free();
}
}
if ((object)method == null)
{
return null;
}
int num = ((!node.TypeArgumentsOpt.IsDefaultOrEmpty) ? node.TypeArgumentsOpt.Length : 0);
if (method.Arity != num)
{
return null;
}
if (num > 0)
{
method = method.ConstructedFrom.Construct(node.TypeArgumentsOpt);
}
return method;
static bool isCandidateUnique(ref MethodSymbol? reference, MethodSymbol candidate)
{
if ((object)reference == null)
{
reference = candidate;
return true;
}
if (MemberSignatureComparer.MethodGroupSignatureComparer.Equals(reference, candidate))
{
return true;
}
reference = null;
return false;
}
}
internal NamedTypeSymbol? GetMethodGroupOrLambdaDelegateType(SyntaxNode syntax, MethodSymbol methodSymbol, ImmutableArray<ScopedKind>? parameterScopesOverride = null, ImmutableArray<bool>? parameterHasUnscopedRefAttributesOverride = null, RefKind? returnRefKindOverride = null, TypeWithAnnotations? returnTypeOverride = null)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0366: Unknown result type (might be due to invalid IL or missing references)
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
ImmutableArray<ParameterSymbol> parameters = methodSymbol.Parameters;
ImmutableArray<RefKind> parameterRefKinds = methodSymbol.ParameterRefKinds;
ImmutableArray<TypeWithAnnotations> parameterTypesWithAnnotations = methodSymbol.ParameterTypesWithAnnotations;
TypeWithAnnotations typeWithAnnotations = returnTypeOverride ?? methodSymbol.ReturnTypeWithAnnotations;
RefKind val = (RefKind)(((_003F?)returnRefKindOverride) ?? methodSymbol.RefKind);
ImmutableArray<ScopedKind> immutableArray = parameterScopesOverride ?? (parameters.Any((ParameterSymbol p) => (int)p.EffectiveScope > 0) ? ImmutableArrayExtensions.SelectAsArray<ParameterSymbol, ScopedKind>(parameters, (Func<ParameterSymbol, ScopedKind>)((ParameterSymbol p) => p.EffectiveScope)) : default(ImmutableArray<ScopedKind>));
ImmutableArray<bool> immutableArray2 = parameterHasUnscopedRefAttributesOverride ?? (parameters.Any((ParameterSymbol p) => p.HasUnscopedRefAttribute) ? ImmutableArrayExtensions.SelectAsArray<ParameterSymbol, bool>(parameters, (Func<ParameterSymbol, bool>)((ParameterSymbol p) => p.HasUnscopedRefAttribute)) : default(ImmutableArray<bool>));
ImmutableArray<ConstantValue> immutableArray3 = (parameters.Any((ParameterSymbol p) => p.HasExplicitDefaultValue) ? ImmutableArrayExtensions.SelectAsArray<ParameterSymbol, ConstantValue>(parameters, (Func<ParameterSymbol, ConstantValue>)((ParameterSymbol p) => p.ExplicitDefaultConstantValue)) : default(ImmutableArray<ConstantValue>));
int length = parameters.Length;
int num;
if (length >= 1)
{
ParameterSymbol parameterSymbol = parameters[length - 1];
if ((object)parameterSymbol != null && parameterSymbol.IsParams)
{
num = (parameterSymbol.Type.IsSZArray() ? 1 : 0);
goto IL_01c0;
}
}
num = 0;
goto IL_01c0;
IL_01c0:
bool flag = (byte)num != 0;
bool flag2 = typeWithAnnotations.Type.IsVoidType();
ImmutableArray<TypeWithAnnotations> immutableArray4 = (flag2 ? parameterTypesWithAnnotations : parameterTypesWithAnnotations.Add(typeWithAnnotations));
if (flag2 && (int)val != 0)
{
return null;
}
if (!immutableArray4.All((TypeWithAnnotations t) => t.HasType))
{
return null;
}
if (!flag && (int)val == 0 && immutableArray3.IsDefault && (parameterRefKinds.IsDefault || parameterRefKinds.All((RefKind refKind) => (int)refKind == 0)) && (immutableArray.IsDefault || immutableArray.All((ScopedKind scope) => (int)scope == 0)) && (immutableArray2.IsDefault || immutableArray2.All((bool p) => !p)))
{
WellKnownType val2 = (flag2 ? WellKnownTypes.GetWellKnownActionDelegate(parameterTypesWithAnnotations.Length) : WellKnownTypes.GetWellKnownFunctionDelegate(parameterTypesWithAnnotations.Length));
if ((int)val2 != 0)
{
NamedTypeSymbol wellKnownType = Compilation.GetWellKnownType(val2);
if (immutableArray4.Length == 0)
{
return wellKnownType;
}
if (checkConstraints(Compilation, Conversions, wellKnownType, immutableArray4))
{
return wellKnownType.Construct(immutableArray4);
}
}
}
ArrayBuilder<AnonymousTypeField> instance = ArrayBuilder<AnonymousTypeField>.GetInstance(parameterTypesWithAnnotations.Length + 1);
Location location = syntax.Location;
for (int num2 = 0; num2 < parameterTypesWithAnnotations.Length; num2++)
{
instance.Add(new AnonymousTypeField("", location, parameterTypesWithAnnotations[num2], (RefKind)((!parameterRefKinds.IsDefault) ? ((int)parameterRefKinds[num2]) : 0), (ScopedKind)((!immutableArray.IsDefault) ? ((int)immutableArray[num2]) : 0), immutableArray3.IsDefault ? null : immutableArray3[num2], flag && num2 == parameterTypesWithAnnotations.Length - 1, !immutableArray2.IsDefault && immutableArray2[num2]));
}
instance.Add(new AnonymousTypeField("", location, typeWithAnnotations, val, (ScopedKind)0));
AnonymousTypeDescriptor typeDescr = new AnonymousTypeDescriptor(instance.ToImmutableAndFree(), location);
return Compilation.AnonymousTypeManager.ConstructAnonymousDelegateSymbol(typeDescr);
static bool checkConstraints(CSharpCompilation compilation, ConversionsBase conversions, NamedTypeSymbol delegateType, ImmutableArray<TypeWithAnnotations> typeArguments)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
ArrayBuilder<TypeParameterDiagnosticInfo> instance2 = ArrayBuilder<TypeParameterDiagnosticInfo>.GetInstance();
ImmutableArray<TypeParameterSymbol> typeParameters = delegateType.TypeParameters;
TypeMap substitution = new TypeMap(typeParameters, typeArguments);
ArrayBuilder<TypeParameterDiagnosticInfo> useSiteDiagnosticsBuilder = null;
bool result = delegateType.CheckConstraints(new ConstraintsHelper.CheckConstraintsArgs(compilation, conversions, includeNullability: false, NoLocation.Singleton, null, CompoundUseSiteInfo<AssemblySymbol>.Discarded), substitution, typeParameters, typeArguments, instance2, null, ref useSiteDiagnosticsBuilder);
instance2.Free();
return result;
}
}
internal static bool ReportDelegateInvokeUseSiteDiagnostic(BindingDiagnosticBag diagnostics, TypeSymbol possibleDelegateType, Location location = null, SyntaxNode node = null)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
if (!possibleDelegateType.IsDelegateType())
{
return false;
}
MethodSymbol methodSymbol = possibleDelegateType.DelegateInvokeMethod();
if ((object)methodSymbol == null)
{
diagnostics.Add((DiagnosticInfo?)(object)new CSDiagnosticInfo(ErrorCode.ERR_InvalidDelegateType, possibleDelegateType), getErrorLocation());
return true;
}
UseSiteInfo<AssemblySymbol> useSiteInfo = methodSymbol.GetUseSiteInfo();
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddDependencies(useSiteInfo);
DiagnosticInfo diagnosticInfo = useSiteInfo.DiagnosticInfo;
if (diagnosticInfo == null)
{
return false;
}
if (diagnosticInfo.Code == 7024)
{
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic((DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_InvalidDelegateType, possibleDelegateType), getErrorLocation()));
return true;
}
return Symbol.ReportUseSiteDiagnostic(diagnosticInfo, diagnostics, getErrorLocation());
Location getErrorLocation()
{
return location ?? GetAnonymousFunctionLocation(node);
}
}
private BoundConditionalAccess BindConditionalAccessExpression(ConditionalAccessExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureNullPropagatingOperator.CheckFeatureAvailability(diagnostics, node.OperatorToken);
BoundExpression boundExpression = BindConditionalAccessReceiver(node, diagnostics);
BoundExpression boundExpression2 = new BinderWithConditionalReceiver(this, boundExpression).BindValue(node.WhenNotNull, diagnostics, BindValueKind.RValue);
if (boundExpression.HasAnyErrors || boundExpression2.HasAnyErrors)
{
return new BoundConditionalAccess((SyntaxNode)(object)node, boundExpression, boundExpression2, CreateErrorType(), hasErrors: true);
}
_ = boundExpression.Type;
if (boundExpression2.Kind == BoundKind.MethodGroup)
{
return GenerateBadConditionalAccessNodeError(node, boundExpression, boundExpression2, diagnostics);
}
TypeSymbol typeSymbol = boundExpression2.Type;
if ((object)typeSymbol == null)
{
return GenerateBadConditionalAccessNodeError(node, boundExpression, boundExpression2, diagnostics);
}
if ((!typeSymbol.IsReferenceType && !typeSymbol.IsValueType) || typeSymbol.IsPointerOrFunctionPointer() || typeSymbol.IsRestrictedType())
{
bool flag = true;
CSharpSyntaxNode parent = node.Parent;
if (parent != null)
{
switch (parent.Kind())
{
case SyntaxKind.ExpressionStatement:
flag = ((ExpressionStatementSyntax)parent).Expression != node;
break;
case SyntaxKind.SimpleLambdaExpression:
flag = ((SimpleLambdaExpressionSyntax)parent).Body != node || MethodOrLambdaRequiresValue(ContainingMemberOrLambda, Compilation);
break;
case SyntaxKind.ParenthesizedLambdaExpression:
flag = ((ParenthesizedLambdaExpressionSyntax)parent).Body != node || MethodOrLambdaRequiresValue(ContainingMemberOrLambda, Compilation);
break;
case SyntaxKind.ArrowExpressionClause:
flag = ((ArrowExpressionClauseSyntax)parent).Expression != node || MethodOrLambdaRequiresValue(ContainingMemberOrLambda, Compilation);
break;
case SyntaxKind.ForStatement:
{
ForStatementSyntax forStatementSyntax = (ForStatementSyntax)parent;
flag = !forStatementSyntax.Incrementors.Contains((ExpressionSyntax)node) && !forStatementSyntax.Initializers.Contains((ExpressionSyntax)node);
break;
}
}
}
if (flag)
{
return GenerateBadConditionalAccessNodeError(node, boundExpression, boundExpression2, diagnostics);
}
typeSymbol = GetSpecialType((SpecialType)6, diagnostics, (SyntaxNode)(object)node);
}
if (typeSymbol.IsValueType && !typeSymbol.IsNullableType() && !typeSymbol.IsVoidType())
{
typeSymbol = GetSpecialType((SpecialType)32, diagnostics, (SyntaxNode)(object)node).Construct(typeSymbol);
}
return new BoundConditionalAccess((SyntaxNode)(object)node, boundExpression, boundExpression2, typeSymbol);
}
internal static bool MethodOrLambdaRequiresValue(Symbol symbol, CSharpCompilation compilation)
{
if (symbol is MethodSymbol { ReturnsVoid: false } methodSymbol)
{
return !methodSymbol.IsAsyncEffectivelyReturningTask(compilation);
}
return false;
}
private BoundConditionalAccess GenerateBadConditionalAccessNodeError(ConditionalAccessExpressionSyntax node, BoundExpression receiver, BoundExpression access, BindingDiagnosticBag diagnostics)
{
DiagnosticInfo info = (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_CannotBeMadeNullable, access.Display);
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic(info, access.Syntax.Location));
receiver = BadExpression(receiver.Syntax, receiver);
return new BoundConditionalAccess((SyntaxNode)(object)node, receiver, access, CreateErrorType(), hasErrors: true);
}
private BoundExpression BindMemberBindingExpression(MemberBindingExpressionSyntax node, bool invoked, bool indexed, BindingDiagnosticBag diagnostics)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
BoundExpression receiverForConditionalBinding = GetReceiverForConditionalBinding(node, diagnostics);
return BindMemberAccessWithBoundLeft(node, receiverForConditionalBinding, node.Name, node.OperatorToken, invoked, indexed, diagnostics);
}
private BoundExpression BindElementBindingExpression(ElementBindingExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
BoundExpression receiverForConditionalBinding = GetReceiverForConditionalBinding(node, diagnostics);
return BindElementAccess(node, receiverForConditionalBinding, node.ArgumentList, allowInlineArrayElementAccess: true, diagnostics);
}
private static CSharpSyntaxNode GetConditionalReceiverSyntax(ConditionalAccessExpressionSyntax node)
{
ExpressionSyntax expression = node.Expression;
while (((SyntaxNode?)(object)expression).IsKind(SyntaxKind.ParenthesizedExpression))
{
expression = ((ParenthesizedExpressionSyntax)expression).Expression;
}
return expression;
}
private BoundExpression GetReceiverForConditionalBinding(ExpressionSyntax binding, BindingDiagnosticBag diagnostics)
{
ConditionalAccessExpressionSyntax node = SyntaxFactory.FindConditionalAccessNodeForBinding(binding);
BoundExpression boundExpression = ConditionalReceiverExpression;
if ((object)boundExpression?.Syntax != GetConditionalReceiverSyntax(node))
{
boundExpression = BindConditionalAccessReceiver(node, diagnostics);
}
TypeSymbol typeSymbol = boundExpression.Type;
if ((object)typeSymbol != null && typeSymbol.IsNullableType())
{
typeSymbol = typeSymbol.GetNullableUnderlyingType();
}
return new BoundConditionalReceiver(boundExpression.Syntax, 0, typeSymbol ?? CreateErrorType(), boundExpression.HasErrors)
{
WasCompilerGenerated = true
};
}
private BoundExpression BindConditionalAccessReceiver(ConditionalAccessExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
ExpressionSyntax expression = node.Expression;
BoundExpression expr = BindRValueWithoutTargetType(expression, diagnostics);
expr = MakeMemberAccessValue(expr, diagnostics);
if (expr.HasAnyErrors)
{
return expr;
}
SyntaxToken operatorToken = node.OperatorToken;
if (expr.Kind == BoundKind.UnboundLambda)
{
MessageID messageID = ((UnboundLambda)expr).MessageID;
DiagnosticInfo info = (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_BadUnaryOp, SyntaxFacts.GetText(operatorToken.Kind()), messageID.Localize());
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic(info, ((SyntaxNode)node).Location));
return BadExpression((SyntaxNode)(object)expression, expr);
}
TypeSymbol type = expr.Type;
if ((object)type == null)
{
Error(diagnostics, ErrorCode.ERR_BadUnaryOp, ((SyntaxToken)(ref operatorToken)).GetLocation(), ((SyntaxToken)(ref operatorToken)).Text, expr.Display);
return BadExpression((SyntaxNode)(object)expression, expr);
}
if (type.IsVoidType())
{
Error(diagnostics, ErrorCode.ERR_BadUnaryOp, ((SyntaxToken)(ref operatorToken)).GetLocation(), ((SyntaxToken)(ref operatorToken)).Text, type);
return BadExpression((SyntaxNode)(object)expression, expr);
}
if (type.IsValueType && !type.IsNullableType())
{
Error(diagnostics, ErrorCode.ERR_BadUnaryOp, ((SyntaxToken)(ref operatorToken)).GetLocation(), ((SyntaxToken)(ref operatorToken)).Text, type);
return BadExpression((SyntaxNode)(object)expression, expr);
}
return expr;
}
internal Binder WithFlags(BinderFlags flags)
{
if (Flags != flags)
{
return new Binder(this, flags);
}
return this;
}
internal Binder WithAdditionalFlags(BinderFlags flags)
{
if (!Flags.Includes(flags))
{
return new Binder(this, Flags | flags);
}
return this;
}
internal Binder WithContainingMemberOrLambda(Symbol containing)
{
return new BinderWithContainingMemberOrLambda(this, containing);
}
internal Binder WithAdditionalFlagsAndContainingMemberOrLambda(BinderFlags flags, Symbol containing)
{
return new BinderWithContainingMemberOrLambda(this, Flags | flags, containing);
}
internal Binder WithUnsafeRegionIfNecessary(SyntaxTokenList modifiers)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (!Flags.Includes(BinderFlags.UnsafeRegion) && modifiers.Any(SyntaxKind.UnsafeKeyword))
{
return new Binder(this, Flags | BinderFlags.UnsafeRegion);
}
return this;
}
internal Binder WithCheckedOrUncheckedRegion(bool @checked)
{
BinderFlags binderFlags = (@checked ? BinderFlags.CheckedRegion : BinderFlags.UncheckedRegion);
BinderFlags binderFlags2 = (@checked ? BinderFlags.UncheckedRegion : BinderFlags.CheckedRegion);
if (!Flags.Includes(binderFlags))
{
return new Binder(this, (Flags & ~binderFlags2) | binderFlags);
}
return this;
}
internal static void BindFieldInitializers(CSharpCompilation compilation, SynthesizedInteractiveInitializerMethod? scriptInitializerOpt, ImmutableArray<ImmutableArray<FieldOrPropertyInitializer>> fieldInitializers, BindingDiagnosticBag diagnostics, ref ProcessedFieldInitializers processedInitializers)
{
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(withDiagnostics: true, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
processedInitializers.BoundInitializers = BindFieldInitializers(compilation, scriptInitializerOpt, fieldInitializers, instance, out ImportChain firstImportChain);
processedInitializers.HasErrors = ((BindingDiagnosticBag)instance).HasAnyErrors();
processedInitializers.FirstImportChain = firstImportChain;
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
}
internal static ImmutableArray<BoundInitializer> BindFieldInitializers(CSharpCompilation compilation, SynthesizedInteractiveInitializerMethod? scriptInitializerOpt, ImmutableArray<ImmutableArray<FieldOrPropertyInitializer>> initializers, BindingDiagnosticBag diagnostics, out ImportChain? firstImportChain)
{
if (initializers.IsEmpty)
{
firstImportChain = null;
return ImmutableArray<BoundInitializer>.Empty;
}
ArrayBuilder<BoundInitializer> instance = ArrayBuilder<BoundInitializer>.GetInstance();
if ((object)scriptInitializerOpt == null)
{
BindRegularCSharpFieldInitializers(compilation, initializers, instance, diagnostics, out firstImportChain);
}
else
{
BindScriptFieldInitializers(compilation, scriptInitializerOpt, initializers, instance, diagnostics, out firstImportChain);
}
return instance.ToImmutableAndFree();
}
internal static void BindRegularCSharpFieldInitializers(CSharpCompilation compilation, ImmutableArray<ImmutableArray<FieldOrPropertyInitializer>> initializers, ArrayBuilder<BoundInitializer> boundInitializers, BindingDiagnosticBag diagnostics, out ImportChain? firstDebugImports)
{
firstDebugImports = null;
ImmutableArray<ImmutableArray<FieldOrPropertyInitializer>>.Enumerator enumerator = initializers.GetEnumerator();
while (enumerator.MoveNext())
{
ImmutableArray<FieldOrPropertyInitializer> current = enumerator.Current;
BinderFactory binderFactory = null;
ImmutableArray<FieldOrPropertyInitializer>.Enumerator enumerator2 = current.GetEnumerator();
while (enumerator2.MoveNext())
{
FieldOrPropertyInitializer current2 = enumerator2.Current;
FieldSymbol fieldOpt = current2.FieldOpt;
if (fieldOpt.IsMetadataConstant)
{
continue;
}
SyntaxReference syntax = current2.Syntax;
SyntaxNode syntax2 = syntax.GetSyntax(default(CancellationToken));
if (!(syntax2 is EqualsValueClauseSyntax equalsValueClauseSyntax))
{
if (!(syntax2 is ParameterSyntax parameterSyntax))
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Binder/Binder_Initializers.cs", 138);
}
if (firstDebugImports == null)
{
if (binderFactory == null)
{
binderFactory = compilation.GetBinderFactory(syntax.SyntaxTree);
}
firstDebugImports = binderFactory.GetBinder((SyntaxNode)(object)parameterSyntax).ImportChain;
}
boundInitializers.Add((BoundInitializer)new BoundFieldEqualsValue((SyntaxNode)(object)parameterSyntax, fieldOpt, ImmutableArray<LocalSymbol>.Empty, new BoundParameter((SyntaxNode)(object)parameterSyntax, ((SynthesizedRecordPropertySymbol)fieldOpt.AssociatedSymbol).BackingParameter).MakeCompilerGenerated()));
}
else
{
if (binderFactory == null)
{
binderFactory = compilation.GetBinderFactory(syntax.SyntaxTree);
}
Binder binder = binderFactory.GetBinder((SyntaxNode)(object)equalsValueClauseSyntax);
if (firstDebugImports == null)
{
firstDebugImports = binder.ImportChain;
}
binder = binder.GetFieldInitializerBinder(fieldOpt);
BoundFieldEqualsValue boundFieldEqualsValue = BindFieldInitializer(binder, fieldOpt, equalsValueClauseSyntax, diagnostics);
boundInitializers.Add((BoundInitializer)boundFieldEqualsValue);
}
}
}
}
internal Binder GetFieldInitializerBinder(FieldSymbol fieldSymbol, bool suppressBinderFlagsFieldInitializer = false)
{
Binder next = this;
next = new WithPrimaryConstructorParametersBinder(fieldSymbol.ContainingType, next);
return new LocalScopeBinder(next).WithAdditionalFlagsAndContainingMemberOrLambda((!suppressBinderFlagsFieldInitializer) ? BinderFlags.FieldInitializer : BinderFlags.None, fieldSymbol);
}
private static void BindScriptFieldInitializers(CSharpCompilation compilation, SynthesizedInteractiveInitializerMethod scriptInitializer, ImmutableArray<ImmutableArray<FieldOrPropertyInitializer>> initializers, ArrayBuilder<BoundInitializer> boundInitializers, BindingDiagnosticBag diagnostics, out ImportChain? firstDebugImports)
{
firstDebugImports = null;
for (int i = 0; i < initializers.Length; i++)
{
ImmutableArray<FieldOrPropertyInitializer> immutableArray = initializers[i];
BinderFactory binderFactory = null;
ScriptLocalScopeBinder.Labels labels = null;
for (int j = 0; j < immutableArray.Length; j++)
{
FieldOrPropertyInitializer fieldOrPropertyInitializer = immutableArray[j];
FieldSymbol fieldOpt = fieldOrPropertyInitializer.FieldOpt;
if ((object)fieldOpt == null || !fieldOpt.IsConst)
{
SyntaxReference syntax = fieldOrPropertyInitializer.Syntax;
SyntaxTree syntaxTree = syntax.SyntaxTree;
CSharpSyntaxNode cSharpSyntaxNode = (CSharpSyntaxNode)(object)syntax.GetSyntax(default(CancellationToken));
CompilationUnitSyntax compilationUnitRoot = syntaxTree.GetCompilationUnitRoot();
if (binderFactory == null)
{
binderFactory = compilation.GetBinderFactory(syntaxTree);
labels = new ScriptLocalScopeBinder.Labels(scriptInitializer, compilationUnitRoot);
}
Binder binder = binderFactory.GetBinder((SyntaxNode)(object)cSharpSyntaxNode);
if (firstDebugImports == null)
{
firstDebugImports = binder.ImportChain;
}
Binder binder2 = new ExecutableCodeBinder((SyntaxNode)(object)compilationUnitRoot, scriptInitializer, new ScriptLocalScopeBinder(labels, binder));
BoundInitializer boundInitializer = (((object)fieldOpt == null) ? BindGlobalStatement(binder2, scriptInitializer, (StatementSyntax)cSharpSyntaxNode, diagnostics, i == initializers.Length - 1 && j == immutableArray.Length - 1) : BindFieldInitializer(binder2.WithAdditionalFlagsAndContainingMemberOrLambda(BinderFlags.FieldInitializer, fieldOpt), fieldOpt, (EqualsValueClauseSyntax)cSharpSyntaxNode, diagnostics));
boundInitializers.Add(boundInitializer);
}
}
}
}
private static BoundInitializer BindGlobalStatement(Binder binder, SynthesizedInteractiveInitializerMethod scriptInitializer, StatementSyntax statementNode, BindingDiagnosticBag diagnostics, bool isLast)
{
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
BoundStatement boundStatement = binder.BindStatement(statementNode, diagnostics);
if (isLast && !boundStatement.HasAnyErrors)
{
if (((Compilation)binder.Compilation).IsSubmission)
{
BoundExpression trailingScriptExpression = InitializerRewriter.GetTrailingScriptExpression(boundStatement);
if (trailingScriptExpression != null && ((object)trailingScriptExpression.Type == null || !trailingScriptExpression.Type.IsVoidType()))
{
TypeSymbol resultType = scriptInitializer.ResultType;
trailingScriptExpression = binder.GenerateConversionForAssignment(resultType, trailingScriptExpression, diagnostics);
boundStatement = new BoundExpressionStatement(boundStatement.Syntax, trailingScriptExpression, trailingScriptExpression.HasErrors);
}
}
if (boundStatement.Kind == BoundKind.LabeledStatement)
{
BoundStatement body = ((BoundLabeledStatement)boundStatement).Body;
while (body.Kind == BoundKind.LabeledStatement)
{
body = ((BoundLabeledStatement)body).Body;
}
if (InitializerRewriter.GetTrailingScriptExpression(body) != null)
{
Error(diagnostics, ErrorCode.ERR_SemicolonExpected, ((ExpressionStatementSyntax)(object)body.Syntax).SemicolonToken);
}
}
}
return new BoundGlobalStatementInitializer((SyntaxNode)(object)statementNode, boundStatement);
}
private static BoundFieldEqualsValue BindFieldInitializer(Binder binder, FieldSymbol fieldSymbol, EqualsValueClauseSyntax equalsValueClauseNode, BindingDiagnosticBag diagnostics)
{
ConsList<FieldSymbol> fieldsBeingBound = binder.FieldsBeingBound;
BindingDiagnosticBag diagnostics2 = ((!(fieldSymbol is SourceMemberFieldSymbolFromDeclarator sourceMemberFieldSymbolFromDeclarator) || !sourceMemberFieldSymbolFromDeclarator.FieldTypeInferred(fieldsBeingBound)) ? diagnostics : BindingDiagnosticBag.Discarded);
binder = new ExecutableCodeBinder((SyntaxNode)(object)equalsValueClauseNode, fieldSymbol, new LocalScopeBinder(binder));
return binder.BindFieldInitializer(fieldSymbol, equalsValueClauseNode, diagnostics2);
}
private BoundExpression BindInterpolatedString(InterpolatedStringExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_049a: Unknown result type (might be due to invalid IL or missing references)
//IL_049f: Unknown result type (might be due to invalid IL or missing references)
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
if (CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureInterpolatedStrings, diagnostics))
{
SyntaxKind syntaxKind = node.StringStartToken.Kind();
if (syntaxKind - 9072 <= SyntaxKind.List)
{
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureRawStringLiterals, diagnostics);
}
}
SyntaxToken val = node.StringStartToken;
if (((SyntaxToken)(ref val)).Text.StartsWith("@$\"") && !Compilation.IsFeatureEnabled(MessageID.IDS_FeatureAltInterpolatedVerbatimStrings))
{
val = node.StringStartToken;
Error(diagnostics, ErrorCode.ERR_AltInterpolatedVerbatimStringsNotAvailable, ((SyntaxToken)(ref val)).GetLocation(), new CSharpRequiredLanguageVersion(MessageID.IDS_FeatureAltInterpolatedVerbatimStrings.RequiredVersion()));
}
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance();
NamedTypeSymbol specialType = GetSpecialType((SpecialType)20, diagnostics, (SyntaxNode)(object)node);
ConstantValue val2 = null;
bool flag = true;
if (node.Contents.Count == 0)
{
val2 = ConstantValue.Create(string.Empty);
}
else
{
bool flag2 = node.StringStartToken.Kind() != SyntaxKind.InterpolatedVerbatimStringStartToken;
SyntaxKind syntaxKind = node.StringStartToken.Kind();
bool flag3 = syntaxKind - 9072 <= SyntaxKind.List;
bool flag4 = flag3;
bool flag5 = Compilation.IsFeatureEnabled(MessageID.IDS_FeatureNewLinesInInterpolations);
NamedTypeSymbol specialType2 = GetSpecialType((SpecialType)13, diagnostics, (SyntaxNode)(object)node);
Enumerator<InterpolatedStringContentSyntax> enumerator = node.Contents.GetEnumerator();
while (enumerator.MoveNext())
{
InterpolatedStringContentSyntax current = enumerator.Current;
switch (current.Kind())
{
case SyntaxKind.Interpolation:
{
InterpolationSyntax interpolationSyntax = (InterpolationSyntax)current;
if (flag2 && !interpolationSyntax.GetDiagnostics().Any((Diagnostic d) => (int)d.Severity == 3) && !flag5)
{
val = interpolationSyntax.OpenBraceToken;
if (!((SyntaxToken)(ref val)).IsMissing)
{
val = interpolationSyntax.CloseBraceToken;
if (!((SyntaxToken)(ref val)).IsMissing)
{
SourceText text2 = node.SyntaxTree.GetText(default(CancellationToken));
TextLineCollection lines = text2.Lines;
val = interpolationSyntax.OpenBraceToken;
TextLine lineFromPosition = lines.GetLineFromPosition(((SyntaxToken)(ref val)).SpanStart);
int lineNumber = ((TextLine)(ref lineFromPosition)).LineNumber;
TextLineCollection lines2 = text2.Lines;
val = interpolationSyntax.CloseBraceToken;
lineFromPosition = lines2.GetLineFromPosition(((SyntaxToken)(ref val)).SpanStart);
if (lineNumber != ((TextLine)(ref lineFromPosition)).LineNumber)
{
val = interpolationSyntax.CloseBraceToken;
diagnostics.Add(ErrorCode.ERR_NewlinesAreNotAllowedInsideANonVerbatimInterpolatedString, ((SyntaxToken)(ref val)).GetLocation(), Compilation.LanguageVersion.ToDisplayString(), new CSharpRequiredLanguageVersion(MessageID.IDS_FeatureNewLinesInInterpolations.RequiredVersion()));
}
}
}
}
BoundExpression boundExpression = BindValue(interpolationSyntax.Expression, diagnostics, BindValueKind.RValue);
BoundExpression boundExpression2 = null;
BoundLiteral format = null;
if (interpolationSyntax.AlignmentClause != null)
{
boundExpression2 = GenerateConversionForAssignment(specialType2, BindValue(interpolationSyntax.AlignmentClause.Value, diagnostics, BindValueKind.RValue), diagnostics);
ConstantValue constantValueOpt = boundExpression2.ConstantValueOpt;
if (constantValueOpt != (ConstantValue)null && !constantValueOpt.IsBad)
{
int int32Value = constantValueOpt.Int32Value;
int32Value = ((int32Value > 0) ? (-int32Value) : int32Value);
if (int32Value < -32767)
{
diagnostics.Add(ErrorCode.WRN_AlignmentMagnitude, boundExpression2.Syntax.Location, constantValueOpt.Int32Value, 32767);
}
}
else if (!boundExpression2.HasErrors)
{
diagnostics.Add(ErrorCode.ERR_ConstantExpected, ((SyntaxNode)interpolationSyntax.AlignmentClause.Value).Location);
}
}
if (interpolationSyntax.FormatClause != null)
{
val = interpolationSyntax.FormatClause.FormatStringToken;
string valueText = ((SyntaxToken)(ref val)).ValueText;
bool hasErrors = false;
char ch;
if (valueText.Length == 0)
{
diagnostics.Add(ErrorCode.ERR_EmptyFormatSpecifier, ((SyntaxNode)interpolationSyntax.FormatClause).Location);
hasErrors = true;
}
else if (SyntaxFacts.IsWhitespace(ch = valueText[valueText.Length - 1]) || SyntaxFacts.IsNewLine(ch))
{
diagnostics.Add(ErrorCode.ERR_TrailingWhitespaceInFormatSpecifier, ((SyntaxNode)interpolationSyntax.FormatClause).Location);
hasErrors = true;
}
format = new BoundLiteral((SyntaxNode)(object)interpolationSyntax.FormatClause, ConstantValue.Create(valueText), specialType, hasErrors);
}
instance.Add((BoundExpression)new BoundStringInsert((SyntaxNode)(object)interpolationSyntax, boundExpression, boundExpression2, format, isInterpolatedStringHandlerAppendCall: false));
if (flag && !(boundExpression.ConstantValueOpt == (ConstantValue)null) && interpolationSyntax != null && interpolationSyntax.FormatClause == null && interpolationSyntax.AlignmentClause == null)
{
ConstantValue constantValueOpt2 = boundExpression.ConstantValueOpt;
if (constantValueOpt2 != null && constantValueOpt2.IsString && !constantValueOpt2.IsBad)
{
val2 = ((val2 == null) ? boundExpression.ConstantValueOpt : FoldStringConcatenation(BinaryOperatorKind.StringConcatenation, val2, boundExpression.ConstantValueOpt));
break;
}
}
flag = false;
break;
}
case SyntaxKind.InterpolatedStringText:
{
val = ((InterpolatedStringTextSyntax)current).TextToken;
string text = ((SyntaxToken)(ref val)).ValueText;
if (!flag4)
{
text = unescapeInterpolatedStringLiteral(text);
}
ConstantValue val3 = ConstantValue.Create((object)text, (SpecialType)20);
instance.Add((BoundExpression)new BoundLiteral((SyntaxNode)(object)current, val3, specialType));
if (flag)
{
val2 = (ConstantValue)((val2 == null) ? ((object)val3) : ((object)FoldStringConcatenation(BinaryOperatorKind.StringConcatenation, val2, val3)));
}
break;
}
default:
throw ExceptionUtilities.UnexpectedValue((object)current.Kind());
}
}
if (!flag)
{
val2 = null;
}
}
return new BoundUnconvertedInterpolatedString((SyntaxNode)(object)node, instance.ToImmutableAndFree(), val2, specialType);
static string unescapeInterpolatedStringLiteral(string value)
{
PooledStringBuilder instance2 = PooledStringBuilder.GetInstance();
StringBuilder builder = instance2.Builder;
int i = 0;
for (int length = value.Length; i < length; i++)
{
char c = value[i];
builder.Append(c);
bool flag6 = ((c == '{' || c == '}') ? true : false);
if (flag6 && i + 1 < length && value[i + 1] == c)
{
i++;
}
}
string result = ((instance2.Length == value.Length) ? value : instance2.Builder.ToString());
instance2.Free();
return result;
}
}
private BoundInterpolatedString BindUnconvertedInterpolatedStringToString(BoundUnconvertedInterpolatedString unconvertedInterpolatedString, BindingDiagnosticBag diagnostics)
{
if (unconvertedInterpolatedString.ConstantValueOpt != null)
{
return constructWithData(BindInterpolatedStringParts(unconvertedInterpolatedString, diagnostics), null);
}
if (unconvertedInterpolatedString.Parts.Length <= 4 && AllInterpolatedStringPartsAreStrings(unconvertedInterpolatedString.Parts))
{
return constructWithData(BindInterpolatedStringParts(unconvertedInterpolatedString, diagnostics), null);
}
if (tryBindAsHandlerType(out var result))
{
return result;
}
return constructWithData(BindInterpolatedStringParts(unconvertedInterpolatedString, diagnostics), null);
BoundInterpolatedString constructWithData(ImmutableArray<BoundExpression> parts, InterpolatedStringHandlerData? data)
{
return new BoundInterpolatedString(unconvertedInterpolatedString.Syntax, data, parts, unconvertedInterpolatedString.ConstantValueOpt, unconvertedInterpolatedString.Type, unconvertedInterpolatedString.HasErrors);
}
bool tryBindAsHandlerType([NotNullWhen(true)] out BoundInterpolatedString? reference)
{
reference = null;
if (InExpressionTree || !InterpolatedStringPartsAreValidInDefaultHandler(unconvertedInterpolatedString))
{
return false;
}
NamedTypeSymbol wellKnownType = Compilation.GetWellKnownType((WellKnownType)310);
if (wellKnownType is MissingMetadataTypeSymbol)
{
return false;
}
reference = BindUnconvertedInterpolatedStringToHandlerType(unconvertedInterpolatedString, wellKnownType, diagnostics, isHandlerConversion: false);
return true;
}
}
private static bool InterpolatedStringPartsAreValidInDefaultHandler(BoundUnconvertedInterpolatedString unconvertedInterpolatedString)
{
if (!unconvertedInterpolatedString.Parts.ContainsAwaitExpression())
{
return unconvertedInterpolatedString.Parts.All(delegate(BoundExpression p)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Invalid comparison between Unknown and I4
int num;
if (p is BoundStringInsert boundStringInsert)
{
BoundExpression value = boundStringInsert.Value;
if (value != null)
{
TypeSymbol type = value.Type;
if ((object)type != null)
{
num = (((int)type.TypeKind == 4) ? 1 : 0);
goto IL_002a;
}
}
}
num = 0;
goto IL_002a;
IL_002a:
return num == 0;
});
}
return false;
}
private static bool AllInterpolatedStringPartsAreStrings(ImmutableArray<BoundExpression> parts)
{
return parts.All(delegate(BoundExpression p)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
if (!(p is BoundLiteral))
{
if (p is BoundStringInsert boundStringInsert)
{
BoundExpression value = boundStringInsert.Value;
if (value != null)
{
TypeSymbol type = value.Type;
if ((object)type != null && (int)type.SpecialType == 20 && boundStringInsert.Alignment == null && boundStringInsert.Format == null)
{
goto IL_0040;
}
}
}
return false;
}
goto IL_0040;
IL_0040:
return true;
});
}
private bool TryBindUnconvertedBinaryOperatorToDefaultInterpolatedStringHandler(BoundBinaryOperator binaryOperator, BindingDiagnosticBag diagnostics, [NotNullWhen(true)] out BoundBinaryOperator? convertedBinaryOperator)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
convertedBinaryOperator = null;
if (InExpressionTree)
{
return false;
}
NamedTypeSymbol wellKnownType = Compilation.GetWellKnownType((WellKnownType)310);
if (wellKnownType.IsErrorType())
{
return false;
}
if (binaryOperator.ConstantValueOpt != null)
{
return false;
}
ArrayBuilder<ImmutableArray<BoundExpression>> instance = ArrayBuilder<ImmutableArray<BoundExpression>>.GetInstance();
if (!binaryOperator.VisitBinaryOperatorInterpolatedString(instance, delegate(BoundUnconvertedInterpolatedString unconvertedInterpolatedString, ArrayBuilder<ImmutableArray<BoundExpression>> partsArrayBuilder)
{
if (!InterpolatedStringPartsAreValidInDefaultHandler(unconvertedInterpolatedString))
{
return false;
}
partsArrayBuilder.Add(unconvertedInterpolatedString.Parts);
return true;
}))
{
instance.Free();
return false;
}
int num = 0;
Enumerator<ImmutableArray<BoundExpression>> enumerator = instance.GetEnumerator();
while (enumerator.MoveNext())
{
ImmutableArray<BoundExpression> current = enumerator.Current;
num += current.Length;
if (num > 4 || !AllInterpolatedStringPartsAreStrings(current))
{
(ImmutableArray<ImmutableArray<BoundExpression>> AppendCalls, InterpolatedStringHandlerData Data) tuple = BindUnconvertedInterpolatedPartsToHandlerType(binaryOperator.Syntax, instance.ToImmutableAndFree(), wellKnownType, diagnostics, isHandlerConversion: false, default(ImmutableArray<BoundInterpolatedStringArgumentPlaceholder>), default(ImmutableArray<RefKind>));
ImmutableArray<ImmutableArray<BoundExpression>> item = tuple.AppendCalls;
InterpolatedStringHandlerData item2 = tuple.Data;
convertedBinaryOperator = UpdateBinaryOperatorWithInterpolatedContents(binaryOperator, item, item2, binaryOperator.Syntax, diagnostics);
return true;
}
}
instance.Free();
return false;
}
private BoundBinaryOperator UpdateBinaryOperatorWithInterpolatedContents(BoundBinaryOperator originalOperator, ImmutableArray<ImmutableArray<BoundExpression>> appendCalls, InterpolatedStringHandlerData data, SyntaxNode rootSyntax, BindingDiagnosticBag diagnostics)
{
NamedTypeSymbol specialType = GetSpecialType((SpecialType)20, diagnostics, rootSyntax);
Func<BoundUnconvertedInterpolatedString, int, (ImmutableArray<ImmutableArray<BoundExpression>>, TypeSymbol), BoundExpression> interpolatedStringFactory = createInterpolation;
Func<BoundBinaryOperator, BoundExpression, BoundExpression, (ImmutableArray<ImmutableArray<BoundExpression>>, TypeSymbol), BoundExpression> binaryOperatorFactory = createBinaryOperator;
return ((BoundBinaryOperator)originalOperator.RewriteInterpolatedStringAddition((appendCalls, specialType), interpolatedStringFactory, binaryOperatorFactory)).Update(BoundBinaryOperator.UncommonData.InterpolatedStringHandlerAddition(data));
static BoundBinaryOperator createBinaryOperator(BoundBinaryOperator original, BoundExpression left, BoundExpression right, (ImmutableArray<ImmutableArray<BoundExpression>> _, TypeSymbol @string) arg)
{
return new BoundBinaryOperator(original.Syntax, BinaryOperatorKind.StringConcatenation, left, right, original.ConstantValueOpt, null, null, LookupResultKind.Viable, default(ImmutableArray<MethodSymbol>), arg.@string, original.HasErrors);
}
static BoundInterpolatedString createInterpolation(BoundUnconvertedInterpolatedString expression, int i, (ImmutableArray<ImmutableArray<BoundExpression>> AppendCalls, TypeSymbol _) arg)
{
return new BoundInterpolatedString(expression.Syntax, null, arg.AppendCalls[i], expression.ConstantValueOpt, expression.Type, expression.HasErrors);
}
}
private BoundExpression BindUnconvertedInterpolatedExpressionToHandlerType(BoundExpression unconvertedExpression, NamedTypeSymbol interpolatedStringHandlerType, BindingDiagnosticBag diagnostics, ImmutableArray<BoundInterpolatedStringArgumentPlaceholder> additionalConstructorArguments = default(ImmutableArray<BoundInterpolatedStringArgumentPlaceholder>), ImmutableArray<RefKind> additionalConstructorRefKinds = default(ImmutableArray<RefKind>))
{
if (!(unconvertedExpression is BoundUnconvertedInterpolatedString unconvertedInterpolatedString))
{
if (unconvertedExpression is BoundBinaryOperator binaryOperator)
{
return BindUnconvertedBinaryOperatorToInterpolatedStringHandlerType(binaryOperator, interpolatedStringHandlerType, diagnostics, additionalConstructorArguments, additionalConstructorRefKinds);
}
throw ExceptionUtilities.UnexpectedValue((object)unconvertedExpression.Kind);
}
return BindUnconvertedInterpolatedStringToHandlerType(unconvertedInterpolatedString, interpolatedStringHandlerType, diagnostics, isHandlerConversion: true, additionalConstructorArguments, additionalConstructorRefKinds);
}
private BoundInterpolatedString BindUnconvertedInterpolatedStringToHandlerType(BoundUnconvertedInterpolatedString unconvertedInterpolatedString, NamedTypeSymbol interpolatedStringHandlerType, BindingDiagnosticBag diagnostics, bool isHandlerConversion, ImmutableArray<BoundInterpolatedStringArgumentPlaceholder> additionalConstructorArguments = default(ImmutableArray<BoundInterpolatedStringArgumentPlaceholder>), ImmutableArray<RefKind> additionalConstructorRefKinds = default(ImmutableArray<RefKind>))
{
var (immutableArray, value) = BindUnconvertedInterpolatedPartsToHandlerType(unconvertedInterpolatedString.Syntax, ImmutableArray.Create(unconvertedInterpolatedString.Parts), interpolatedStringHandlerType, diagnostics, isHandlerConversion, additionalConstructorArguments, additionalConstructorRefKinds);
return new BoundInterpolatedString(unconvertedInterpolatedString.Syntax, value, immutableArray[0], unconvertedInterpolatedString.ConstantValueOpt, unconvertedInterpolatedString.Type, unconvertedInterpolatedString.HasErrors);
}
private BoundBinaryOperator BindUnconvertedBinaryOperatorToInterpolatedStringHandlerType(BoundBinaryOperator binaryOperator, NamedTypeSymbol interpolatedStringHandlerType, BindingDiagnosticBag diagnostics, ImmutableArray<BoundInterpolatedStringArgumentPlaceholder> additionalConstructorArguments, ImmutableArray<RefKind> additionalConstructorRefKinds)
{
ArrayBuilder<ImmutableArray<BoundExpression>> instance = ArrayBuilder<ImmutableArray<BoundExpression>>.GetInstance();
binaryOperator.VisitBinaryOperatorInterpolatedString(instance, delegate(BoundUnconvertedInterpolatedString unconvertedInterpolatedString, ArrayBuilder<ImmutableArray<BoundExpression>> partsArrayBuilder)
{
partsArrayBuilder.Add(unconvertedInterpolatedString.Parts);
return true;
});
var (appendCalls, data) = BindUnconvertedInterpolatedPartsToHandlerType(binaryOperator.Syntax, instance.ToImmutableAndFree(), interpolatedStringHandlerType, diagnostics, isHandlerConversion: true, additionalConstructorArguments, additionalConstructorRefKinds);
return UpdateBinaryOperatorWithInterpolatedContents(binaryOperator, appendCalls, data, binaryOperator.Syntax, diagnostics);
}
private (ImmutableArray<ImmutableArray<BoundExpression>> AppendCalls, InterpolatedStringHandlerData Data) BindUnconvertedInterpolatedPartsToHandlerType(SyntaxNode syntax, ImmutableArray<ImmutableArray<BoundExpression>> partsArray, NamedTypeSymbol interpolatedStringHandlerType, BindingDiagnosticBag diagnostics, bool isHandlerConversion, ImmutableArray<BoundInterpolatedStringArgumentPlaceholder> additionalConstructorArguments, ImmutableArray<RefKind> additionalConstructorRefKinds)
{
additionalConstructorArguments = ImmutableArrayExtensions.NullToEmpty<BoundInterpolatedStringArgumentPlaceholder>(additionalConstructorArguments);
additionalConstructorRefKinds = ImmutableArrayExtensions.NullToEmpty<RefKind>(additionalConstructorRefKinds);
ReportUseSite(interpolatedStringHandlerType, diagnostics, syntax);
BoundInterpolatedStringHandlerPlaceholder boundInterpolatedStringHandlerPlaceholder = new BoundInterpolatedStringHandlerPlaceholder(syntax, interpolatedStringHandlerType)
{
WasCompilerGenerated = true
};
(ImmutableArray<ImmutableArray<BoundExpression>> AppendFormatCalls, bool UsesBoolReturn, ImmutableArray<ImmutableArray<(bool IsLiteral, bool HasAlignment, bool HasFormat)>>, int BaseStringLength, int NumFormatHoles) tuple = BindInterpolatedStringAppendCalls(partsArray, boundInterpolatedStringHandlerPlaceholder, diagnostics);
ImmutableArray<ImmutableArray<BoundExpression>> item = tuple.AppendFormatCalls;
bool item2 = tuple.UsesBoolReturn;
ImmutableArray<ImmutableArray<(bool, bool, bool)>> item3 = tuple.Item3;
int item4 = tuple.BaseStringLength;
int item5 = tuple.NumFormatHoles;
bool flag = false;
if (isHandlerConversion)
{
CheckFeatureAvailability(syntax, MessageID.IDS_FeatureImprovedInterpolatedStrings, diagnostics);
}
else if (!Compilation.IsFeatureEnabled(MessageID.IDS_FeatureImprovedInterpolatedStrings) && ((BindingDiagnosticBag)diagnostics).AccumulatesDiagnostics)
{
flag = true;
}
if (flag)
{
TypeSymbol specialType = GetSpecialType((SpecialType)1, diagnostics, syntax);
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(withDiagnostics: true, withDependencies: false);
ImmutableArray<ImmutableArray<BoundExpression>>.Enumerator enumerator = partsArray.GetEnumerator();
while (enumerator.MoveNext())
{
ImmutableArray<BoundExpression>.Enumerator enumerator2 = enumerator.Current.GetEnumerator();
while (enumerator2.MoveNext())
{
if (!(enumerator2.Current is BoundStringInsert boundStringInsert))
{
continue;
}
BoundExpression boundExpression = boundStringInsert.Value;
bool flag2 = false;
if ((object)boundExpression.Type != null)
{
boundExpression = BindToNaturalType(boundExpression, instance);
if (((BindingDiagnosticBag)instance).HasAnyErrors())
{
CheckFeatureAvailability(boundExpression.Syntax, MessageID.IDS_FeatureImprovedInterpolatedStrings, diagnostics);
flag2 = true;
}
}
if (!flag2)
{
GenerateConversionForAssignment(specialType, boundExpression, instance);
if (((BindingDiagnosticBag)instance).HasAnyErrors())
{
CheckFeatureAvailability(boundExpression.Syntax, MessageID.IDS_FeatureImprovedInterpolatedStrings, diagnostics);
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Clear();
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
}
NamedTypeSymbol specialType2 = GetSpecialType((SpecialType)13, diagnostics, syntax);
int num = 3 + additionalConstructorArguments.Length;
ArrayBuilder<BoundExpression> instance2 = ArrayBuilder<BoundExpression>.GetInstance(num);
ArrayBuilder<RefKind> instance3 = ArrayBuilder<RefKind>.GetInstance(num);
instance3.Add((RefKind)0);
instance3.Add((RefKind)0);
instance3.AddRange(additionalConstructorRefKinds);
NamedTypeSymbol specialType3 = GetSpecialType((SpecialType)7, diagnostics, syntax);
BoundInterpolatedStringArgumentPlaceholder item6 = new BoundInterpolatedStringArgumentPlaceholder(syntax, -2, specialType3)
{
WasCompilerGenerated = true
};
ImmutableArray<BoundInterpolatedStringArgumentPlaceholder> immutableArray = additionalConstructorArguments.Add(item6);
instance3.Add((RefKind)2);
populateArguments(syntax, immutableArray, item4, item5, specialType2, instance2);
BindingDiagnosticBag instance4 = BindingDiagnosticBag.GetInstance(withDiagnostics: true, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
BoundExpression boundExpression2 = MakeConstructorInvocation(interpolatedStringHandlerType, instance2, instance3, syntax, instance4);
BindingDiagnosticBag instance5;
BoundExpression boundExpression3;
BoundExpression boundExpression4;
if (!(boundExpression2 is BoundObjectCreationExpression) || boundExpression2.ResultKind != LookupResultKind.Viable)
{
instance2.Clear();
populateArguments(syntax, additionalConstructorArguments, item4, item5, specialType2, instance2);
instance3.RemoveLast();
instance5 = BindingDiagnosticBag.GetInstance(instance4);
boundExpression3 = MakeConstructorInvocation(interpolatedStringHandlerType, instance2, instance3, syntax, instance5);
if (boundExpression3 is BoundObjectCreationExpression && boundExpression3.ResultKind == LookupResultKind.Viable)
{
boundExpression4 = boundExpression3;
addAndFreeConstructorDiagnostics(diagnostics, instance5);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance4).Free();
}
else
{
DiagnosticBag diagnosticBag = ((BindingDiagnosticBag)instance5).DiagnosticBag;
bool num2 = diagnosticBag != null && diagnosticBag.AsEnumerableWithoutResolution().Any((Diagnostic d) => d.Code == 1729);
DiagnosticBag diagnosticBag2 = ((BindingDiagnosticBag)instance4).DiagnosticBag;
bool flag3 = diagnosticBag2 != null && diagnosticBag2.AsEnumerableWithoutResolution().Any((Diagnostic d) => d.Code == 1729);
if (num2)
{
if (flag3)
{
goto IL_0343;
}
boundExpression4 = boundExpression2;
additionalConstructorArguments = immutableArray;
addAndFreeConstructorDiagnostics(diagnostics, instance4);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance5).Free();
}
else
{
if (!flag3)
{
goto IL_0343;
}
boundExpression4 = boundExpression3;
addAndFreeConstructorDiagnostics(diagnostics, instance5);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance4).Free();
}
}
}
else
{
addAndFreeConstructorDiagnostics(diagnostics, instance4);
boundExpression4 = boundExpression2;
additionalConstructorArguments = immutableArray;
}
goto IL_036c;
IL_036c:
instance2.Free();
instance3.Free();
if (boundExpression4 is BoundDynamicObjectCreationExpression)
{
diagnostics.Add(ErrorCode.ERR_InterpolatedStringHandlerCreationCannotUseDynamic, syntax.Location, interpolatedStringHandlerType.Name);
}
InterpolatedStringHandlerData item7 = new InterpolatedStringHandlerData(interpolatedStringHandlerType, boundExpression4, item2, ImmutableArrayExtensions.NullToEmpty<BoundInterpolatedStringArgumentPlaceholder>(additionalConstructorArguments), item3, boundInterpolatedStringHandlerPlaceholder);
return (AppendCalls: item, Data: item7);
IL_0343:
boundExpression4 = boundExpression3;
addAndFreeConstructorDiagnostics(diagnostics, instance5);
addAndFreeConstructorDiagnostics(diagnostics, instance4);
goto IL_036c;
static void addAndFreeConstructorDiagnostics(BindingDiagnosticBag target, BindingDiagnosticBag source)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)target).AddDependencies((BindingDiagnosticBag<AssemblySymbol>)(object)source, false);
DiagnosticBag diagnosticBag3 = ((BindingDiagnosticBag)source).DiagnosticBag;
if (diagnosticBag3 != null && !diagnosticBag3.IsEmptyWithoutResolution)
{
foreach (Diagnostic item8 in diagnosticBag3.AsEnumerableWithoutResolution())
{
ErrorCode code = (ErrorCode)item8.Code;
if (((uint)(code - 9191) > 2u && code != ErrorCode.WRN_ArgExpectedIn) || 1 == 0)
{
((BindingDiagnosticBag)target).Add(item8);
}
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)source).Free();
}
static void populateArguments(SyntaxNode syntax2, ImmutableArray<BoundInterpolatedStringArgumentPlaceholder> immutableArray2, int baseStringLength, int numFormatHoles, NamedTypeSymbol intType, ArrayBuilder<BoundExpression> argumentsBuilder)
{
argumentsBuilder.Add((BoundExpression)new BoundLiteral(syntax2, ConstantValue.Create(baseStringLength), intType)
{
WasCompilerGenerated = true
});
argumentsBuilder.Add((BoundExpression)new BoundLiteral(syntax2, ConstantValue.Create(numFormatHoles), intType)
{
WasCompilerGenerated = true
});
argumentsBuilder.AddRange<BoundInterpolatedStringArgumentPlaceholder>(immutableArray2);
}
}
private ImmutableArray<BoundExpression> BindInterpolatedStringParts(BoundUnconvertedInterpolatedString unconvertedInterpolatedString, BindingDiagnosticBag diagnostics)
{
ArrayBuilder<BoundExpression> val = null;
NamedTypeSymbol specialType = GetSpecialType((SpecialType)1, diagnostics, unconvertedInterpolatedString.Syntax);
for (int i = 0; i < unconvertedInterpolatedString.Parts.Length; i++)
{
BoundExpression boundExpression = unconvertedInterpolatedString.Parts[i];
if (boundExpression is BoundStringInsert boundStringInsert)
{
BoundExpression boundExpression2;
if ((object)boundStringInsert.Value.Type == null)
{
boundExpression2 = GenerateConversionForAssignment(specialType, boundStringInsert.Value, diagnostics);
}
else
{
boundExpression2 = BindToNaturalType(boundStringInsert.Value, diagnostics);
GenerateConversionForAssignment(specialType, boundStringInsert.Value, diagnostics);
}
if (boundStringInsert.Value != boundExpression2)
{
if (val == null)
{
val = ArrayBuilder<BoundExpression>.GetInstance(unconvertedInterpolatedString.Parts.Length);
val.AddRange(unconvertedInterpolatedString.Parts, i);
}
val.Add((BoundExpression)boundStringInsert.Update(boundExpression2, boundStringInsert.Alignment, boundStringInsert.Format, isInterpolatedStringHandlerAppendCall: false));
}
else
{
val?.Add(boundExpression);
}
}
else
{
val?.Add(boundExpression);
}
}
return val?.ToImmutableAndFree() ?? unconvertedInterpolatedString.Parts;
}
private (ImmutableArray<ImmutableArray<BoundExpression>> AppendFormatCalls, bool UsesBoolReturn, ImmutableArray<ImmutableArray<(bool IsLiteral, bool HasAlignment, bool HasFormat)>>, int BaseStringLength, int NumFormatHoles) BindInterpolatedStringAppendCalls(ImmutableArray<ImmutableArray<BoundExpression>> partsArray, BoundInterpolatedStringHandlerPlaceholder implicitBuilderReceiver, BindingDiagnosticBag diagnostics)
{
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Invalid comparison between Unknown and I4
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Invalid comparison between Unknown and I4
if (partsArray.IsEmpty && partsArray.All<ImmutableArray<BoundExpression>>((ImmutableArray<BoundExpression> p) => p.IsEmpty))
{
return (AppendFormatCalls: ImmutableArray<ImmutableArray<BoundExpression>>.Empty, UsesBoolReturn: false, ImmutableArray<ImmutableArray<(bool, bool, bool)>>.Empty, BaseStringLength: 0, NumFormatHoles: 0);
}
bool? flag = null;
int length = partsArray[0].Length;
ArrayBuilder<ImmutableArray<BoundExpression>> instance = ArrayBuilder<ImmutableArray<BoundExpression>>.GetInstance(partsArray.Length);
ArrayBuilder<BoundExpression> instance2 = ArrayBuilder<BoundExpression>.GetInstance(length);
ArrayBuilder<ImmutableArray<(bool, bool, bool)>> instance3 = ArrayBuilder<ImmutableArray<(bool, bool, bool)>>.GetInstance(partsArray.Length);
ArrayBuilder<(bool, bool, bool)> instance4 = ArrayBuilder<(bool, bool, bool)>.GetInstance(length);
ArrayBuilder<BoundExpression> instance5 = ArrayBuilder<BoundExpression>.GetInstance(3);
ArrayBuilder<(string, Location)?> instance6 = ArrayBuilder<(string, Location)?>.GetInstance(3);
int num = 0;
int num2 = 0;
ImmutableArray<ImmutableArray<BoundExpression>>.Enumerator enumerator = partsArray.GetEnumerator();
while (enumerator.MoveNext())
{
ImmutableArray<BoundExpression>.Enumerator enumerator2 = enumerator.Current.GetEnumerator();
while (enumerator2.MoveNext())
{
BoundExpression current = enumerator2.Current;
string text;
bool item;
bool item2;
bool item3;
if (current is BoundStringInsert boundStringInsert)
{
text = "AppendFormatted";
instance5.Add(boundStringInsert.Value);
instance6.Add(((string, Location)?)null);
item = false;
item2 = false;
item3 = false;
if (boundStringInsert.Alignment != null)
{
item2 = true;
instance5.Add(boundStringInsert.Alignment);
instance6.Add(((string, Location)?)("alignment", boundStringInsert.Alignment.Syntax.Location));
}
if (boundStringInsert.Format != null)
{
item3 = true;
instance5.Add((BoundExpression)boundStringInsert.Format);
instance6.Add(((string, Location)?)("format", boundStringInsert.Format.Syntax.Location));
}
num2++;
}
else
{
BoundLiteral boundLiteral = (BoundLiteral)current;
string stringValue = boundLiteral.ConstantValueOpt.StringValue;
text = "AppendLiteral";
instance5.Add((BoundExpression)boundLiteral.Update(ConstantValue.Create(stringValue), boundLiteral.Type));
item = true;
item2 = false;
item3 = false;
num += stringValue.Length;
}
ImmutableArray<BoundExpression> args = instance5.ToImmutableAndClear();
ImmutableArray<(string, Location)?> immutableArray;
if (instance6.Count > 1)
{
immutableArray = instance6.ToImmutableAndClear();
}
else
{
immutableArray = default(ImmutableArray<(string, Location)?>);
instance6.Clear();
}
SyntaxNode syntax = current.Syntax;
string methodName = text;
ImmutableArray<(string, Location)?> names = immutableArray;
BoundExpression boundExpression = MakeInvocationExpression(syntax, implicitBuilderReceiver, methodName, args, diagnostics, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), names, null, allowFieldsAndProperties: false, allowUnexpandedForm: true, searchExtensionMethodsIfNecessary: false);
instance2.Add(boundExpression);
instance4.Add((item, item2, item3));
if (!(boundExpression is BoundCall boundCall))
{
continue;
}
MethodSymbol method = boundCall.Method;
if ((object)method != null)
{
TypeSymbol returnType = method.ReturnType;
bool flag2 = (int)returnType.SpecialType == 7;
if (!flag2 && (int)returnType.SpecialType != 6)
{
diagnostics.Add(ErrorCode.ERR_InterpolatedStringHandlerMethodReturnMalformed, current.Syntax.Location, method);
}
else if (!flag.HasValue)
{
flag = flag2;
}
else if (flag != flag2)
{
NamedTypeSymbol namedTypeSymbol = ((flag == true) ? Compilation.GetSpecialType((SpecialType)7) : Compilation.GetSpecialType((SpecialType)6));
diagnostics.Add(ErrorCode.ERR_InterpolatedStringHandlerMethodReturnInconsistent, current.Syntax.Location, method, namedTypeSymbol);
}
}
}
instance.Add(instance2.ToImmutableAndClear());
instance3.Add(instance4.ToImmutableAndClear());
}
instance5.Free();
instance6.Free();
instance2.Free();
instance4.Free();
return (AppendFormatCalls: instance.ToImmutableAndFree(), UsesBoolReturn: flag == true, instance3.ToImmutableAndFree(), BaseStringLength: num, NumFormatHoles: num2);
}
private BoundExpression BindInterpolatedStringHandlerInMemberCall(BoundExpression unconvertedString, ArrayBuilder<BoundExpression> arguments, ImmutableArray<ParameterSymbol> parameters, ref MemberAnalysisResult memberAnalysisResult, int interpolatedStringArgNum, BoundExpression? receiver, BindingDiagnosticBag diagnostics)
{
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_0304: Invalid comparison between Unknown and I4
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
Conversion conversion = memberAnalysisResult.ConversionForArg(interpolatedStringArgNum);
ParameterSymbol correspondingParameter = GetCorrespondingParameter(ref memberAnalysisResult, parameters, interpolatedStringArgNum);
if (correspondingParameter.HasInterpolatedStringHandlerArgumentError)
{
diagnostics.Add(ErrorCode.ERR_InterpolatedStringHandlerArgumentAttributeMalformed, unconvertedString.Syntax.Location, correspondingParameter, correspondingParameter.Type);
return CreateConversion(unconvertedString.Syntax, unconvertedString, conversion, isCast: false, null, wasCompilerGenerated: false, correspondingParameter.Type, diagnostics, hasErrors: true);
}
ImmutableArray<int> interpolatedStringHandlerArgumentIndexes = correspondingParameter.InterpolatedStringHandlerArgumentIndexes;
if (interpolatedStringHandlerArgumentIndexes.IsEmpty)
{
return CreateConversion(unconvertedString.Syntax, unconvertedString, conversion, isCast: false, null, correspondingParameter.IsParams ? ((ArrayTypeSymbol)correspondingParameter.Type).ElementType : correspondingParameter.Type, diagnostics);
}
ImmutableArray<int> immutableArray;
if (memberAnalysisResult.ArgsToParamsOpt.IsDefault && arguments.Count == parameters.Length)
{
immutableArray = interpolatedStringHandlerArgumentIndexes;
}
else
{
ArrayBuilder<int> instance = ArrayBuilder<int>.GetInstance(interpolatedStringHandlerArgumentIndexes.Length, -3);
for (int i = 0; i < interpolatedStringHandlerArgumentIndexes.Length; i++)
{
int num = interpolatedStringHandlerArgumentIndexes[i];
if (num == -1)
{
instance[i] = num;
continue;
}
for (int j = 0; j < arguments.Count; j++)
{
if (memberAnalysisResult.ParameterFromArgument(j) == num)
{
instance[i] = j;
}
}
}
immutableArray = instance.ToImmutableAndFree();
}
ArrayBuilder<BoundInterpolatedStringArgumentPlaceholder> instance2 = ArrayBuilder<BoundInterpolatedStringArgumentPlaceholder>.GetInstance(immutableArray.Length);
ArrayBuilder<RefKind> instance3 = ArrayBuilder<RefKind>.GetInstance(immutableArray.Length);
bool flag = false;
for (int k = 0; k < immutableArray.Length; k++)
{
int num2 = immutableArray[k];
RefKind val;
TypeSymbol type;
switch (num2)
{
case -1:
val = (RefKind)0;
type = receiver.Type;
break;
case -3:
{
int num3 = interpolatedStringHandlerArgumentIndexes[k];
ParameterSymbol parameterSymbol2 = parameters[num3];
if (parameterSymbol2.IsOptional || (num3 + 1 == parameters.Length && Microsoft.CodeAnalysis.CSharp.OverloadResolution.IsValidParamsParameter(parameterSymbol2)))
{
diagnostics.Add(ErrorCode.ERR_InterpolatedStringHandlerArgumentOptionalNotSpecified, unconvertedString.Syntax.Location, parameterSymbol2.Name, correspondingParameter.Name);
flag = true;
}
val = parameterSymbol2.RefKind;
type = parameterSymbol2.Type;
break;
}
default:
{
int index = interpolatedStringHandlerArgumentIndexes[k];
ParameterSymbol parameterSymbol = parameters[index];
if (num2 > interpolatedStringArgNum)
{
diagnostics.Add(ErrorCode.ERR_InterpolatedStringHandlerArgumentLocatedAfterInterpolatedString, arguments[num2].Syntax.Location, parameterSymbol.Name, correspondingParameter.Name);
flag = true;
}
val = parameterSymbol.RefKind;
type = parameterSymbol.Type;
break;
}
}
bool suppress;
SyntaxNode syntax;
if (num2 < 0)
{
switch (num2)
{
case -1:
suppress = receiver.IsSuppressed;
syntax = receiver.Syntax;
break;
case -3:
syntax = unconvertedString.Syntax;
suppress = false;
break;
default:
throw ExceptionUtilities.UnexpectedValue((object)num2);
}
}
else
{
syntax = arguments[num2].Syntax;
suppress = arguments[num2].IsSuppressed;
}
instance2.Add((BoundInterpolatedStringArgumentPlaceholder)new BoundInterpolatedStringArgumentPlaceholder(syntax, num2, type, num2 == -3)
{
WasCompilerGenerated = true
}.WithSuppression(suppress));
instance3.Add((RefKind)(((int)val == 4) ? 3 : ((int)val)));
}
BoundExpression boundExpression = BindUnconvertedInterpolatedExpressionToHandlerType(unconvertedString, (NamedTypeSymbol)correspondingParameter.Type, diagnostics, instance2.ToImmutableAndFree(), instance3.ToImmutableAndFree());
return new BoundConversion(boundExpression.Syntax, boundExpression, conversion, CheckOverflowAtRuntime, explicitCastInCode: false, null, null, correspondingParameter.Type, flag || boundExpression.HasErrors);
}
private BoundExpression BindMethodGroup(ExpressionSyntax node, bool invoked, bool indexed, BindingDiagnosticBag diagnostics)
{
switch (node.Kind())
{
case SyntaxKind.IdentifierName:
case SyntaxKind.GenericName:
return BindIdentifier((SimpleNameSyntax)node, invoked, indexed, diagnostics);
case SyntaxKind.SimpleMemberAccessExpression:
case SyntaxKind.PointerMemberAccessExpression:
return BindMemberAccess((MemberAccessExpressionSyntax)node, invoked, indexed, diagnostics);
case SyntaxKind.ParenthesizedExpression:
return BindMethodGroup(((ParenthesizedExpressionSyntax)node).Expression, invoked: false, indexed: false, diagnostics);
default:
return BindExpression(node, diagnostics, invoked, indexed);
}
}
private static ImmutableArray<MethodSymbol> GetOriginalMethods(OverloadResolutionResult<MethodSymbol> overloadResolutionResult)
{
if (overloadResolutionResult == null)
{
return ImmutableArray<MethodSymbol>.Empty;
}
ArrayBuilder<MethodSymbol> instance = ArrayBuilder<MethodSymbol>.GetInstance();
ImmutableArray<MemberResolutionResult<MethodSymbol>>.Enumerator enumerator = overloadResolutionResult.Results.GetEnumerator();
while (enumerator.MoveNext())
{
instance.Add(enumerator.Current.Member);
}
return instance.ToImmutableAndFree();
}
internal BoundExpression MakeInvocationExpression(SyntaxNode node, BoundExpression receiver, string methodName, ImmutableArray<BoundExpression> args, BindingDiagnosticBag diagnostics, SeparatedSyntaxList<TypeSyntax> typeArgsSyntax = default(SeparatedSyntaxList<TypeSyntax>), ImmutableArray<TypeWithAnnotations> typeArgs = default(ImmutableArray<TypeWithAnnotations>), ImmutableArray<(string Name, Location Location)?> names = default(ImmutableArray<(string Name, Location Location)?>), CSharpSyntaxNode? queryClause = null, bool allowFieldsAndProperties = false, bool allowUnexpandedForm = true, bool searchExtensionMethodsIfNecessary = true)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
receiver = BindToNaturalType(receiver, diagnostics);
BoundExpression boundExpression = BindInstanceMemberAccess(node, node, receiver, methodName, ImmutableArrayExtensions.NullToEmpty<TypeWithAnnotations>(typeArgs).Length, typeArgsSyntax, typeArgs, invoked: true, indexed: false, diagnostics, searchExtensionMethodsIfNecessary);
if (!allowFieldsAndProperties && (boundExpression.Kind == BoundKind.FieldAccess || boundExpression.Kind == BoundKind.PropertyAccess))
{
MessageID id;
Symbol item;
if (boundExpression.Kind == BoundKind.FieldAccess)
{
id = MessageID.IDS_SK_FIELD;
item = ((BoundFieldAccess)boundExpression).FieldSymbol;
}
else
{
id = MessageID.IDS_SK_PROPERTY;
item = ((BoundPropertyAccess)boundExpression).PropertySymbol;
}
diagnostics.Add(ErrorCode.ERR_BadSKknown, node.Location, methodName, id.Localize(), MessageID.IDS_SK_METHOD.Localize());
return BadExpression(node, LookupResultKind.Empty, ImmutableArray.Create(item), args.Add(receiver), wasCompilerGenerated: true);
}
boundExpression = CheckValue(boundExpression, BindValueKind.RValueOrMethodGroup, diagnostics);
boundExpression.WasCompilerGenerated = true;
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
instance.Arguments.AddRange(args);
if (!names.IsDefault)
{
instance.Names.AddRange(names);
}
BoundExpression boundExpression2 = BindInvocationExpression(node, node, methodName, boundExpression, instance, diagnostics, queryClause, allowUnexpandedForm);
if (queryClause != null && boundExpression2.Kind == BoundKind.DynamicInvocation)
{
boundExpression2 = CreateBadCall(node, boundExpression, LookupResultKind.Viable, instance);
}
boundExpression2.WasCompilerGenerated = true;
instance.Free();
return boundExpression2;
}
private BoundExpression BindInvocationExpression(InvocationExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
if (TryBindNameofOperator(node, diagnostics, out var result))
{
return result;
}
bool num = node.Expression.Kind() == SyntaxKind.ArgListExpression;
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
InvocationExpressionSyntax nested;
if (num)
{
BindArgumentsAndNames(node.ArgumentList, diagnostics, instance);
result = BindArgListOperator(node, diagnostics, instance);
}
else if (receiverIsInvocation(node, out nested))
{
ArrayBuilder<InvocationExpressionSyntax> instance2 = ArrayBuilder<InvocationExpressionSyntax>.GetInstance();
ArrayBuilderExtensions.Push<InvocationExpressionSyntax>(instance2, node);
node = nested;
while (receiverIsInvocation(node, out nested))
{
ArrayBuilderExtensions.Push<InvocationExpressionSyntax>(instance2, node);
node = nested;
}
BoundExpression boundExpression = BindMethodGroup(node.Expression, invoked: true, indexed: false, diagnostics);
while (true)
{
result = bindArgumentsAndInvocation(node, boundExpression, instance, diagnostics);
nested = node;
if (!ArrayBuilderExtensions.TryPop<InvocationExpressionSyntax>(instance2, ref node))
{
break;
}
MemberAccessExpressionSyntax memberAccessExpressionSyntax = (MemberAccessExpressionSyntax)node.Expression;
instance.Clear();
CheckContextForPointerTypes(nested, diagnostics, result);
boundExpression = BindMemberAccessWithBoundLeft(memberAccessExpressionSyntax, result, memberAccessExpressionSyntax.Name, memberAccessExpressionSyntax.OperatorToken, invoked: true, indexed: false, diagnostics);
}
instance2.Free();
}
else
{
BoundExpression boundExpression2 = BindMethodGroup(node.Expression, invoked: true, indexed: false, diagnostics);
result = bindArgumentsAndInvocation(node, boundExpression2, instance, diagnostics);
}
instance.Free();
return result;
BoundExpression bindArgumentsAndInvocation(InvocationExpressionSyntax invocationExpressionSyntax, BoundExpression boundExpression3, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics2)
{
boundExpression3 = CheckValue(boundExpression3, BindValueKind.RValueOrMethodGroup, diagnostics2);
string methodName = ((boundExpression3.Kind == BoundKind.MethodGroup) ? GetName(invocationExpressionSyntax.Expression) : null);
BindArgumentsAndNames(invocationExpressionSyntax.ArgumentList, diagnostics2, analyzedArguments, allowArglist: true);
return BindInvocationExpression((SyntaxNode)(object)invocationExpressionSyntax, (SyntaxNode)(object)invocationExpressionSyntax.Expression, methodName, boundExpression3, analyzedArguments, diagnostics2);
}
static bool receiverIsInvocation(InvocationExpressionSyntax invocationExpressionSyntax, out InvocationExpressionSyntax reference)
{
ExpressionSyntax expression = invocationExpressionSyntax.Expression;
if (expression is MemberAccessExpressionSyntax { Expression: InvocationExpressionSyntax expression2 } && ((SyntaxNode)expression).RawKind == 8689 && !expression2.MayBeNameofOperator())
{
reference = expression2;
return true;
}
reference = null;
return false;
}
}
private BoundExpression BindArgListOperator(InvocationExpressionSyntax node, BindingDiagnosticBag diagnostics, AnalyzedArguments analyzedArguments)
{
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Invalid comparison between Unknown and I4
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
bool hasErrors = analyzedArguments.HasErrors;
TypeSymbol specialType = GetSpecialType((SpecialType)1, diagnostics, (SyntaxNode)(object)node);
for (int i = 0; i < analyzedArguments.Arguments.Count; i++)
{
BoundExpression boundExpression = analyzedArguments.Arguments[i];
if (boundExpression.Kind == BoundKind.OutVariablePendingInference)
{
analyzedArguments.Arguments[i] = ((OutVariablePendingInference)boundExpression).FailInference(this, diagnostics);
}
else if ((object)boundExpression.Type == null && !boundExpression.HasAnyErrors)
{
analyzedArguments.Arguments[i] = GenerateConversionForAssignment(specialType, boundExpression, diagnostics);
}
else if (boundExpression.Type.IsVoidType())
{
Error(diagnostics, ErrorCode.ERR_CantUseVoidInArglist, SyntaxNodeOrToken.op_Implicit(boundExpression.Syntax));
hasErrors = true;
}
else if ((int)analyzedArguments.RefKind(i) == 0)
{
analyzedArguments.Arguments[i] = BindToNaturalType(analyzedArguments.Arguments[i], diagnostics);
}
RefKind val = analyzedArguments.RefKind(i);
if ((int)val > 1)
{
Error(diagnostics, ErrorCode.ERR_CantUseInOrOutInArglist, SyntaxNodeOrToken.op_Implicit(boundExpression.Syntax));
hasErrors = true;
}
}
ImmutableArray<BoundExpression> arguments = analyzedArguments.Arguments.ToImmutable();
ImmutableArray<RefKind> argumentRefKindsOpt = analyzedArguments.RefKinds.ToImmutableOrNull();
return new BoundArgListOperator((SyntaxNode)(object)node, arguments, argumentRefKindsOpt, null, hasErrors);
}
private BoundExpression BindInvocationExpression(SyntaxNode node, SyntaxNode expression, string methodName, BoundExpression boundExpression, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics, CSharpSyntaxNode queryClause = null, bool allowUnexpandedForm = true)
{
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Invalid comparison between Unknown and I4
BoundExpression boundExpression2;
NamedTypeSymbol delegateType;
if ((object)boundExpression.Type != null && boundExpression.Type.IsDynamic())
{
ReportSuppressionIfNeeded(boundExpression, diagnostics);
boundExpression2 = BindDynamicInvocation(node, boundExpression, analyzedArguments, ImmutableArray<MethodSymbol>.Empty, diagnostics, queryClause);
}
else if (boundExpression.Kind == BoundKind.MethodGroup)
{
ReportSuppressionIfNeeded(boundExpression, diagnostics);
boundExpression2 = BindMethodGroupInvocation(node, expression, methodName, (BoundMethodGroup)boundExpression, analyzedArguments, diagnostics, queryClause, allowUnexpandedForm, out var _);
}
else if ((object)(delegateType = GetDelegateType(boundExpression)) != null)
{
if (ReportDelegateInvokeUseSiteDiagnostic(diagnostics, delegateType, null, node))
{
return CreateBadCall(node, boundExpression, LookupResultKind.Viable, analyzedArguments);
}
boundExpression2 = BindDelegateInvocation(node, expression, methodName, boundExpression, analyzedArguments, diagnostics, queryClause, delegateType);
}
else
{
TypeSymbol? type = boundExpression.Type;
if ((object)type != null && (int)type.Kind == 20)
{
ReportSuppressionIfNeeded(boundExpression, diagnostics);
boundExpression2 = BindFunctionPointerInvocation(node, boundExpression, analyzedArguments, diagnostics);
}
else
{
if (!boundExpression.HasAnyErrors)
{
diagnostics.Add((DiagnosticInfo?)(object)new CSDiagnosticInfo(ErrorCode.ERR_MethodNameExpected), expression.Location);
}
boundExpression2 = CreateBadCall(node, boundExpression, LookupResultKind.NotInvocable, analyzedArguments);
}
}
CheckRestrictedTypeReceiver(boundExpression2, Compilation, diagnostics);
return boundExpression2;
}
private BoundExpression BindDynamicInvocation(SyntaxNode node, BoundExpression expression, AnalyzedArguments arguments, ImmutableArray<MethodSymbol> applicableMethods, BindingDiagnosticBag diagnostics, CSharpSyntaxNode queryClause)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
CheckNamedArgumentsForDynamicInvocation(arguments, diagnostics);
bool flag = false;
if (expression.Kind == BoundKind.MethodGroup)
{
BoundMethodGroup boundMethodGroup = (BoundMethodGroup)expression;
BoundExpression receiverOpt = boundMethodGroup.ReceiverOpt;
if (receiverOpt != null)
{
switch (receiverOpt.Kind)
{
case BoundKind.BaseReference:
Error(diagnostics, ErrorCode.ERR_NoDynamicPhantomOnBase, SyntaxNodeOrToken.op_Implicit(node), boundMethodGroup.Name);
flag = true;
break;
case BoundKind.ThisReference:
if ((InConstructorInitializer || InFieldInitializer) && receiverOpt.WasCompilerGenerated)
{
expression = boundMethodGroup.Update(boundMethodGroup.TypeArgumentsOpt, boundMethodGroup.Name, boundMethodGroup.Methods, boundMethodGroup.LookupSymbolOpt, boundMethodGroup.LookupError, (BoundMethodGroupFlags?)((uint?)boundMethodGroup.Flags & 0xFFFFFFFDu), boundMethodGroup.FunctionType, new BoundTypeExpression(node, null, ContainingType).MakeCompilerGenerated(), boundMethodGroup.ResultKind);
}
break;
case BoundKind.TypeOrValueExpression:
{
BoundTypeOrValueExpression boundTypeOrValueExpression = (BoundTypeOrValueExpression)receiverOpt;
bool inStaticContext;
bool useType = IsInstance(boundTypeOrValueExpression.Data.ValueSymbol) && !HasThis(isExplicit: false, out inStaticContext);
BoundExpression receiverOpt2 = ReplaceTypeOrValueReceiver(boundTypeOrValueExpression, useType, diagnostics);
expression = boundMethodGroup.Update(boundMethodGroup.TypeArgumentsOpt, boundMethodGroup.Name, boundMethodGroup.Methods, boundMethodGroup.LookupSymbolOpt, boundMethodGroup.LookupError, boundMethodGroup.Flags, boundMethodGroup.FunctionType, receiverOpt2, boundMethodGroup.ResultKind);
break;
}
}
}
}
else
{
expression = BindToNaturalType(expression, diagnostics);
}
ImmutableArray<BoundExpression> arguments2 = BuildArgumentsForDynamicInvocation(arguments, diagnostics);
ImmutableArray<RefKind> immutableArray = arguments.RefKinds.ToImmutableOrNull();
flag &= ReportBadDynamicArguments(node, arguments2, immutableArray, diagnostics, queryClause);
return new BoundDynamicInvocation(node, arguments.GetNames(), immutableArray, applicableMethods, expression, arguments2, Compilation.DynamicType, flag);
}
private void CheckNamedArgumentsForDynamicInvocation(AnalyzedArguments arguments, BindingDiagnosticBag diagnostics)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
if (arguments.Names.Count == 0 || !Compilation.LanguageVersion.AllowNonTrailingNamedArguments())
{
return;
}
bool flag = false;
for (int i = 0; i < arguments.Names.Count; i++)
{
if (arguments.Names[i].HasValue)
{
flag = true;
}
else if (flag)
{
Error(diagnostics, ErrorCode.ERR_NamedArgumentSpecificationBeforeFixedArgumentInDynamicInvocation, SyntaxNodeOrToken.op_Implicit(arguments.Arguments[i].Syntax));
break;
}
}
}
private ImmutableArray<BoundExpression> BuildArgumentsForDynamicInvocation(AnalyzedArguments arguments, BindingDiagnosticBag diagnostics)
{
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(arguments.Arguments.Count);
instance.AddRange(arguments.Arguments);
int i = 0;
for (int count = instance.Count; i < count; i++)
{
ArrayBuilder<BoundExpression> val = instance;
int num = i;
BoundExpression boundExpression = instance[i];
BoundExpression boundExpression2 = ((boundExpression is OutVariablePendingInference outVariablePendingInference) ? outVariablePendingInference.FailInference(this, diagnostics) : ((!(boundExpression is BoundDiscardExpression boundDiscardExpression) || boundDiscardExpression.HasExpressionType()) ? BindToNaturalType(boundExpression, diagnostics) : boundDiscardExpression.FailInference(this, diagnostics)));
val[num] = boundExpression2;
}
return instance.ToImmutableAndFree();
}
private static bool ReportBadDynamicArguments(SyntaxNode node, ImmutableArray<BoundExpression> arguments, ImmutableArray<RefKind> refKinds, BindingDiagnosticBag diagnostics, CSharpSyntaxNode queryClause)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
bool result = false;
bool flag = false;
if (!refKinds.IsDefault)
{
for (int i = 0; i < refKinds.Length; i++)
{
if ((int)refKinds[i] == 3)
{
Error(diagnostics, ErrorCode.ERR_InDynamicMethodArg, SyntaxNodeOrToken.op_Implicit(arguments[i].Syntax));
result = true;
}
}
}
ImmutableArray<BoundExpression>.Enumerator enumerator = arguments.GetEnumerator();
while (enumerator.MoveNext())
{
BoundExpression current = enumerator.Current;
if (!IsLegalDynamicOperand(current))
{
if (queryClause != null && !flag)
{
flag = true;
Error(diagnostics, ErrorCode.ERR_BadDynamicQuery, SyntaxNodeOrToken.op_Implicit(node));
result = true;
}
else if (current.Kind == BoundKind.Lambda || current.Kind == BoundKind.UnboundLambda)
{
Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArgLambda, SyntaxNodeOrToken.op_Implicit(current.Syntax));
result = true;
}
else if (current.Kind == BoundKind.MethodGroup)
{
Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArgMemgrp, SyntaxNodeOrToken.op_Implicit(current.Syntax));
result = true;
}
else if (current.Kind == BoundKind.ArgListOperator)
{
Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArg, SyntaxNodeOrToken.op_Implicit(current.Syntax), "__arglist");
}
else
{
Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArg, SyntaxNodeOrToken.op_Implicit(current.Syntax), current.Type);
result = true;
}
}
}
return result;
}
private BoundExpression BindDelegateInvocation(SyntaxNode node, SyntaxNode expression, string methodName, BoundExpression boundExpression, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics, CSharpSyntaxNode queryClause, NamedTypeSymbol delegateType)
{
//IL_0021: 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)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
MethodGroup instance = MethodGroup.GetInstance();
instance.PopulateWithSingleMethod(boundExpression, delegateType.DelegateInvokeMethod);
OverloadResolutionResult<MethodSymbol> instance2 = OverloadResolutionResult<MethodSymbol>.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
OverloadResolution.MethodInvocationOverloadResolution(instance.Methods, instance.TypeArguments, instance.Receiver, analyzedArguments, instance2, ref useSiteInfo, isMethodGroupConversion: false, allowRefOmittedArguments: false, inferWithDynamic: false, allowUnexpandedForm: true, (RefKind)0, null, isFunctionPointerResolution: false, isExtensionMethodResolution: false, default(CallingConventionInfo));
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
BoundExpression result = ((!analyzedArguments.HasDynamicArgument || !instance2.HasAnyApplicableMember) ? BindInvocationExpressionContinued(node, expression, methodName, instance2, analyzedArguments, instance, delegateType, diagnostics, queryClause) : BindDynamicInvocation(node, boundExpression, analyzedArguments, instance2.GetAllApplicableMembers(), diagnostics, queryClause));
instance2.Free();
instance.Free();
return result;
}
private static bool HasApplicableConditionalMethod(OverloadResolutionResult<MethodSymbol> results)
{
ImmutableArray<MemberResolutionResult<MethodSymbol>> results2 = results.Results;
for (int i = 0; i < results2.Length; i++)
{
if (results2[i].IsApplicable && results2[i].Member.IsConditional)
{
return true;
}
}
return false;
}
private BoundExpression BindMethodGroupInvocation(SyntaxNode syntax, SyntaxNode expression, string methodName, BoundMethodGroup methodGroup, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics, CSharpSyntaxNode queryClause, bool allowUnexpandedForm, out bool anyApplicableCandidates)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
MethodGroupResolution resolution = ResolveMethodGroup(methodGroup, expression, methodName, analyzedArguments, isMethodGroupConversion: false, ref useSiteInfo, inferWithDynamic: false, allowUnexpandedForm, (RefKind)0, null, isFunctionPointerResolution: false, default(CallingConventionInfo));
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(expression, useSiteInfo);
anyApplicableCandidates = resolution.ResultKind == LookupResultKind.Viable && resolution.OverloadResolutionResult.HasAnyApplicableMember;
if (!methodGroup.HasAnyErrors)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(resolution.Diagnostics, false);
}
BoundExpression result;
if (resolution.HasAnyErrors)
{
ImmutableArray<MethodSymbol> methods;
LookupResultKind resultKind;
ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations;
if (resolution.OverloadResolutionResult != null)
{
methods = GetOriginalMethods(resolution.OverloadResolutionResult);
resultKind = resolution.MethodGroup.ResultKind;
typeArgumentsWithAnnotations = resolution.MethodGroup.TypeArguments.ToImmutable();
}
else
{
methods = methodGroup.Methods;
resultKind = methodGroup.ResultKind;
typeArgumentsWithAnnotations = methodGroup.TypeArgumentsOpt;
}
result = CreateBadCall(syntax, methodName, methodGroup.ReceiverOpt, methods, resultKind, typeArgumentsWithAnnotations, analyzedArguments, resolution.IsExtensionMethodGroup, isDelegate: false);
}
else if (!resolution.IsEmpty)
{
if (resolution.ResultKind != LookupResultKind.Viable)
{
if (resolution.MethodGroup != null)
{
result = BindInvocationExpressionContinued(syntax, expression, methodName, resolution.OverloadResolutionResult, resolution.AnalyzedArguments, resolution.MethodGroup, null, BindingDiagnosticBag.Discarded, queryClause);
}
result = CreateBadCall(syntax, methodGroup, methodGroup.ResultKind, analyzedArguments);
}
else if (resolution.AnalyzedArguments.HasDynamicArgument && resolution.OverloadResolutionResult.HasAnyApplicableMember)
{
if (resolution.IsLocalFunctionInvocation)
{
result = BindLocalFunctionInvocationWithDynamicArgument(syntax, expression, methodName, methodGroup, diagnostics, queryClause, resolution);
}
else if (resolution.IsExtensionMethodGroup)
{
Error(diagnostics, ErrorCode.ERR_BadArgTypeDynamicExtension, SyntaxNodeOrToken.op_Implicit(syntax), methodGroup.InstanceOpt.Type, methodGroup.Name);
result = CreateBadCall(syntax, methodGroup, methodGroup.ResultKind, analyzedArguments);
}
else
{
if (HasApplicableConditionalMethod(resolution.OverloadResolutionResult))
{
Error(diagnostics, ErrorCode.WRN_DynamicDispatchToConditionalMethod, SyntaxNodeOrToken.op_Implicit(syntax), methodGroup.Name);
}
ImmutableArray<MethodSymbol> candidatesPassingFinalValidation = GetCandidatesPassingFinalValidation(syntax, resolution.OverloadResolutionResult, methodGroup.ReceiverOpt, methodGroup.TypeArgumentsOpt, diagnostics);
result = ((candidatesPassingFinalValidation.Length <= 0) ? CreateBadCall(syntax, methodGroup, methodGroup.ResultKind, analyzedArguments) : BindDynamicInvocation(syntax, methodGroup, resolution.AnalyzedArguments, candidatesPassingFinalValidation, diagnostics, queryClause));
}
}
else
{
result = BindInvocationExpressionContinued(syntax, expression, methodName, resolution.OverloadResolutionResult, resolution.AnalyzedArguments, resolution.MethodGroup, null, diagnostics, queryClause);
}
}
else
{
result = CreateBadCall(syntax, methodGroup, methodGroup.ResultKind, analyzedArguments);
}
resolution.Free();
return result;
}
private BoundExpression BindLocalFunctionInvocationWithDynamicArgument(SyntaxNode syntax, SyntaxNode expression, string methodName, BoundMethodGroup boundMethodGroup, BindingDiagnosticBag diagnostics, CSharpSyntaxNode queryClause, MethodGroupResolution resolution)
{
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
MemberResolutionResult<MethodSymbol> validResult = resolution.OverloadResolutionResult.ValidResult;
ImmutableArray<BoundExpression> arguments = resolution.AnalyzedArguments.Arguments.ToImmutable();
ImmutableArray<RefKind> refKinds = resolution.AnalyzedArguments.RefKinds.ToImmutableOrNull();
ReportBadDynamicArguments(syntax, arguments, refKinds, diagnostics, queryClause);
MethodSymbol member = validResult.Member;
MemberAnalysisResult result = validResult.Result;
if (Microsoft.CodeAnalysis.CSharp.OverloadResolution.IsValidParams(member) && result.Kind == MemberResolutionKind.ApplicableInNormalForm)
{
ImmutableArray<ParameterSymbol> parameters = member.Parameters;
int num = parameters.Length - 1;
for (int i = 0; i < arguments.Length; i++)
{
if (arguments[i].HasDynamicType() && result.ParameterFromArgument(i) == num)
{
Error(diagnostics, ErrorCode.ERR_DynamicLocalFunctionParamsParameter, SyntaxNodeOrToken.op_Implicit(syntax), parameters.Last().Name, member.Name);
return BindDynamicInvocation(syntax, boundMethodGroup, resolution.AnalyzedArguments, resolution.OverloadResolutionResult.GetAllApplicableMembers(), diagnostics, queryClause);
}
}
}
if (boundMethodGroup.TypeArgumentsOpt.IsDefaultOrEmpty && member.IsGenericMethod)
{
Error(diagnostics, ErrorCode.ERR_DynamicLocalFunctionTypeParameter, SyntaxNodeOrToken.op_Implicit(syntax), member.Name);
return BindDynamicInvocation(syntax, boundMethodGroup, resolution.AnalyzedArguments, resolution.OverloadResolutionResult.GetAllApplicableMembers(), diagnostics, queryClause);
}
return BindInvocationExpressionContinued(syntax, expression, methodName, resolution.OverloadResolutionResult, resolution.AnalyzedArguments, resolution.MethodGroup, null, diagnostics, queryClause);
}
private ImmutableArray<TMethodOrPropertySymbol> GetCandidatesPassingFinalValidation<TMethodOrPropertySymbol>(SyntaxNode syntax, OverloadResolutionResult<TMethodOrPropertySymbol> overloadResolutionResult, BoundExpression receiverOpt, ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, BindingDiagnosticBag diagnostics) where TMethodOrPropertySymbol : Symbol
{
ArrayBuilder<TMethodOrPropertySymbol> instance = ArrayBuilder<TMethodOrPropertySymbol>.GetInstance();
BindingDiagnosticBag bindingDiagnosticBag = null;
BindingDiagnosticBag instance2 = BindingDiagnosticBag.GetInstance(diagnostics);
int i = 0;
for (int count = overloadResolutionResult.ResultsBuilder.Count; i < count; i++)
{
MemberResolutionResult<TMethodOrPropertySymbol> memberResolutionResult = overloadResolutionResult.ResultsBuilder[i];
if (memberResolutionResult.Result.IsApplicable)
{
if (!MemberGroupFinalValidationAccessibilityChecks(receiverOpt, memberResolutionResult.Member, syntax, instance2, invokedAsExtensionMethod: false) && (typeArgumentsOpt.IsDefault || ((MethodSymbol)(object)memberResolutionResult.Member).CheckConstraints(new ConstraintsHelper.CheckConstraintsArgs(Compilation, Conversions, includeNullability: false, syntax.Location, instance2))))
{
instance.Add(memberResolutionResult.Member);
}
else if (bindingDiagnosticBag == null)
{
bindingDiagnosticBag = instance2;
instance2 = BindingDiagnosticBag.GetInstance(diagnostics);
}
else
{
((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).Clear();
}
}
}
if (bindingDiagnosticBag != null)
{
if (instance.Count == 0)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag, false);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag).Free();
}
((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).Free();
return instance.ToImmutableAndFree();
}
private void CheckRestrictedTypeReceiver(BoundExpression expression, CSharpCompilation compilation, BindingDiagnosticBag diagnostics)
{
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
switch (expression.Kind)
{
case BoundKind.Call:
{
BoundCall boundCall = (BoundCall)expression;
if (!boundCall.HasAnyErrors && boundCall.ReceiverOpt != null && (object)boundCall.ReceiverOpt.Type != null)
{
if (boundCall.ReceiverOpt.Type.IsRestrictedType() && !TypeSymbol.Equals(boundCall.Method.ContainingType, boundCall.ReceiverOpt.Type, (TypeCompareKind)0))
{
SymbolDistinguisher symbolDistinguisher = new SymbolDistinguisher(compilation, boundCall.ReceiverOpt.Type, boundCall.Method.ContainingType);
Error(diagnostics, ErrorCode.ERR_NoImplicitConv, SyntaxNodeOrToken.op_Implicit(boundCall.ReceiverOpt.Syntax), symbolDistinguisher.First, symbolDistinguisher.Second);
}
else if (boundCall.ReceiverOpt.Kind == BoundKind.BaseReference && ContainingType.IsRestrictedType())
{
SymbolDistinguisher symbolDistinguisher2 = new SymbolDistinguisher(compilation, ContainingType, boundCall.Method.ContainingType);
Error(diagnostics, ErrorCode.ERR_NoImplicitConv, SyntaxNodeOrToken.op_Implicit(boundCall.ReceiverOpt.Syntax), symbolDistinguisher2.First, symbolDistinguisher2.Second);
}
}
break;
}
case BoundKind.DynamicInvocation:
{
BoundDynamicInvocation boundDynamicInvocation = (BoundDynamicInvocation)expression;
if (!boundDynamicInvocation.HasAnyErrors && (object)boundDynamicInvocation.Expression.Type != null && boundDynamicInvocation.Expression.Type.IsRestrictedType())
{
Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArg, SyntaxNodeOrToken.op_Implicit(boundDynamicInvocation.Expression.Syntax), boundDynamicInvocation.Expression.Type);
}
break;
}
default:
throw ExceptionUtilities.UnexpectedValue((object)expression.Kind);
case BoundKind.FunctionPointerInvocation:
break;
}
}
private BoundCall BindInvocationExpressionContinued(SyntaxNode node, SyntaxNode expression, string methodName, OverloadResolutionResult<MethodSymbol> result, AnalyzedArguments analyzedArguments, MethodGroup methodGroup, NamedTypeSymbol delegateTypeOpt, BindingDiagnosticBag diagnostics, CSharpSyntaxNode queryClause = null)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Invalid comparison between Unknown and I4
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Invalid comparison between Unknown and I4
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
//IL_03da: Unknown result type (might be due to invalid IL or missing references)
//IL_038c: Unknown result type (might be due to invalid IL or missing references)
//IL_0451: Unknown result type (might be due to invalid IL or missing references)
//IL_0464: Unknown result type (might be due to invalid IL or missing references)
//IL_0405: Unknown result type (might be due to invalid IL or missing references)
bool isExtensionMethodGroup = methodGroup.IsExtensionMethodGroup;
if (!result.Succeeded)
{
if (analyzedArguments.HasErrors)
{
Enumerator<BoundExpression> enumerator = analyzedArguments.Arguments.GetEnumerator();
while (enumerator.MoveNext())
{
BoundExpression current = enumerator.Current;
if (!(current is UnboundLambda unboundLambda))
{
if (!(current is BoundUnconvertedObjectCreationExpression) && !(current is BoundTupleLiteral))
{
if (current is BoundUnconvertedSwitchExpression source)
{
TypeSymbol type = current.Type;
if ((object)type != null)
{
ConvertSwitchExpression(source, type, null, diagnostics);
}
}
else if (current is BoundUnconvertedConditionalOperator boundUnconvertedConditionalOperator)
{
TypeSymbol type2 = boundUnconvertedConditionalOperator.Type;
if ((object)type2 != null)
{
ConvertConditionalExpression(boundUnconvertedConditionalOperator, type2, null, diagnostics);
}
}
}
else
{
BindToNaturalType(current, diagnostics);
}
}
else
{
BoundLambda boundLambda = unboundLambda.BindForErrorRecovery();
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(boundLambda.Diagnostics, false);
}
}
}
else
{
string name = (((object)delegateTypeOpt == null) ? methodName : null);
result.ReportDiagnostics(this, GetLocationForOverloadResolutionDiagnostic(node, expression), node, diagnostics, name, methodGroup.Receiver, expression, analyzedArguments, methodGroup.Methods.ToImmutable(), null, delegateTypeOpt, queryClause);
}
return CreateBadCall(node, methodGroup.Name, (isExtensionMethodGroup && analyzedArguments.Arguments.Count > 0 && methodGroup.Receiver == analyzedArguments.Arguments[0]) ? null : methodGroup.Receiver, GetOriginalMethods(result), methodGroup.ResultKind, methodGroup.TypeArguments.ToImmutable(), analyzedArguments, isExtensionMethodGroup, (object)delegateTypeOpt != null);
}
MemberResolutionResult<MethodSymbol> validResult = result.ValidResult;
TypeSymbol returnType = validResult.Member.ReturnType;
MethodSymbol member = validResult.Member;
BoundExpression boundExpression = ReplaceTypeOrValueReceiver(methodGroup.Receiver, !member.RequiresInstanceReceiver && !isExtensionMethodGroup, diagnostics);
CheckAndCoerceArguments(validResult, analyzedArguments, diagnostics, boundExpression, isExtensionMethodGroup);
bool expanded = validResult.Result.Kind == MemberResolutionKind.ApplicableInExpandedForm;
ImmutableArray<int> argsToParamsOpt = validResult.Result.ArgsToParamsOpt;
BindDefaultArguments(node, member.Parameters, analyzedArguments.Arguments, analyzedArguments.RefKinds, ref argsToParamsOpt, out var defaultArguments, expanded, enableCallerInfo: true, diagnostics);
bool flag = MemberGroupFinalValidation(boundExpression, member, expression, diagnostics, isExtensionMethodGroup);
CheckImplicitThisCopyInReadOnlyMember(boundExpression, member, diagnostics);
if (isExtensionMethodGroup)
{
BoundExpression boundExpression2 = analyzedArguments.Argument(0);
ParameterSymbol parameterSymbol = member.Parameters.First();
if (boundExpression != boundExpression2)
{
boundExpression2 = CreateConversion(boundExpression, validResult.Result.ConversionForArg(0), parameterSymbol.Type, diagnostics);
}
if ((int)parameterSymbol.RefKind == 1)
{
boundExpression2 = CheckValue(boundExpression2, BindValueKind.RefOrOut, diagnostics);
if (analyzedArguments.RefKinds.Count == 0)
{
analyzedArguments.RefKinds.Count = analyzedArguments.Arguments.Count;
}
analyzedArguments.RefKinds[0] = (RefKind)1;
CheckFeatureAvailability(boundExpression2.Syntax, MessageID.IDS_FeatureRefExtensionMethods, diagnostics);
}
else if ((int)parameterSymbol.RefKind == 3)
{
CheckFeatureAvailability(boundExpression2.Syntax, MessageID.IDS_FeatureRefExtensionMethods, diagnostics);
}
analyzedArguments.Arguments[0] = boundExpression2;
}
if (isExtensionMethodGroup || (!member.RequiresInstanceReceiver && boundExpression != null && boundExpression.WasCompilerGenerated))
{
boundExpression = null;
}
ImmutableArray<string> names = analyzedArguments.GetNames();
ImmutableArray<RefKind> argumentRefKindsOpt = analyzedArguments.RefKinds.ToImmutableOrNull();
ImmutableArray<BoundExpression> arguments = analyzedArguments.Arguments.ToImmutable();
if (!flag && member.RequiresInstanceReceiver && boundExpression != null && boundExpression.Kind == BoundKind.ThisReference && boundExpression.WasCompilerGenerated)
{
flag = IsRefOrOutThisParameterCaptured(SyntaxNodeOrToken.op_Implicit(node), diagnostics);
}
if (member.HasParameterContainingPointerType())
{
flag = ReportUnsafeIfNotAllowed(node, diagnostics) || flag;
}
bool flag2 = boundExpression != null && boundExpression.Kind == BoundKind.BaseReference;
ReportDiagnosticsIfObsolete(diagnostics, member, SyntaxNodeOrToken.op_Implicit(node), flag2);
ReportDiagnosticsIfUnmanagedCallersOnly(diagnostics, member, SyntaxNodeOrToken.op_Implicit(node), isDelegateConversion: false);
if (member.IsRuntimeFinalizer())
{
ErrorCode code = (flag2 ? ErrorCode.ERR_CallingBaseFinalizeDeprecated : ErrorCode.ERR_CallingFinalizeDeprecated);
Error(diagnostics, code, SyntaxNodeOrToken.op_Implicit(node));
flag = true;
}
bool flag3 = (object)delegateTypeOpt != null;
if (!flag3 && member.RequiresInstanceReceiver)
{
WarnOnAccessOfOffDefault((SyntaxNode)(object)((node.Kind() == SyntaxKind.InvocationExpression) ? ((InvocationExpressionSyntax)(object)node).Expression : ((ExpressionSyntax)(object)node)), boundExpression, diagnostics);
}
return new BoundCall(node, boundExpression, ReceiverIsSubjectToCloning(boundExpression, member), member, arguments, names, argumentRefKindsOpt, flag3, expanded, isExtensionMethodGroup, argsToParamsOpt, defaultArguments, LookupResultKind.Viable, returnType, flag);
}
internal ThreeState ReceiverIsSubjectToCloning(BoundExpression? receiver, PropertySymbol property)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
MethodSymbol methodSymbol = property.GetMethod ?? property.SetMethod;
if ((object)methodSymbol == null)
{
return (ThreeState)1;
}
return ReceiverIsSubjectToCloning(receiver, methodSymbol);
}
internal ThreeState ReceiverIsSubjectToCloning(BoundExpression? receiver, MethodSymbol method)
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
if (receiver is BoundValuePlaceholderBase || receiver == null || receiver.Type?.IsValueType != true)
{
return (ThreeState)1;
}
BindValueKind valueKind = (method.IsEffectivelyReadOnly ? BindValueKind.RefersToLocation : (BindValueKind.Assignable | BindValueKind.RefersToLocation));
return ThreeStateHelpers.ToThreeState(!CheckValueKind(receiver.Syntax, receiver, valueKind, checkingReceiver: true, BindingDiagnosticBag.Discarded));
}
private static SourceLocation GetCallerLocation(SyntaxNode syntax)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Expected O, but got Unknown
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken val = ((syntax is InvocationExpressionSyntax invocationExpressionSyntax) ? invocationExpressionSyntax.ArgumentList.OpenParenToken : ((syntax is BaseObjectCreationExpressionSyntax baseObjectCreationExpressionSyntax) ? baseObjectCreationExpressionSyntax.NewKeyword : ((syntax is ConstructorInitializerSyntax constructorInitializerSyntax) ? constructorInitializerSyntax.ArgumentList.OpenParenToken : ((syntax is PrimaryConstructorBaseTypeSyntax primaryConstructorBaseTypeSyntax) ? primaryConstructorBaseTypeSyntax.ArgumentList.OpenParenToken : ((!(syntax is ElementAccessExpressionSyntax elementAccessExpressionSyntax)) ? syntax.GetFirstToken(false, false, false, false) : elementAccessExpressionSyntax.ArgumentList.OpenBracketToken)))));
SyntaxToken val2 = val;
return new SourceLocation(ref val2);
}
private BoundExpression GetDefaultParameterSpecialNoConversion(SyntaxNode syntax, ParameterSymbol parameter, BindingDiagnosticBag diagnostics)
{
TypeSymbol type = parameter.Type;
BoundExpression boundExpression = null;
if (InAttributeArgument)
{
diagnostics.Add(ErrorCode.ERR_BadAttributeParamDefaultArgument, syntax.Location, parameter.Name);
}
else if (parameter.IsMarshalAsObject)
{
boundExpression = new BoundDefaultExpression(syntax, type)
{
WasCompilerGenerated = true
};
}
else if (parameter.IsIUnknownConstant)
{
if (GetWellKnownTypeMember(Compilation, (WellKnownMember)78, diagnostics, null, syntax) is MethodSymbol constructor)
{
BoundDefaultExpression boundDefaultExpression = new BoundDefaultExpression(syntax, type)
{
WasCompilerGenerated = true
};
boundExpression = new BoundObjectCreationExpression(syntax, constructor, boundDefaultExpression)
{
WasCompilerGenerated = true
};
}
}
else if (parameter.IsIDispatchConstant)
{
if (GetWellKnownTypeMember(Compilation, (WellKnownMember)79, diagnostics, null, syntax) is MethodSymbol constructor2)
{
BoundDefaultExpression boundDefaultExpression2 = new BoundDefaultExpression(syntax, type)
{
WasCompilerGenerated = true
};
boundExpression = new BoundObjectCreationExpression(syntax, constructor2, boundDefaultExpression2)
{
WasCompilerGenerated = true
};
}
}
else if (GetWellKnownTypeMember(Compilation, (WellKnownMember)43, diagnostics, null, syntax) is FieldSymbol fieldSymbol)
{
boundExpression = new BoundFieldAccess(syntax, null, fieldSymbol, null)
{
WasCompilerGenerated = true
};
}
return boundExpression ?? BadExpression(syntax).MakeCompilerGenerated();
}
internal static ParameterSymbol? GetCorrespondingParameter(int argumentOrdinal, ImmutableArray<ParameterSymbol> parameters, ImmutableArray<int> argsToParamsOpt, bool expanded)
{
int length = parameters.Length;
if (argsToParamsOpt.IsDefault)
{
if (argumentOrdinal < length)
{
return parameters[argumentOrdinal];
}
if (expanded)
{
return parameters[length - 1];
}
return null;
}
int num = argsToParamsOpt[argumentOrdinal];
if (num < length)
{
return parameters[num];
}
return null;
}
internal void BindDefaultArguments(SyntaxNode node, ImmutableArray<ParameterSymbol> parameters, ArrayBuilder<BoundExpression> argumentsBuilder, ArrayBuilder<RefKind>? argumentRefKindsBuilder, ref ImmutableArray<int> argsToParamsOpt, out BitVector defaultArguments, bool expanded, bool enableCallerInfo, BindingDiagnosticBag diagnostics, bool assertMissingParametersAreOptional = true, Symbol? attributedMember = null)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
BitVector val = BitVector.Create(parameters.Length);
for (int i = 0; i < argumentsBuilder.Count; i++)
{
ParameterSymbol correspondingParameter = GetCorrespondingParameter(i, parameters, argsToParamsOpt, expanded);
if ((object)correspondingParameter != null)
{
((BitVector)(ref val))[correspondingParameter.Ordinal] = true;
}
}
if (ImmutableArrayExtensions.All<ParameterSymbol, BitVector>(parameters, (Func<ParameterSymbol, BitVector, bool>)((ParameterSymbol param, BitVector visitedParameters) => ((BitVector)(ref visitedParameters))[param.Ordinal]), val))
{
defaultArguments = default(BitVector);
return;
}
Symbol symbol;
if (InAttributeArgument)
{
symbol = attributedMember;
}
else
{
Symbol symbol2 = ContainingMember();
Symbol symbol3 = ((!(symbol2 is FieldSymbol { AssociatedSymbol: { } associatedSymbol })) ? symbol2 : associatedSymbol);
symbol = symbol3;
}
Symbol containingMember = symbol;
defaultArguments = BitVector.Create(parameters.Length);
ArrayBuilder<int> val2 = null;
if (!argsToParamsOpt.IsDefault)
{
val2 = ArrayBuilder<int>.GetInstance(argsToParamsOpt.Length);
val2.AddRange(argsToParamsOpt);
}
Index index = (expanded ? (^1) : (^0));
int count = argumentsBuilder.Count;
ReadOnlySpan<ParameterSymbol> readOnlySpan = parameters.AsSpan();
ReadOnlySpan<ParameterSymbol> readOnlySpan2 = readOnlySpan.Slice(0, index.GetOffset(readOnlySpan.Length));
for (int num = 0; num < readOnlySpan2.Length; num++)
{
ParameterSymbol parameterSymbol = readOnlySpan2[num];
if (!((BitVector)(ref val))[parameterSymbol.Ordinal])
{
((BitVector)(ref defaultArguments))[argumentsBuilder.Count] = true;
argumentsBuilder.Add(bindDefaultArgument(node, parameterSymbol, containingMember, enableCallerInfo, diagnostics, argumentsBuilder, count, argsToParamsOpt));
if (argumentRefKindsBuilder != null && argumentRefKindsBuilder.Count > 0)
{
argumentRefKindsBuilder.Add((RefKind)0);
}
val2?.Add(parameterSymbol.Ordinal);
}
}
if (val2 != null)
{
argsToParamsOpt = val2.ToImmutableOrNull();
val2.Free();
}
BoundExpression bindDefaultArgument(SyntaxNode syntax, ParameterSymbol parameter, Symbol? symbol4, bool flag, BindingDiagnosticBag bindingDiagnosticBag, ArrayBuilder<BoundExpression> val6, int argumentsCount, ImmutableArray<int> argsToParamsOpt2)
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Invalid comparison between Unknown and I4
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Invalid comparison between Unknown and I4
//IL_0304: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Invalid comparison between Unknown and I4
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Invalid comparison between Unknown and I4
TypeSymbol type = parameter.Type;
if (Flags.Includes(BinderFlags.ParameterDefaultValue))
{
return new BoundDefaultExpression(syntax, type)
{
WasCompilerGenerated = true
};
}
ConstantValue explicitDefaultConstantValue = parameter.ExplicitDefaultConstantValue;
if (InAttributeArgument && explicitDefaultConstantValue != null && explicitDefaultConstantValue.IsBad)
{
bindingDiagnosticBag.Add(ErrorCode.ERR_BadAttributeArgument, syntax.Location);
return BadExpression(syntax).MakeCompilerGenerated();
}
ConstantValue val3 = ((explicitDefaultConstantValue == null || !explicitDefaultConstantValue.IsBad) ? explicitDefaultConstantValue : ConstantValue.Null);
ConstantValue val4 = val3;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
SourceLocation val5 = (flag ? GetCallerLocation(syntax) : null);
BoundExpression boundExpression;
if (val5 != null && parameter.IsCallerLineNumber)
{
int displayLineNumber = ((Location)val5).SourceTree.GetDisplayLineNumber(((Location)val5).SourceSpan);
boundExpression = new BoundLiteral(syntax, ConstantValue.Create(displayLineNumber), Compilation.GetSpecialType((SpecialType)13))
{
WasCompilerGenerated = true
};
}
else if (val5 != null && parameter.IsCallerFilePath)
{
string displayPath = ((Location)val5).SourceTree.GetDisplayPath(((Location)val5).SourceSpan, ((CompilationOptions)Compilation.Options).SourceReferenceResolver);
boundExpression = new BoundLiteral(syntax, ConstantValue.Create(displayPath), Compilation.GetSpecialType((SpecialType)20))
{
WasCompilerGenerated = true
};
}
else if (val5 != null && parameter.IsCallerMemberName && (object)symbol4 != null)
{
string memberCallerName = symbol4.GetMemberCallerName();
boundExpression = new BoundLiteral(syntax, ConstantValue.Create(memberCallerName), Compilation.GetSpecialType((SpecialType)20))
{
WasCompilerGenerated = true
};
}
else
{
if (val5 != null && !parameter.IsCallerMemberName && Conversions.ClassifyBuiltInConversion(Compilation.GetSpecialType((SpecialType)20), type, isChecked: false, ref useSiteInfo).Exists)
{
int num2 = getArgumentIndex(parameter.CallerArgumentExpressionParameterIndex, argsToParamsOpt2);
if (num2 > -1 && num2 < argumentsCount)
{
BoundExpression boundExpression2 = val6[num2];
boundExpression = new BoundLiteral(syntax, ConstantValue.Create(((object)boundExpression2.Syntax).ToString()), Compilation.GetSpecialType((SpecialType)20))
{
WasCompilerGenerated = true
};
goto IL_02b5;
}
}
if (val4 == (ConstantValue)null)
{
boundExpression = ((!type.IsDynamic() && (int)type.SpecialType != 1) ? new BoundDefaultExpression(syntax, type)
{
WasCompilerGenerated = true
} : GetDefaultParameterSpecialNoConversion(syntax, parameter, bindingDiagnosticBag));
}
else if (val4.IsNull)
{
boundExpression = new BoundDefaultExpression(syntax, type)
{
WasCompilerGenerated = true
};
}
else
{
TypeSymbol specialType = Compilation.GetSpecialType(val4.SpecialType);
boundExpression = new BoundLiteral(syntax, val4, specialType)
{
WasCompilerGenerated = true
};
if (InAttributeArgument && (int)type.SpecialType == 1)
{
bindingDiagnosticBag.Add(ErrorCode.ERR_NotNullRefDefaultParameter, syntax.Location, parameter.Name, type);
}
}
}
goto IL_02b5;
IL_0312:
bool flag3;
bool flag2 = flag3;
goto IL_0316;
IL_0316:
if (flag2)
{
return new BoundDefaultExpression(syntax, type)
{
WasCompilerGenerated = true
};
}
Conversion conversion;
if (!conversion.IsValid)
{
GenerateImplicitConversionError(bindingDiagnosticBag, syntax, conversion, boundExpression, type);
}
bool isExplicit = conversion.IsExplicit;
return CreateConversion(boundExpression.Syntax, boundExpression, conversion, isExplicit, isExplicit ? new ConversionGroup(conversion, parameter.TypeWithAnnotations) : null, type, bindingDiagnosticBag);
IL_02b5:
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo2 = GetNewCompoundUseSiteInfo(bindingDiagnosticBag);
conversion = Conversions.ClassifyConversionFromExpression(boundExpression, type, CheckOverflowAtRuntime, ref useSiteInfo2);
((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag).Add(syntax, useSiteInfo2);
flag2 = !conversion.IsValid;
if (flag2)
{
if (val4 != null)
{
SpecialType specialType2 = val4.SpecialType;
if ((int)specialType2 == 17 || (int)specialType2 == 33)
{
flag3 = true;
goto IL_0312;
}
}
flag3 = false;
goto IL_0312;
}
goto IL_0316;
}
static int getArgumentIndex(int parameterIndex, ImmutableArray<int> immutableArray)
{
if (!immutableArray.IsDefault)
{
return immutableArray.IndexOf(parameterIndex);
}
return parameterIndex;
}
}
internal bool CheckImplicitThisCopyInReadOnlyMember(BoundExpression receiver, MethodSymbol method, BindingDiagnosticBag diagnostics)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
if (receiver != null && receiver.IsEquivalentToThisReference && receiver.Type.IsValueType && ContainingMemberOrLambda is MethodSymbol { IsEffectivelyReadOnly: not false } methodSymbol && TypeSymbol.Equals(methodSymbol.ContainingType, method.ContainingType, (TypeCompareKind)0) && !method.IsEffectivelyReadOnly && method.RequiresInstanceReceiver)
{
Error(diagnostics, ErrorCode.WRN_ImplicitCopyInReadOnlyMember, SyntaxNodeOrToken.op_Implicit(receiver.Syntax), method, "this");
return false;
}
return true;
}
private static Location GetLocationForOverloadResolutionDiagnostic(SyntaxNode node, SyntaxNode expression)
{
if (node != expression)
{
switch (expression.Kind())
{
case SyntaxKind.QualifiedName:
return ((QualifiedNameSyntax)(object)expression).Right.GetLocation();
case SyntaxKind.SimpleMemberAccessExpression:
case SyntaxKind.PointerMemberAccessExpression:
return ((MemberAccessExpressionSyntax)(object)expression).Name.GetLocation();
}
}
return expression.GetLocation();
}
private BoundExpression ReplaceTypeOrValueReceiver(BoundExpression receiver, bool useType, BindingDiagnosticBag diagnostics)
{
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
if (receiver == null)
{
return null;
}
switch (receiver.Kind)
{
case BoundKind.TypeOrValueExpression:
{
BoundTypeOrValueExpression boundTypeOrValueExpression = (BoundTypeOrValueExpression)receiver;
if (useType)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(boundTypeOrValueExpression.Data.TypeDiagnostics, false);
ImmutableArray<Diagnostic>.Enumerator enumerator = boundTypeOrValueExpression.Data.ValueDiagnostics.Diagnostics.GetEnumerator();
while (enumerator.MoveNext())
{
Diagnostic current = enumerator.Current;
if (current.Code == 9179)
{
IReadOnlyList<object> arguments = current.Arguments;
if (arguments == null || arguments.Count != 1 || !(arguments[0] is ParameterSymbol parameterSymbol) || !parameterSymbol.Type.Equals(boundTypeOrValueExpression.Data.ValueExpression.Type, (TypeCompareKind)63))
{
((BindingDiagnosticBag)diagnostics).Add(current);
}
}
}
return boundTypeOrValueExpression.Data.TypeExpression;
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(boundTypeOrValueExpression.Data.ValueDiagnostics, false);
return CheckValue(boundTypeOrValueExpression.Data.ValueExpression, BindValueKind.RValue, diagnostics);
}
case BoundKind.QueryClause:
{
BoundQueryClause boundQueryClause = (BoundQueryClause)receiver;
BoundExpression value = boundQueryClause.Value;
BoundExpression boundExpression = ReplaceTypeOrValueReceiver(value, useType, diagnostics);
if (value != boundExpression)
{
return boundQueryClause.Update(boundExpression, boundQueryClause.DefinedSymbol, boundQueryClause.Operation, boundQueryClause.Cast, boundQueryClause.Binder, boundQueryClause.UnoptimizedForm, boundQueryClause.Type);
}
return boundQueryClause;
}
default:
return BindToNaturalType(receiver, diagnostics);
}
}
private static BoundExpression GetValueExpressionIfTypeOrValueReceiver(BoundExpression receiver)
{
if (receiver == null)
{
return null;
}
if (!(receiver is BoundTypeOrValueExpression { Data: var data }))
{
if (receiver is BoundQueryClause boundQueryClause)
{
return GetValueExpressionIfTypeOrValueReceiver(boundQueryClause.Value);
}
return null;
}
return data.ValueExpression;
}
private static NamedTypeSymbol GetDelegateType(BoundExpression expr)
{
if (expr != null && expr.Kind != BoundKind.TypeExpression && expr.Type is NamedTypeSymbol namedTypeSymbol && namedTypeSymbol.IsDelegateType())
{
return namedTypeSymbol;
}
return null;
}
private BoundCall CreateBadCall(SyntaxNode node, string name, BoundExpression receiver, ImmutableArray<MethodSymbol> methods, LookupResultKind resultKind, ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations, AnalyzedArguments analyzedArguments, bool invokedAsExtensionMethod, bool isDelegate)
{
if (!typeArgumentsWithAnnotations.IsDefaultOrEmpty)
{
ArrayBuilder<MethodSymbol> instance = ArrayBuilder<MethodSymbol>.GetInstance();
ImmutableArray<MethodSymbol>.Enumerator enumerator = methods.GetEnumerator();
while (enumerator.MoveNext())
{
MethodSymbol current = enumerator.Current;
instance.Add((current.ConstructedFrom == current && current.Arity == typeArgumentsWithAnnotations.Length) ? current.Construct(typeArgumentsWithAnnotations) : current);
}
methods = instance.ToImmutableAndFree();
}
MethodSymbol method;
if (methods.Length == 1 && !IsUnboundGeneric(methods[0]))
{
method = methods[0];
}
else
{
TypeSymbol returnType = GetCommonTypeOrReturnType(methods) ?? new ExtendedErrorTypeSymbol(Compilation, string.Empty, 0, null);
method = new ErrorMethodSymbol((receiver != null && (object)receiver.Type != null) ? receiver.Type : ContainingType, returnType, name);
}
ImmutableArray<BoundExpression> arguments = BuildArgumentsForErrorRecovery(analyzedArguments, methods);
ImmutableArray<string> names = analyzedArguments.GetNames();
ImmutableArray<RefKind> refKinds = analyzedArguments.RefKinds.ToImmutableOrNull();
receiver = BindToTypeForErrorRecovery(receiver);
return BoundCall.ErrorCall(node, receiver, method, arguments, names, refKinds, isDelegate, invokedAsExtensionMethod, methods, resultKind, this);
}
private static bool IsUnboundGeneric(MethodSymbol method)
{
if (method.IsGenericMethod)
{
return method.ConstructedFrom() == method;
}
return false;
}
private ImmutableArray<BoundExpression> BuildArgumentsForErrorRecovery(AnalyzedArguments analyzedArguments, ImmutableArray<MethodSymbol> methods)
{
ArrayBuilder<ImmutableArray<ParameterSymbol>> instance = ArrayBuilder<ImmutableArray<ParameterSymbol>>.GetInstance();
ImmutableArray<MethodSymbol>.Enumerator enumerator = methods.GetEnumerator();
while (enumerator.MoveNext())
{
MethodSymbol current = enumerator.Current;
if (!IsUnboundGeneric(current) && current.ParameterCount > 0)
{
instance.Add(current.Parameters);
if (instance.Count == 10)
{
break;
}
}
}
ImmutableArray<BoundExpression> result = BuildArgumentsForErrorRecovery(analyzedArguments, (IEnumerable<ImmutableArray<ParameterSymbol>>)instance);
instance.Free();
return result;
}
private ImmutableArray<BoundExpression> BuildArgumentsForErrorRecovery(AnalyzedArguments analyzedArguments, ImmutableArray<PropertySymbol> properties)
{
ArrayBuilder<ImmutableArray<ParameterSymbol>> instance = ArrayBuilder<ImmutableArray<ParameterSymbol>>.GetInstance();
ImmutableArray<PropertySymbol>.Enumerator enumerator = properties.GetEnumerator();
while (enumerator.MoveNext())
{
PropertySymbol current = enumerator.Current;
if (current.ParameterCount > 0)
{
instance.Add(current.Parameters);
if (instance.Count == 10)
{
break;
}
}
}
ImmutableArray<BoundExpression> result = BuildArgumentsForErrorRecovery(analyzedArguments, (IEnumerable<ImmutableArray<ParameterSymbol>>)instance);
instance.Free();
return result;
}
private ImmutableArray<BoundExpression> BuildArgumentsForErrorRecovery(AnalyzedArguments analyzedArguments, IEnumerable<ImmutableArray<ParameterSymbol>> parameterListList)
{
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Invalid comparison between Unknown and I4
int count = analyzedArguments.Arguments.Count;
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(count);
instance.AddRange(analyzedArguments.Arguments);
for (int i = 0; i < count; i++)
{
BoundExpression boundExpression = instance[i];
UnboundLambda unboundLambda;
switch (boundExpression.Kind)
{
case BoundKind.UnboundLambda:
{
unboundLambda = (UnboundLambda)boundExpression;
if (unboundLambda.HasExplicitlyTypedParameterList && unboundLambda.HasExplicitReturnType(out var _, out var _))
{
FunctionTypeSymbol functionType = unboundLambda.FunctionType;
if ((object)functionType != null)
{
NamedTypeSymbol internalDelegateType = functionType.GetInternalDelegateType();
if ((object)internalDelegateType != null)
{
unboundLambda.Bind(internalDelegateType, isExpressionTree: false);
goto IL_014b;
}
}
}
foreach (ImmutableArray<ParameterSymbol> parameterList in parameterListList)
{
TypeSymbol correspondingParameterType = GetCorrespondingParameterType(analyzedArguments, i, parameterList);
if ((object)correspondingParameterType != null && (int)correspondingParameterType.Kind == 11 && (object)correspondingParameterType.GetDelegateType() != null)
{
unboundLambda.Bind((NamedTypeSymbol)correspondingParameterType, isExpressionTree: false);
}
}
goto IL_014b;
}
case BoundKind.DiscardExpression:
case BoundKind.OutVariablePendingInference:
{
if (boundExpression.HasExpressionType())
{
break;
}
TypeSymbol typeSymbol = getCorrespondingParameterType(i);
if (boundExpression.Kind == BoundKind.OutVariablePendingInference)
{
if ((object)typeSymbol == null)
{
instance[i] = ((OutVariablePendingInference)boundExpression).FailInference(this, null);
}
else
{
instance[i] = ((OutVariablePendingInference)boundExpression).SetInferredTypeWithAnnotations(TypeWithAnnotations.Create(typeSymbol), null);
}
}
else if (boundExpression.Kind == BoundKind.DiscardExpression)
{
if ((object)typeSymbol == null)
{
instance[i] = ((BoundDiscardExpression)boundExpression).FailInference(this, null);
}
else
{
instance[i] = ((BoundDiscardExpression)boundExpression).SetInferredTypeWithAnnotations(TypeWithAnnotations.Create(typeSymbol));
}
}
break;
}
case BoundKind.OutDeconstructVarPendingInference:
instance[i] = ((OutDeconstructVarPendingInference)boundExpression).FailInference(this);
break;
case BoundKind.Local:
case BoundKind.Parameter:
instance[i] = BindToTypeForErrorRecovery(boundExpression);
break;
default:
{
instance[i] = BindToTypeForErrorRecovery(boundExpression, getCorrespondingParameterType(i));
break;
}
IL_014b:
instance[i] = unboundLambda.BindForErrorRecovery();
break;
}
}
return instance.ToImmutableAndFree();
TypeSymbol getCorrespondingParameterType(int i2)
{
TypeSymbol typeSymbol2 = null;
foreach (ImmutableArray<ParameterSymbol> parameterList2 in parameterListList)
{
TypeSymbol correspondingParameterType2 = GetCorrespondingParameterType(analyzedArguments, i2, parameterList2);
if ((object)correspondingParameterType2 != null)
{
if ((object)typeSymbol2 == null)
{
typeSymbol2 = correspondingParameterType2;
}
else if (!typeSymbol2.Equals(correspondingParameterType2, (TypeCompareKind)9))
{
typeSymbol2 = null;
break;
}
}
}
return typeSymbol2;
}
}
private static TypeSymbol GetCorrespondingParameterType(AnalyzedArguments analyzedArguments, int i, ImmutableArray<ParameterSymbol> parameterList)
{
string text = analyzedArguments.Name(i);
if (text != null)
{
ImmutableArray<ParameterSymbol>.Enumerator enumerator = parameterList.GetEnumerator();
while (enumerator.MoveNext())
{
ParameterSymbol current = enumerator.Current;
if (current.Name == text)
{
return current.Type;
}
}
return null;
}
if (i >= parameterList.Length)
{
return null;
}
return parameterList[i].Type;
}
private ImmutableArray<BoundExpression> BuildArgumentsForErrorRecovery(AnalyzedArguments analyzedArguments)
{
return BuildArgumentsForErrorRecovery(analyzedArguments, Enumerable.Empty<ImmutableArray<ParameterSymbol>>());
}
private BoundCall CreateBadCall(SyntaxNode node, BoundExpression expr, LookupResultKind resultKind, AnalyzedArguments analyzedArguments)
{
TypeSymbol returnType = new ExtendedErrorTypeSymbol(Compilation, string.Empty, 0, null);
MethodSymbol method = new ErrorMethodSymbol(expr.Type ?? ContainingType, returnType, string.Empty);
ImmutableArray<BoundExpression> arguments = BuildArgumentsForErrorRecovery(analyzedArguments);
ImmutableArray<string> names = analyzedArguments.GetNames();
ImmutableArray<RefKind> refKinds = analyzedArguments.RefKinds.ToImmutableOrNull();
ImmutableArray<MethodSymbol> originalMethods = ((expr.Kind == BoundKind.MethodGroup) ? ((BoundMethodGroup)expr).Methods : ImmutableArray<MethodSymbol>.Empty);
return BoundCall.ErrorCall(node, expr, method, arguments, names, refKinds, isDelegateCall: false, invokedAsExtensionMethod: false, originalMethods, resultKind, this);
}
private static TypeSymbol GetCommonTypeOrReturnType<TMember>(ImmutableArray<TMember> members) where TMember : Symbol
{
TypeSymbol typeSymbol = null;
int i = 0;
for (int length = members.Length; i < length; i++)
{
TypeSymbol type = members[i].GetTypeOrReturnType().Type;
if ((object)typeSymbol == null)
{
typeSymbol = type;
}
else if (!TypeSymbol.Equals(typeSymbol, type, (TypeCompareKind)0))
{
return null;
}
}
return typeSymbol;
}
private bool TryBindNameofOperator(InvocationExpressionSyntax node, BindingDiagnosticBag diagnostics, out BoundExpression result)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
if (node.MayBeNameofOperator())
{
Binder binder = GetBinder((SyntaxNode)(object)node);
if ((object)binder.EnclosingNameofArgument == node.ArgumentList.Arguments[0].Expression)
{
result = binder.BindNameofOperatorInternal(node, diagnostics);
return true;
}
}
result = null;
return false;
}
private BoundExpression BindNameofOperatorInternal(InvocationExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureNameof, diagnostics);
ExpressionSyntax expression = node.ArgumentList.Arguments[0].Expression;
BoundExpression boundExpression = BindExpression(expression, diagnostics);
string name;
bool flag = CheckSyntaxForNameofArgument(expression, out name, boundExpression.HasAnyErrors ? BindingDiagnosticBag.Discarded : diagnostics);
if (!boundExpression.HasAnyErrors && flag && boundExpression.Kind == BoundKind.MethodGroup)
{
BoundMethodGroup boundMethodGroup = (BoundMethodGroup)boundExpression;
if (!boundMethodGroup.TypeArgumentsOpt.IsDefaultOrEmpty)
{
diagnostics.Add(ErrorCode.ERR_NameofMethodGroupWithTypeParameters, ((SyntaxNode)expression).Location);
}
else
{
EnsureNameofExpressionSymbols(boundMethodGroup, diagnostics);
}
}
if (boundExpression is BoundNamespaceExpression boundNamespaceExpression)
{
diagnostics.AddAssembliesUsedByNamespaceReference(boundNamespaceExpression.NamespaceSymbol);
}
boundExpression = BindToNaturalType(boundExpression, diagnostics, reportNoTargetType: false);
return new BoundNameOfOperator((SyntaxNode)(object)node, boundExpression, ConstantValue.Create(name), Compilation.GetSpecialType((SpecialType)20));
}
private void EnsureNameofExpressionSymbols(BoundMethodGroup methodGroup, BindingDiagnosticBag diagnostics)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
MethodGroupResolution methodGroupResolution = ResolveMethodGroup(methodGroup, null, isMethodGroupConversion: false, ref useSiteInfo, inferWithDynamic: false, (RefKind)0, null, isFunctionPointerResolution: false, default(CallingConventionInfo));
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(methodGroup.Syntax, useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(methodGroupResolution.Diagnostics, false);
if (methodGroupResolution.IsExtensionMethodGroup)
{
diagnostics.Add(ErrorCode.ERR_NameofExtensionMethod, methodGroup.Syntax.Location);
}
}
private bool CheckSyntaxForNameofArgument(ExpressionSyntax argument, out string name, BindingDiagnosticBag diagnostics, bool top = true)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken identifier;
switch (argument.Kind())
{
case SyntaxKind.IdentifierName:
{
IdentifierNameSyntax identifierNameSyntax = (IdentifierNameSyntax)argument;
identifier = identifierNameSyntax.Identifier;
name = ((SyntaxToken)(ref identifier)).ValueText;
return true;
}
case SyntaxKind.GenericName:
{
GenericNameSyntax genericNameSyntax = (GenericNameSyntax)argument;
identifier = genericNameSyntax.Identifier;
name = ((SyntaxToken)(ref identifier)).ValueText;
return true;
}
case SyntaxKind.SimpleMemberAccessExpression:
{
MemberAccessExpressionSyntax memberAccessExpressionSyntax = (MemberAccessExpressionSyntax)argument;
bool result = true;
SyntaxKind syntaxKind = memberAccessExpressionSyntax.Expression.Kind();
if (syntaxKind - 8746 > SyntaxKind.List)
{
result = CheckSyntaxForNameofArgument(memberAccessExpressionSyntax.Expression, out name, diagnostics, top: false);
}
identifier = memberAccessExpressionSyntax.Name.Identifier;
name = ((SyntaxToken)(ref identifier)).ValueText;
return result;
}
case SyntaxKind.AliasQualifiedName:
{
AliasQualifiedNameSyntax aliasQualifiedNameSyntax = (AliasQualifiedNameSyntax)argument;
bool result2 = true;
if (top)
{
diagnostics.Add(ErrorCode.ERR_AliasQualifiedNameNotAnExpression, ((SyntaxNode)argument).Location);
result2 = false;
}
identifier = aliasQualifiedNameSyntax.Name.Identifier;
name = ((SyntaxToken)(ref identifier)).ValueText;
return result2;
}
case SyntaxKind.PredefinedType:
case SyntaxKind.ThisExpression:
case SyntaxKind.BaseExpression:
name = "";
if (!top)
{
return true;
}
break;
}
ErrorCode code = (top ? ErrorCode.ERR_ExpressionHasNoName : ErrorCode.ERR_SubexpressionNotInNameof);
diagnostics.Add(code, ((SyntaxNode)argument).Location);
name = "";
return false;
}
internal bool InvocableNameofInScope()
{
//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)
LookupResult instance = LookupResult.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
LookupSymbolsWithFallback(instance, SyntaxFacts.GetText(SyntaxKind.NameOfKeyword), 0, ref useSiteInfo, null, LookupOptions.MustBeInvocableIfMember | LookupOptions.AllMethodsOnArityZero);
bool isMultiViable = instance.IsMultiViable;
instance.Free();
return isMultiViable;
}
private BoundFunctionPointerInvocation BindFunctionPointerInvocation(SyntaxNode node, BoundExpression boundExpression, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics)
{
//IL_0021: 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)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
boundExpression = BindToNaturalType(boundExpression, diagnostics);
FunctionPointerTypeSymbol functionPointerTypeSymbol = (FunctionPointerTypeSymbol)boundExpression.Type;
OverloadResolutionResult<FunctionPointerMethodSymbol> instance = OverloadResolutionResult<FunctionPointerMethodSymbol>.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
ArrayBuilder<FunctionPointerMethodSymbol> instance2 = ArrayBuilder<FunctionPointerMethodSymbol>.GetInstance(1);
instance2.Add(functionPointerTypeSymbol.Signature);
OverloadResolution.FunctionPointerOverloadResolution(instance2, analyzedArguments, instance, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
if (!instance.Succeeded)
{
ImmutableArray<FunctionPointerMethodSymbol> immutableArray = instance2.ToImmutableAndFree();
instance.ReportDiagnostics(this, node.Location, null, diagnostics, null, boundExpression, boundExpression.Syntax, analyzedArguments, immutableArray, null, null, null, isMethodGroupConversion: false, functionPointerTypeSymbol.Signature.RefKind);
return new BoundFunctionPointerInvocation(node, boundExpression, BuildArgumentsForErrorRecovery(analyzedArguments, StaticCast<MethodSymbol>.From<FunctionPointerMethodSymbol>(immutableArray)), analyzedArguments.RefKinds.ToImmutableOrNull(), LookupResultKind.OverloadResolutionFailure, functionPointerTypeSymbol.Signature.ReturnType, hasErrors: true);
}
instance2.Free();
MemberResolutionResult<FunctionPointerMethodSymbol> validResult = instance.ValidResult;
CheckAndCoerceArguments(validResult, analyzedArguments, diagnostics, null, invokedAsExtensionMethod: false);
ImmutableArray<BoundExpression> arguments = analyzedArguments.Arguments.ToImmutable();
ImmutableArray<RefKind> argumentRefKindsOpt = analyzedArguments.RefKinds.ToImmutableOrNull();
bool hasErrors = ReportUnsafeIfNotAllowed(node, diagnostics);
return new BoundFunctionPointerInvocation(node, boundExpression, arguments, argumentRefKindsOpt, LookupResultKind.Viable, functionPointerTypeSymbol.Signature.ReturnType, hasErrors);
}
private UnboundLambda AnalyzeAnonymousFunction(AnonymousFunctionExpressionSyntax syntax, BindingDiagnosticBag diagnostics)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: 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_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Unknown result type (might be due to invalid IL or missing references)
//IL_0349: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_036b: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_038f: Unknown result type (might be due to invalid IL or missing references)
//IL_0383: Unknown result type (might be due to invalid IL or missing references)
//IL_0389: Unknown result type (might be due to invalid IL or missing references)
ImmutableArray<string> names = default(ImmutableArray<string>);
ImmutableArray<RefKind> refKinds = default(ImmutableArray<RefKind>);
ImmutableArray<ScopedKind> declaredScopes = default(ImmutableArray<ScopedKind>);
ImmutableArray<TypeWithAnnotations> types = default(ImmutableArray<TypeWithAnnotations>);
ImmutableArray<EqualsValueClauseSyntax> defaultValues = default(ImmutableArray<EqualsValueClauseSyntax>);
RefKind returnRefKind = (RefKind)0;
TypeWithAnnotations returnType = default(TypeWithAnnotations);
ImmutableArray<SyntaxList<AttributeListSyntax>> parameterAttributes = default(ImmutableArray<SyntaxList<AttributeListSyntax>>);
ArrayBuilder<string> instance = ArrayBuilder<string>.GetInstance();
ImmutableArray<bool> discardsOpt = default(ImmutableArray<bool>);
SeparatedSyntaxList<ParameterSyntax>? syntaxList = null;
if (syntax is LambdaExpressionSyntax lambdaExpressionSyntax)
{
MessageID.IDS_FeatureLambda.CheckFeatureAvailability(diagnostics, lambdaExpressionSyntax.ArrowToken);
checkAttributes(syntax, lambdaExpressionSyntax.AttributeLists, diagnostics);
}
bool flag;
SyntaxToken refnessKeyword;
switch (syntax.Kind())
{
default:
{
flag = true;
SimpleLambdaExpressionSyntax simpleLambdaExpressionSyntax = (SimpleLambdaExpressionSyntax)syntax;
refnessKeyword = simpleLambdaExpressionSyntax.Parameter.Identifier;
instance.Add(((SyntaxToken)(ref refnessKeyword)).ValueText);
break;
}
case SyntaxKind.ParenthesizedLambdaExpression:
{
flag = true;
ParenthesizedLambdaExpressionSyntax parenthesizedLambdaExpressionSyntax = (ParenthesizedLambdaExpressionSyntax)syntax;
TypeSyntax returnType2 = parenthesizedLambdaExpressionSyntax.ReturnType;
if (returnType2 != null)
{
(returnRefKind, returnType) = BindExplicitLambdaReturnType(returnType2, diagnostics);
}
syntaxList = parenthesizedLambdaExpressionSyntax.ParameterList.Parameters;
CheckParenthesizedLambdaParameters(syntaxList.Value, diagnostics);
break;
}
case SyntaxKind.AnonymousMethodExpression:
{
AnonymousMethodExpressionSyntax anonymousMethodExpressionSyntax = (AnonymousMethodExpressionSyntax)syntax;
MessageID.IDS_FeatureAnonDelegates.CheckFeatureAvailability(diagnostics, anonymousMethodExpressionSyntax.DelegateKeyword);
flag = anonymousMethodExpressionSyntax.ParameterList != null;
if (flag)
{
syntaxList = anonymousMethodExpressionSyntax.ParameterList.Parameters;
}
break;
}
}
bool isAsync = false;
bool isStatic = false;
bool hasParamsArray = false;
SyntaxTokenList modifiers = syntax.Modifiers;
Enumerator enumerator = ((SyntaxTokenList)(ref modifiers)).GetEnumerator();
while (((Enumerator)(ref enumerator)).MoveNext())
{
SyntaxToken current = ((Enumerator)(ref enumerator)).Current;
if (current.IsKind(SyntaxKind.AsyncKeyword))
{
MessageID.IDS_FeatureAsync.CheckFeatureAvailability(diagnostics, current);
isAsync = true;
}
else if (current.IsKind(SyntaxKind.StaticKeyword))
{
MessageID.IDS_FeatureStaticAnonymousFunction.CheckFeatureAvailability(diagnostics, current);
isStatic = true;
}
}
if (syntaxList.HasValue)
{
bool flag2 = true;
ArrayBuilder<TypeWithAnnotations> instance2 = ArrayBuilder<TypeWithAnnotations>.GetInstance();
ArrayBuilder<RefKind> instance3 = ArrayBuilder<RefKind>.GetInstance();
ArrayBuilder<ScopedKind> instance4 = ArrayBuilder<ScopedKind>.GetInstance();
ArrayBuilder<SyntaxList<AttributeListSyntax>> instance5 = ArrayBuilder<SyntaxList<AttributeListSyntax>>.GetInstance();
ArrayBuilder<EqualsValueClauseSyntax> instance6 = ArrayBuilder<EqualsValueClauseSyntax>.GetInstance();
int num = 0;
int num2 = 0;
Enumerator<ParameterSyntax> enumerator2 = syntaxList.Value.GetEnumerator();
while (enumerator2.MoveNext())
{
ParameterSyntax current2 = enumerator2.Current;
num++;
if (current2.Identifier.IsUnderscoreToken())
{
num2++;
}
checkAttributes(syntax, current2.AttributeLists, diagnostics);
bool flag3 = ((SyntaxNode?)(object)syntax).IsKind(SyntaxKind.AnonymousMethodExpression);
if (current2.Default != null)
{
if (flag3)
{
Error(diagnostics, ErrorCode.ERR_DefaultValueNotAllowed, current2.Default.EqualsToken);
}
else
{
MessageID.IDS_FeatureLambdaOptionalParameters.CheckFeatureAvailability(diagnostics, current2.Default.EqualsToken);
}
}
if (current2.IsArgList)
{
Error(diagnostics, ErrorCode.ERR_IllegalVarArgs, (CSharpSyntaxNode)current2);
continue;
}
TypeSyntax type = current2.Type;
TypeWithAnnotations typeWithAnnotations = default(TypeWithAnnotations);
RefKind val = (RefKind)0;
ScopedKind scope = (ScopedKind)0;
SyntaxToken thisKeyword;
if (type == null)
{
flag2 = false;
}
else
{
typeWithAnnotations = BindType(type, diagnostics);
ParameterHelpers.CheckParameterModifiers(current2, diagnostics, parsingFunctionPointerParams: false, !flag3, flag3);
val = ParameterHelpers.GetModifiers(current2.Modifiers, out refnessKeyword, out var paramsKeyword, out thisKeyword, out scope);
if (num == syntaxList.Value.Count && paramsKeyword.Kind() != SyntaxKind.None)
{
hasParamsArray = true;
ReportUseSiteDiagnosticForSynthesizedAttribute(Compilation, (WellKnownMember)63, diagnostics, ((SyntaxToken)(ref paramsKeyword)).GetLocation());
}
}
thisKeyword = current2.Identifier;
instance.Add(((SyntaxToken)(ref thisKeyword)).ValueText);
instance2.Add(typeWithAnnotations);
instance3.Add(val);
instance4.Add(scope);
instance5.Add((SyntaxList<AttributeListSyntax>)((syntax.Kind() == SyntaxKind.ParenthesizedLambdaExpression) ? current2.AttributeLists : default(SyntaxList<AttributeListSyntax>)));
instance6.Add(current2.Default);
}
discardsOpt = computeDiscards(syntaxList.Value, num2);
if (flag2)
{
types = instance2.ToImmutable();
}
if (ArrayBuilderExtensions.Any<RefKind>(instance3, (Func<RefKind, bool>)((RefKind r) => (int)r > 0)))
{
refKinds = instance3.ToImmutable();
}
if (ArrayBuilderExtensions.Any<ScopedKind>(instance4, (Func<ScopedKind, bool>)((ScopedKind s) => (int)s > 0)))
{
declaredScopes = instance4.ToImmutable();
}
if (ArrayBuilderExtensions.Any<SyntaxList<AttributeListSyntax>>(instance5, (Func<SyntaxList<AttributeListSyntax>, bool>)((SyntaxList<AttributeListSyntax> a) => a.Count > 0)))
{
parameterAttributes = instance5.ToImmutable();
}
if (ArrayBuilderExtensions.Any<EqualsValueClauseSyntax>(instance6, (Func<EqualsValueClauseSyntax, bool>)((EqualsValueClauseSyntax v) => v != null)))
{
defaultValues = instance6.ToImmutable();
}
instance2.Free();
instance4.Free();
instance3.Free();
instance5.Free();
instance6.Free();
}
if (flag)
{
names = instance.ToImmutable();
}
instance.Free();
return UnboundLambda.Create(syntax, this, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies, returnRefKind, returnType, parameterAttributes, refKinds, declaredScopes, types, names, discardsOpt, syntaxList, defaultValues, isAsync, isStatic, hasParamsArray);
static void checkAttributes(AnonymousFunctionExpressionSyntax anonymousFunctionExpressionSyntax, SyntaxList<AttributeListSyntax> attributeLists, BindingDiagnosticBag diagnostics2)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
Enumerator<AttributeListSyntax> enumerator3 = attributeLists.GetEnumerator();
while (enumerator3.MoveNext())
{
AttributeListSyntax current3 = enumerator3.Current;
if (anonymousFunctionExpressionSyntax.Kind() == SyntaxKind.ParenthesizedLambdaExpression)
{
MessageID.IDS_FeatureLambdaAttributes.CheckFeatureAvailability(diagnostics2, (SyntaxNode)(object)current3);
}
else
{
Error(diagnostics2, (anonymousFunctionExpressionSyntax.Kind() == SyntaxKind.SimpleLambdaExpression) ? ErrorCode.ERR_AttributesRequireParenthesizedLambdaExpression : ErrorCode.ERR_AttributesNotAllowed, (CSharpSyntaxNode)current3);
}
}
}
static ImmutableArray<bool> computeDiscards(SeparatedSyntaxList<ParameterSyntax> parameters, int underscoresCount)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if (underscoresCount <= 1)
{
return default(ImmutableArray<bool>);
}
ArrayBuilder<bool> instance7 = ArrayBuilder<bool>.GetInstance(parameters.Count);
Enumerator<ParameterSyntax> enumerator3 = parameters.GetEnumerator();
while (enumerator3.MoveNext())
{
ParameterSyntax current3 = enumerator3.Current;
instance7.Add(current3.Identifier.IsUnderscoreToken());
}
return instance7.ToImmutableAndFree();
}
}
private (RefKind, TypeWithAnnotations) BindExplicitLambdaReturnType(TypeSyntax syntax, BindingDiagnosticBag diagnostics)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureLambdaReturnType.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)syntax);
syntax = syntax.SkipScoped(out var _).SkipRefInLocalOrReturn(diagnostics, out var refKind);
if (syntax is IdentifierNameSyntax { Identifier: var identifier } && ((SyntaxToken)(ref identifier)).RawContextualKind == 8490)
{
diagnostics.Add(ErrorCode.ERR_LambdaExplicitReturnTypeVar, ((SyntaxNode)syntax).Location);
}
TypeWithAnnotations item = BindType(syntax, diagnostics);
TypeSymbol type = item.Type;
if (item.IsStatic)
{
diagnostics.Add(ErrorFacts.GetStaticClassReturnCode(useWarning: false), ((SyntaxNode)syntax).Location, type);
}
else if (item.IsRestrictedType(ignoreSpanLikeTypes: true))
{
diagnostics.Add(ErrorCode.ERR_MethodReturnCantBeRefAny, ((SyntaxNode)syntax).Location, type);
}
return (refKind, item);
}
private static void CheckParenthesizedLambdaParameters(SeparatedSyntaxList<ParameterSyntax> parameterSyntaxList, BindingDiagnosticBag diagnostics)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
if (parameterSyntaxList.Count <= 0)
{
return;
}
bool flag = parameterSyntaxList[0].Type != null;
checkForImplicitDefault(flag, parameterSyntaxList[0], diagnostics);
int i = 1;
for (int count = parameterSyntaxList.Count; i < count; i++)
{
ParameterSyntax parameterSyntax = parameterSyntaxList[i];
SyntaxToken identifier = parameterSyntax.Identifier;
if (((SyntaxToken)(ref identifier)).IsMissing)
{
continue;
}
bool flag2 = parameterSyntax.Type != null;
if (flag != flag2)
{
object obj = parameterSyntax.Type?.GetLocation();
if (obj == null)
{
identifier = parameterSyntax.Identifier;
obj = ((SyntaxToken)(ref identifier)).GetLocation();
}
diagnostics.Add(ErrorCode.ERR_InconsistentLambdaParameterUsage, (Location)obj);
}
checkForImplicitDefault(flag2, parameterSyntax, diagnostics);
}
static void checkForImplicitDefault(bool hasType, ParameterSyntax param, BindingDiagnosticBag bindingDiagnosticBag)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (!hasType && param.Default != null)
{
SyntaxToken identifier2 = param.Identifier;
Location location = ((SyntaxToken)(ref identifier2)).GetLocation();
object[] array = new object[1];
identifier2 = param.Identifier;
array[0] = ((SyntaxToken)(ref identifier2)).Text;
bindingDiagnosticBag.Add(ErrorCode.ERR_ImplicitlyTypedDefaultParameter, location, array);
}
}
}
private UnboundLambda BindAnonymousFunction(AnonymousFunctionExpressionSyntax syntax, BindingDiagnosticBag diagnostics)
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
UnboundLambda unboundLambda = AnalyzeAnonymousFunction(syntax, diagnostics);
UnboundLambdaState data = unboundLambda.Data;
if (data.HasExplicitlyTypedParameterList)
{
int num = -1;
for (int i = 0; i < unboundLambda.ParameterCount; i++)
{
ParameterSyntax parameterSyntax = unboundLambda.ParameterSyntax(i);
if (parameterSyntax.Default != null && num == -1)
{
num = i;
}
ParameterHelpers.GetModifiers(parameterSyntax.Modifiers, out var _, out var paramsKeyword, out var thisKeyword, out var _);
bool isParams = paramsKeyword.Kind() != SyntaxKind.None;
int ordinal = i;
int lastParameterIndex = unboundLambda.ParameterCount - 1;
TypeWithAnnotations typeWithAnnotations = unboundLambda.ParameterTypeWithAnnotations(i);
RefKind refKind = unboundLambda.RefKind(i);
ScopedKind? declaredScope = unboundLambda.DeclaredScope(i);
thisKeyword = default(SyntaxToken);
ParameterHelpers.ReportParameterErrors(null, parameterSyntax, ordinal, lastParameterIndex, isParams, typeWithAnnotations, refKind, declaredScope, null, thisKeyword, paramsKeyword, num, diagnostics);
}
}
syntax.Modifiers.ToDeclarationModifiers(isForTypeDeclaration: false, (DiagnosticBag)(((object)((BindingDiagnosticBag)diagnostics).DiagnosticBag) ?? ((object)new DiagnosticBag())));
if (data.HasSignature)
{
LocalScopeBinder localScopeBinder = new LocalScopeBinder(this);
bool flag = localScopeBinder.Compilation.IsFeatureEnabled(MessageID.IDS_FeatureNameShadowingInNestedFunctions);
PooledHashSet<string> instance = PooledHashSet<string>.GetInstance();
bool flag2 = false;
for (int j = 0; j < unboundLambda.ParameterCount; j++)
{
string text = unboundLambda.ParameterName(j);
if (string.IsNullOrEmpty(text))
{
continue;
}
if (unboundLambda.ParameterIsDiscard(j))
{
if (flag2)
{
MessageID.IDS_FeatureLambdaDiscardParameters.CheckFeatureAvailability(diagnostics, (Compilation)(object)localScopeBinder.Compilation, unboundLambda.ParameterLocation(j));
}
flag2 = true;
}
else if (!((HashSet<string>)(object)instance).Add(text))
{
diagnostics.Add(ErrorCode.ERR_DuplicateParamName, unboundLambda.ParameterLocation(j), text);
}
else if (!flag)
{
localScopeBinder.ValidateLambdaParameterNameConflictsInScope(unboundLambda.ParameterLocation(j), text, diagnostics);
}
}
instance.Free();
}
return unboundLambda;
}
internal void LookupSymbolsSimpleName(LookupResult result, NamespaceOrTypeSymbol qualifierOpt, string plainName, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
if (options.IsAttributeTypeLookup())
{
LookupAttributeType(result, qualifierOpt, plainName, arity, basesBeingResolved, options, diagnose, ref useSiteInfo);
}
else
{
LookupSymbolsOrMembersInternal(result, qualifierOpt, plainName, arity, basesBeingResolved, options, diagnose, ref useSiteInfo);
}
}
internal void LookupExtensionMethods(LookupResult result, string name, int arity, LookupOptions options, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
ExtensionMethodScopeEnumerator enumerator = new ExtensionMethodScopes(this).GetEnumerator();
while (enumerator.MoveNext())
{
ExtensionMethodScope current = enumerator.Current;
LookupExtensionMethodsInSingleBinder(current, result, name, arity, options, ref useSiteInfo);
}
}
private Binder LookupSymbolsWithFallback(LookupResult result, string name, int arity, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConsList<TypeSymbol> basesBeingResolved = null, LookupOptions options = LookupOptions.Default)
{
Binder result2 = LookupSymbolsInternal(result, name, arity, basesBeingResolved, options, diagnose: false, ref useSiteInfo);
if (result.Kind != LookupResultKind.Viable && result.Kind != LookupResultKind.Empty)
{
result.Clear();
LookupSymbolsInternal(result, name, arity, basesBeingResolved, options, diagnose: true, ref useSiteInfo);
}
return result2;
}
private Binder LookupSymbolsInternal(LookupResult result, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
Binder binder = null;
Binder binder2 = this;
while (binder2 != null && !result.IsMultiViable)
{
if (binder != null)
{
LookupResult instance = LookupResult.GetInstance();
binder2.LookupSymbolsInSingleBinder(instance, name, arity, basesBeingResolved, options, this, diagnose, ref useSiteInfo);
result.MergeEqual(instance);
instance.Free();
}
else
{
binder2.LookupSymbolsInSingleBinder(result, name, arity, basesBeingResolved, options, this, diagnose, ref useSiteInfo);
if (!result.IsClear)
{
binder = binder2;
}
}
if ((options & LookupOptions.LabelsOnly) != LookupOptions.Default && binder2.IsLastBinderWithinMember())
{
break;
}
binder2 = binder2.Next;
}
return binder;
}
internal virtual void LookupSymbolsInSingleBinder(LookupResult result, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
}
private void LookupSymbolsOrMembersInternal(LookupResult result, NamespaceOrTypeSymbol qualifierOpt, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
if ((object)qualifierOpt == null)
{
LookupSymbolsInternal(result, name, arity, basesBeingResolved, options, diagnose, ref useSiteInfo);
}
else
{
LookupMembersInternal(result, qualifierOpt, name, arity, basesBeingResolved, options, this, diagnose, ref useSiteInfo);
}
}
private void LookupMembersWithFallback(LookupResult result, NamespaceOrTypeSymbol nsOrType, string name, int arity, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConsList<TypeSymbol> basesBeingResolved = null, LookupOptions options = LookupOptions.Default)
{
LookupMembersInternal(result, nsOrType, name, arity, basesBeingResolved, options, this, diagnose: false, ref useSiteInfo);
if (!result.IsMultiViable && !result.IsClear)
{
result.Clear();
LookupMembersInternal(result, nsOrType, name, arity, basesBeingResolved, options, this, diagnose: true, ref useSiteInfo);
}
}
protected void LookupMembersInternal(LookupResult result, NamespaceOrTypeSymbol nsOrType, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
if (nsOrType.IsNamespace)
{
LookupMembersInNamespace(result, (NamespaceSymbol)nsOrType, name, arity, options, originalBinder, diagnose, ref useSiteInfo);
}
else
{
LookupMembersInType(result, (TypeSymbol)nsOrType, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteInfo);
}
}
protected void LookupMembersInType(LookupResult result, TypeSymbol type, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected I4, but got Unknown
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
TypeKind typeKind = type.TypeKind;
switch ((int)typeKind)
{
case 11:
LookupMembersInTypeParameter(result, (TypeParameterSymbol)type, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteInfo);
break;
case 7:
LookupMembersInInterface(result, (NamedTypeSymbol)type, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteInfo);
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 10:
case 12:
LookupMembersInClass(result, type, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteInfo);
break;
case 6:
LookupMembersInErrorType(result, (ErrorTypeSymbol)type, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteInfo);
break;
case 9:
case 13:
result.Clear();
break;
default:
throw ExceptionUtilities.UnexpectedValue((object)type.TypeKind);
}
}
private void LookupMembersInErrorType(LookupResult result, ErrorTypeSymbol errorType, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
if (!errorType.CandidateSymbols.IsDefault && errorType.CandidateSymbols.Length == 1 && errorType.ResultKind == LookupResultKind.Inaccessible && errorType.CandidateSymbols.First() is TypeSymbol type)
{
LookupMembersInType(result, type, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteInfo);
}
else
{
result.Clear();
}
}
protected void LookupMembersInSubmissions(LookupResult result, TypeSymbol submissionClass, CompilationUnitSyntax declarationSyntax, bool inUsings, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Invalid comparison between Unknown and I4
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
LookupResult instance = LookupResult.GetInstance();
LookupResult instance2 = LookupResult.GetInstance();
SymbolKind? val = null;
bool flag = Compilation.IsSubmissionSyntaxTree(declarationSyntax.SyntaxTree);
for (CSharpCompilation cSharpCompilation = Compilation; cSharpCompilation != null; cSharpCompilation = cSharpCompilation.PreviousSubmission)
{
instance.Clear();
bool flag2 = cSharpCompilation == Compilation;
bool flag3 = !(flag2 && inUsings);
Imports imports = ((!flag3) ? Imports.Empty : (flag ? cSharpCompilation.GetSubmissionImports() : ((!flag2) ? Imports.Empty : ((SourceNamespaceSymbol)Compilation.SourceModule.GlobalNamespace).GetImports(declarationSyntax, basesBeingResolved))));
if ((options & LookupOptions.NamespaceAliasesOnly) == 0 && (object)cSharpCompilation.ScriptClass != null)
{
LookupMembersWithoutInheritance(instance, cSharpCompilation.ScriptClass, name, arity, options, originalBinder, submissionClass, diagnose, ref useSiteInfo, basesBeingResolved);
if (instance.IsMultiViable && flag3 && IsUsingAlias(imports.UsingAliases, name, originalBinder.IsSemanticModelBinder))
{
Symbol symbol = instance.Symbols.First();
if ((int)symbol.Kind != 11 || arity == 0)
{
CSDiagnosticInfo errorInfo = new CSDiagnosticInfo(ErrorCode.ERR_ConflictingAliasAndDefinition, name, symbol.GetKindText());
ExtendedErrorTypeSymbol symbol2 = new ExtendedErrorTypeSymbol((NamespaceOrTypeSymbol?)null, name, arity, (DiagnosticInfo?)(object)errorInfo, true, false);
result.SetFrom(LookupResult.Good(symbol2));
break;
}
}
}
if (!instance.IsMultiViable && flag3)
{
if (!flag2)
{
imports = Imports.ExpandPreviousSubmissionImports(imports, Compilation);
}
LookupSymbolInAliases(imports.UsingAliases, imports.ExternAliases, originalBinder, instance, name, arity, basesBeingResolved, options, diagnose, ref useSiteInfo);
}
if (!val.HasValue)
{
if (!instance.IsMultiViable)
{
instance2.MergePrioritized(instance);
}
else
{
result.MergeEqual(instance);
Symbol symbol3 = instance.Symbols.First();
if (!IsMethodOrIndexer(symbol3))
{
break;
}
options &= ~(LookupOptions.NamespacesOrTypesOnly | LookupOptions.MustBeInvocableIfMember);
val = symbol3.Kind;
}
}
else
{
if (instance.Symbols.Count > 0 && instance.Symbols.First().Kind != val.Value)
{
break;
}
if (instance.IsMultiViable)
{
result.MergeEqual(instance);
}
}
}
if (result.Symbols.Count == 0)
{
result.SetFrom(instance2);
}
instance.Free();
instance2.Free();
}
protected bool IsUsingAlias(ImmutableDictionary<string, AliasAndUsingDirective> usingAliases, string name, bool callerIsSemanticModel)
{
if (usingAliases.TryGetValue(name, out var value))
{
MarkImportDirective(value.UsingDirectiveReference, callerIsSemanticModel);
return true;
}
return false;
}
protected void MarkImportDirective(SyntaxReference directive, bool callerIsSemanticModel)
{
if (directive != null && !callerIsSemanticModel)
{
((Compilation)Compilation).MarkImportDirectiveAsUsed(directive);
}
}
protected void LookupSymbolInAliases(ImmutableDictionary<string, AliasAndUsingDirective> usingAliases, ImmutableArray<AliasAndExternAliasDirective> externAliases, Binder originalBinder, LookupResult result, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
bool isSemanticModelBinder = originalBinder.IsSemanticModelBinder;
if (usingAliases.TryGetValue(name, out var value))
{
SingleLookupResult result2 = originalBinder.CheckViability(value.Alias, arity, options, null, diagnose, ref useSiteInfo, basesBeingResolved);
if (result2.Kind == LookupResultKind.Viable)
{
MarkImportDirective(value.UsingDirectiveReference, isSemanticModelBinder);
}
result.MergeEqual(result2);
}
ImmutableArray<AliasAndExternAliasDirective>.Enumerator enumerator = externAliases.GetEnumerator();
while (enumerator.MoveNext())
{
AliasAndExternAliasDirective current = enumerator.Current;
if (!current.SkipInLookup && current.Alias.Name == name)
{
SingleLookupResult result3 = originalBinder.CheckViability(current.Alias, arity, options, null, diagnose, ref useSiteInfo, basesBeingResolved);
if (result3.Kind == LookupResultKind.Viable)
{
MarkImportDirective(current.ExternAliasDirectiveReference, isSemanticModelBinder);
}
result.MergeEqual(result3);
}
}
}
private static void LookupMembersInNamespace(LookupResult result, NamespaceSymbol ns, string name, int arity, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
ImmutableArray<Symbol>.Enumerator enumerator = GetCandidateMembers(ns, name, options, originalBinder).GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
SingleLookupResult result2 = originalBinder.CheckViability(current, arity, options, null, diagnose, ref useSiteInfo);
result.MergeEqual(result2);
}
}
private void LookupExtensionMethodsInSingleBinder(ExtensionMethodScope scope, LookupResult result, string name, int arity, LookupOptions options, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_0019: 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)
ArrayBuilder<MethodSymbol> instance = ArrayBuilder<MethodSymbol>.GetInstance();
scope.Binder.GetCandidateExtensionMethods(instance, name, arity, options, this);
Enumerator<MethodSymbol> enumerator = instance.GetEnumerator();
while (enumerator.MoveNext())
{
MethodSymbol current = enumerator.Current;
SingleLookupResult result2 = CheckViability(current, arity, options, null, diagnose: true, ref useSiteInfo);
result.MergeEqual(result2);
}
instance.Free();
}
private void LookupAttributeType(LookupResult result, NamespaceOrTypeSymbol qualifierOpt, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
LookupSymbolsOrMembersInternal(result, qualifierOpt, name, arity, basesBeingResolved, options, diagnose, ref useSiteInfo);
CompoundUseSiteInfo<AssemblySymbol> attributeTypeViabilityUseSiteInfo = default(CompoundUseSiteInfo<AssemblySymbol>);
attributeTypeViabilityUseSiteInfo._002Ector(useSiteInfo);
Symbol symbol;
bool flag = IsSingleViableAttributeType(result, out symbol, ref attributeTypeViabilityUseSiteInfo);
LookupResult lookupResult = null;
Symbol symbol2 = null;
CompoundUseSiteInfo<AssemblySymbol> attributeTypeViabilityUseSiteInfo2 = default(CompoundUseSiteInfo<AssemblySymbol>);
attributeTypeViabilityUseSiteInfo2._002Ector(useSiteInfo);
bool flag2 = false;
if (!options.IsVerbatimNameAttributeTypeLookup())
{
lookupResult = LookupResult.GetInstance();
LookupSymbolsOrMembersInternal(lookupResult, qualifierOpt, name + "Attribute", arity, basesBeingResolved, options, diagnose, ref useSiteInfo);
flag2 = IsSingleViableAttributeType(lookupResult, out symbol2, ref attributeTypeViabilityUseSiteInfo2);
}
if (flag && flag2)
{
result.MergeEqual(lookupResult);
}
else if (flag)
{
useSiteInfo.MergeAndClear(ref attributeTypeViabilityUseSiteInfo);
}
else if (flag2)
{
result.SetFrom(lookupResult);
useSiteInfo.MergeAndClear(ref attributeTypeViabilityUseSiteInfo2);
}
else
{
if (!result.IsClear && (object)symbol != null)
{
result.SetFrom(GenerateNonViableAttributeTypeResult(symbol, result.Error, diagnose));
}
if (lookupResult != null)
{
if (!lookupResult.IsClear && (object)symbol2 != null)
{
lookupResult.SetFrom(GenerateNonViableAttributeTypeResult(symbol2, lookupResult.Error, diagnose));
}
result.MergePrioritized(lookupResult);
}
}
lookupResult?.Free();
}
private bool IsAmbiguousResult(LookupResult result, out Symbol resultSymbol)
{
resultSymbol = null;
ArrayBuilder<Symbol> symbols = result.Symbols;
switch (symbols.Count)
{
case 0:
return false;
case 1:
resultSymbol = symbols[0];
return false;
default:
resultSymbol = ResolveMultipleSymbolsInAttributeTypeLookup(symbols);
return (object)resultSymbol == null;
}
}
private Symbol ResolveMultipleSymbolsInAttributeTypeLookup(ArrayBuilder<Symbol> symbols)
{
ImmutableArray<Symbol> immutableArray = symbols.ToImmutable();
for (int i = 0; i < symbols.Count; i++)
{
symbols[i] = UnwrapAliasNoDiagnostics(symbols[i]);
}
BestSymbolInfo secondBest;
BestSymbolInfo bestSymbolInfo = GetBestSymbolInfo(symbols, out secondBest);
if (bestSymbolInfo.IsFromCompilation && !secondBest.IsFromCompilation)
{
Symbol x = symbols[bestSymbolInfo.Index];
Symbol y = symbols[secondBest.Index];
if (NameAndArityMatchRecursively(x, y))
{
return immutableArray[bestSymbolInfo.Index];
}
}
return null;
}
private static bool NameAndArityMatchRecursively(Symbol x, Symbol y)
{
while (true)
{
if (isRoot(x))
{
return isRoot(y);
}
if (isRoot(y))
{
return false;
}
if (x.Name != y.Name || x.GetArity() != y.GetArity())
{
break;
}
x = x.ContainingSymbol;
y = y.ContainingSymbol;
}
return false;
static bool isRoot(Symbol symbol)
{
if ((object)symbol != null)
{
if (symbol is NamespaceSymbol namespaceSymbol)
{
return namespaceSymbol.IsGlobalNamespace;
}
return false;
}
return true;
}
}
private bool IsSingleViableAttributeType(LookupResult result, out Symbol symbol, ref CompoundUseSiteInfo<AssemblySymbol> attributeTypeViabilityUseSiteInfo)
{
if (IsAmbiguousResult(result, out symbol))
{
return false;
}
if (result == null || result.Kind != LookupResultKind.Viable || (object)symbol == null)
{
return false;
}
DiagnosticInfo diagInfo = null;
return CheckAttributeTypeViability(UnwrapAliasNoDiagnostics(symbol), diagnose: false, ref diagInfo, ref attributeTypeViabilityUseSiteInfo);
}
private SingleLookupResult GenerateNonViableAttributeTypeResult(Symbol symbol, DiagnosticInfo diagInfo, bool diagnose)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
symbol = UnwrapAliasNoDiagnostics(symbol);
CompoundUseSiteInfo<AssemblySymbol> attributeTypeViabilityUseSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
CheckAttributeTypeViability(symbol, diagnose, ref diagInfo, ref attributeTypeViabilityUseSiteInfo);
return LookupResult.NotAnAttributeType(symbol, diagInfo);
}
private bool CheckAttributeTypeViability(Symbol symbol, bool diagnose, ref DiagnosticInfo diagInfo, ref CompoundUseSiteInfo<AssemblySymbol> attributeTypeViabilityUseSiteInfo)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Invalid comparison between Unknown and I4
if ((int)symbol.Kind == 11)
{
NamedTypeSymbol namedTypeSymbol = (NamedTypeSymbol)symbol;
if (namedTypeSymbol.IsAbstract)
{
diagInfo = (DiagnosticInfo)(object)(diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_AbstractAttributeClass, symbol) : null);
return false;
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = ((attributeTypeViabilityUseSiteInfo.AccumulatesDependencies || !diagnose) ? new CompoundUseSiteInfo<AssemblySymbol>(attributeTypeViabilityUseSiteInfo) : CompoundUseSiteInfo<AssemblySymbol>.DiscardedDependencies);
if (Compilation.IsEqualOrDerivedFromWellKnownClass(namedTypeSymbol, (WellKnownType)49, ref useSiteInfo))
{
attributeTypeViabilityUseSiteInfo.MergeAndClear(ref useSiteInfo);
return true;
}
if (diagnose && useSiteInfo.HasErrors)
{
foreach (DiagnosticInfo diagnostic in useSiteInfo.Diagnostics)
{
if ((int)diagnostic.Severity == 3)
{
diagInfo = diagnostic;
return false;
}
}
}
}
diagInfo = (DiagnosticInfo)(object)(diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_NotAnAttributeClass, symbol) : null);
return false;
}
internal virtual void GetCandidateExtensionMethods(ArrayBuilder<MethodSymbol> methods, string name, int arity, LookupOptions options, Binder originalBinder)
{
}
protected static void LookupMembersWithoutInheritance(LookupResult result, TypeSymbol type, string name, int arity, LookupOptions options, Binder originalBinder, TypeSymbol accessThroughType, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConsList<TypeSymbol> basesBeingResolved)
{
ImmutableArray<Symbol>.Enumerator enumerator = GetCandidateMembers(type, name, options, originalBinder).GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
SingleLookupResult result2 = originalBinder.CheckViability(current, arity, options, accessThroughType, diagnose, ref useSiteInfo, basesBeingResolved);
result.MergeEqual(result2);
}
}
private void LookupMembersInClass(LookupResult result, TypeSymbol type, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
LookupMembersInClass(result, type, name, arity, basesBeingResolved, options, originalBinder, type, diagnose, ref useSiteInfo);
}
private void LookupMembersInClass(LookupResult result, TypeSymbol type, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, TypeSymbol accessThroughType, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
TypeSymbol typeSymbol = type;
LookupResult instance = LookupResult.GetInstance();
PooledHashSet<NamedTypeSymbol> visited = null;
while ((object)typeSymbol != null)
{
instance.Clear();
LookupMembersWithoutInheritance(instance, typeSymbol, name, arity, options, originalBinder, accessThroughType, diagnose, ref useSiteInfo, basesBeingResolved);
MergeHidingLookupResults(result, instance, basesBeingResolved, ref useSiteInfo);
if (typeSymbol is NamedTypeSymbol { ShouldAddWinRTMembers: not false } namedTypeSymbol)
{
AddWinRTMembers(result, namedTypeSymbol, name, arity, options, originalBinder, diagnose, ref useSiteInfo);
}
bool flag = instance.IsMultiViable && !IsMethodOrIndexer(instance.Symbols[0]);
if (result.IsMultiViable && (flag || !IsMethodOrIndexer(result.Symbols[0])))
{
break;
}
if (basesBeingResolved != null && ConsListExtensions.ContainsReference<TypeSymbol>(basesBeingResolved, type.OriginalDefinition))
{
Symbol nearestOtherSymbol = GetNearestOtherSymbol(basesBeingResolved, type);
CSDiagnosticInfo errorInfo = new CSDiagnosticInfo(ErrorCode.ERR_CircularBase, type, nearestOtherSymbol);
ExtendedErrorTypeSymbol symbol = new ExtendedErrorTypeSymbol(Compilation, name, arity, (DiagnosticInfo?)(object)errorInfo, unreported: true);
result.SetFrom(LookupResult.Good(symbol));
}
if (originalBinder.InCrefButNotParameterOrReturnType)
{
break;
}
typeSymbol = typeSymbol.GetNextBaseTypeNoUseSiteDiagnostics(basesBeingResolved, Compilation, ref visited);
typeSymbol?.OriginalDefinition.AddUseSiteInfo(ref useSiteInfo);
}
visited?.Free();
instance.Free();
}
private void AddWinRTMembers(LookupResult result, NamedTypeSymbol type, string name, int arity, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Invalid comparison between Unknown and I4
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Invalid comparison between Unknown and I4
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Invalid comparison between Unknown and I4
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Invalid comparison between Unknown and I4
MemberSignatureComparer cSharpOverrideComparer = MemberSignatureComparer.CSharpOverrideComparer;
HashSet<Symbol> hashSet = new HashSet<Symbol>(cSharpOverrideComparer);
HashSet<Symbol> hashSet2 = new HashSet<Symbol>(cSharpOverrideComparer);
if (result.IsMultiViable)
{
Enumerator<Symbol> enumerator = result.Symbols.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
if ((int)current.Kind == 9 || (int)current.Kind == 15)
{
hashSet.Add(current);
}
}
}
LookupResult instance = LookupResult.GetInstance();
GetWellKnownWinRTMemberInterfaces(out var idictSymbol, out var iroDictSymbol, out var iListSymbol, out var iCollectionSymbol, out var inccSymbol, out var inpcSymbol);
ImmutableArray<NamedTypeSymbol>.Enumerator enumerator2 = type.AllInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteInfo).GetEnumerator();
while (enumerator2.MoveNext())
{
NamedTypeSymbol current2 = enumerator2.Current;
if (!ShouldAddWinRTMembersForInterface(current2, idictSymbol, iroDictSymbol, iListSymbol, iCollectionSymbol, inccSymbol, inpcSymbol))
{
continue;
}
LookupMembersWithoutInheritance(instance, current2, name, arity, options, originalBinder, current2, diagnose, ref useSiteInfo, null);
if (instance.IsMultiViable)
{
Enumerator<Symbol> enumerator = instance.Symbols.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current3 = enumerator.Current;
if (!hashSet.Add(current3))
{
hashSet2.Add(current3);
}
}
}
instance.Clear();
}
instance.Free();
if (result.IsMultiViable)
{
Enumerator<Symbol> enumerator = result.Symbols.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current4 = enumerator.Current;
if ((int)current4.Kind == 9 || (int)current4.Kind == 15)
{
hashSet.Remove(current4);
hashSet2.Remove(current4);
}
}
}
foreach (Symbol item in hashSet)
{
if (!hashSet2.Contains(item))
{
result.MergeEqual(new SingleLookupResult(LookupResultKind.Viable, item, null));
}
}
}
private void GetWellKnownWinRTMemberInterfaces(out NamedTypeSymbol idictSymbol, out NamedTypeSymbol iroDictSymbol, out NamedTypeSymbol iListSymbol, out NamedTypeSymbol iCollectionSymbol, out NamedTypeSymbol inccSymbol, out NamedTypeSymbol inpcSymbol)
{
idictSymbol = Compilation.GetWellKnownType((WellKnownType)207);
iroDictSymbol = Compilation.GetWellKnownType((WellKnownType)208);
iListSymbol = Compilation.GetWellKnownType((WellKnownType)202);
iCollectionSymbol = Compilation.GetWellKnownType((WellKnownType)203);
inccSymbol = Compilation.GetWellKnownType((WellKnownType)211);
inpcSymbol = Compilation.GetWellKnownType((WellKnownType)212);
}
private static bool ShouldAddWinRTMembersForInterface(NamedTypeSymbol iface, NamedTypeSymbol idictSymbol, NamedTypeSymbol iroDictSymbol, NamedTypeSymbol iListSymbol, NamedTypeSymbol iCollectionSymbol, NamedTypeSymbol inccSymbol, NamedTypeSymbol inpcSymbol)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Invalid comparison between Unknown and I4
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Invalid comparison between Unknown and I4
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Invalid comparison between Unknown and I4
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Invalid comparison between Unknown and I4
NamedTypeSymbol originalDefinition = iface.OriginalDefinition;
SpecialType specialType = originalDefinition.SpecialType;
if ((int)specialType != 25 && (int)specialType != 26 && (int)specialType != 27 && !TypeSymbol.Equals(originalDefinition, idictSymbol, (TypeCompareKind)0) && (int)specialType != 30 && (int)specialType != 31 && !TypeSymbol.Equals(originalDefinition, iroDictSymbol, (TypeCompareKind)0) && (int)specialType != 24 && !TypeSymbol.Equals(originalDefinition, iListSymbol, (TypeCompareKind)0) && !TypeSymbol.Equals(originalDefinition, iCollectionSymbol, (TypeCompareKind)0) && !TypeSymbol.Equals(originalDefinition, inccSymbol, (TypeCompareKind)0))
{
return TypeSymbol.Equals(originalDefinition, inpcSymbol, (TypeCompareKind)0);
}
return true;
}
private static Symbol GetNearestOtherSymbol(ConsList<TypeSymbol> list, TypeSymbol type)
{
TypeSymbol typeSymbol = type;
while (list != null && list != ConsList<TypeSymbol>.Empty)
{
if (TypeSymbol.Equals(list.Head, type.OriginalDefinition, (TypeCompareKind)0))
{
if (TypeSymbol.Equals(typeSymbol, type, (TypeCompareKind)0) && list.Tail != null && list.Tail != ConsList<TypeSymbol>.Empty)
{
typeSymbol = list.Tail.Head;
}
break;
}
typeSymbol = list.Head;
list = list.Tail;
}
return typeSymbol;
}
private void LookupMembersInInterfaceOnly(LookupResult current, NamedTypeSymbol type, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, TypeSymbol accessThroughType, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
LookupMembersWithoutInheritance(current, type, name, arity, options, originalBinder, accessThroughType, diagnose, ref useSiteInfo, basesBeingResolved);
if ((options & LookupOptions.NamespaceAliasesOnly) == 0 && !originalBinder.InCrefButNotParameterOrReturnType && ((options & LookupOptions.NamespacesOrTypesOnly) == 0 || !current.IsSingleViable || !TypeSymbol.Equals(current.SingleSymbolOrDefault.ContainingType, type, (TypeCompareKind)63)))
{
LookupMembersInInterfacesWithoutInheritance(current, GetBaseInterfaces(type, basesBeingResolved, ref useSiteInfo), name, arity, basesBeingResolved, options, originalBinder, accessThroughType, diagnose, ref useSiteInfo);
}
}
private static ImmutableArray<NamedTypeSymbol> GetBaseInterfaces(NamedTypeSymbol type, ConsList<TypeSymbol> basesBeingResolved, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
if (basesBeingResolved == null || !basesBeingResolved.Any())
{
return type.AllInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteInfo);
}
if (ConsListExtensions.ContainsReference<TypeSymbol>(basesBeingResolved, (TypeSymbol)type.OriginalDefinition))
{
return ImmutableArray<NamedTypeSymbol>.Empty;
}
ImmutableArray<NamedTypeSymbol> declaredInterfaces = type.GetDeclaredInterfaces(basesBeingResolved);
if (declaredInterfaces.IsEmpty)
{
return ImmutableArray<NamedTypeSymbol>.Empty;
}
ConsList<NamedTypeSymbol> cycleGuard = ConsListExtensions.Prepend<NamedTypeSymbol>(ConsList<NamedTypeSymbol>.Empty, type.OriginalDefinition);
ArrayBuilder<NamedTypeSymbol> instance = ArrayBuilder<NamedTypeSymbol>.GetInstance();
HashSet<NamedTypeSymbol> visited = new HashSet<NamedTypeSymbol>(SymbolEqualityComparer.ConsiderEverything);
for (int num = declaredInterfaces.Length - 1; num >= 0; num--)
{
addAllInterfaces(declaredInterfaces[num], visited, instance, basesBeingResolved, cycleGuard);
}
instance.ReverseContents();
Enumerator<NamedTypeSymbol> enumerator = instance.GetEnumerator();
while (enumerator.MoveNext())
{
enumerator.Current.OriginalDefinition.AddUseSiteInfo(ref useSiteInfo);
}
return instance.ToImmutableAndFree();
static void addAllInterfaces(NamedTypeSymbol @interface, HashSet<NamedTypeSymbol> hashSet, ArrayBuilder<NamedTypeSymbol> result, ConsList<TypeSymbol> val2, ConsList<NamedTypeSymbol> val)
{
NamedTypeSymbol originalDefinition;
if (@interface.IsInterface && !ConsListExtensions.ContainsReference<NamedTypeSymbol>(val, originalDefinition = @interface.OriginalDefinition) && hashSet.Add(@interface))
{
if (!ConsListExtensions.ContainsReference<TypeSymbol>(val2, (TypeSymbol)originalDefinition))
{
ImmutableArray<NamedTypeSymbol> declaredInterfaces2 = @interface.GetDeclaredInterfaces(val2);
if (!declaredInterfaces2.IsEmpty)
{
val = ConsListExtensions.Prepend<NamedTypeSymbol>(val, originalDefinition);
for (int num2 = declaredInterfaces2.Length - 1; num2 >= 0; num2--)
{
addAllInterfaces(declaredInterfaces2[num2], hashSet, result, val2, val);
}
}
}
result.Add(@interface);
}
}
}
private void LookupMembersInInterfacesWithoutInheritance(LookupResult current, ImmutableArray<NamedTypeSymbol> interfaces, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, TypeSymbol accessThroughType, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
if (interfaces.Length <= 0)
{
return;
}
LookupResult instance = LookupResult.GetInstance();
HashSet<NamedTypeSymbol> hashSet = null;
if (interfaces.Length > 1)
{
hashSet = new HashSet<NamedTypeSymbol>(SymbolEqualityComparer.IgnoringNullable);
}
ImmutableArray<NamedTypeSymbol>.Enumerator enumerator = interfaces.GetEnumerator();
while (enumerator.MoveNext())
{
NamedTypeSymbol current2 = enumerator.Current;
if (hashSet == null || hashSet.Add(current2))
{
LookupMembersWithoutInheritance(instance, current2, name, arity, options, originalBinder, accessThroughType, diagnose, ref useSiteInfo, basesBeingResolved);
MergeHidingLookupResults(current, instance, basesBeingResolved, ref useSiteInfo);
instance.Clear();
}
}
instance.Free();
}
private void LookupMembersInInterface(LookupResult current, NamedTypeSymbol type, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
LookupMembersInInterfaceOnly(current, type, name, arity, basesBeingResolved, options, originalBinder, type, diagnose, ref useSiteInfo);
if (!originalBinder.InCrefButNotParameterOrReturnType)
{
LookupResult instance = LookupResult.GetInstance();
LookupMembersInClass(instance, Compilation.GetSpecialType((SpecialType)1), name, arity, basesBeingResolved, options, originalBinder, type, diagnose, ref useSiteInfo);
MergeHidingLookupResults(current, instance, basesBeingResolved, ref useSiteInfo);
instance.Free();
}
}
private void LookupMembersInTypeParameter(LookupResult current, TypeParameterSymbol typeParameter, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
if ((options & (LookupOptions.NamespaceAliasesOnly | LookupOptions.NamespacesOrTypesOnly)) == 0)
{
LookupMembersInClass(current, typeParameter.EffectiveBaseClass(ref useSiteInfo), name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteInfo);
LookupMembersInInterfacesWithoutInheritance(current, typeParameter.AllEffectiveInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteInfo), name, arity, null, options, originalBinder, typeParameter, diagnose, ref useSiteInfo);
}
}
private static bool IsDerivedType(NamedTypeSymbol baseType, NamedTypeSymbol derivedType, ConsList<TypeSymbol> basesBeingResolved, CSharpCompilation compilation, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
if (basesBeingResolved == null || !basesBeingResolved.Any())
{
NamedTypeSymbol namedTypeSymbol = derivedType.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteInfo);
while ((object)namedTypeSymbol != null)
{
if (TypeSymbol.Equals(namedTypeSymbol, baseType, (TypeCompareKind)0))
{
return true;
}
namedTypeSymbol = namedTypeSymbol.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteInfo);
}
}
else
{
PooledHashSet<NamedTypeSymbol> visited = null;
NamedTypeSymbol namedTypeSymbol2 = (NamedTypeSymbol)derivedType.GetNextBaseTypeNoUseSiteDiagnostics(basesBeingResolved, compilation, ref visited);
while ((object)namedTypeSymbol2 != null)
{
namedTypeSymbol2.OriginalDefinition.AddUseSiteInfo(ref useSiteInfo);
if (TypeSymbol.Equals(namedTypeSymbol2, baseType, (TypeCompareKind)0))
{
visited?.Free();
return true;
}
namedTypeSymbol2 = (NamedTypeSymbol)namedTypeSymbol2.GetNextBaseTypeNoUseSiteDiagnostics(basesBeingResolved, compilation, ref visited);
}
visited?.Free();
}
if (baseType.IsInterface)
{
return GetBaseInterfaces(derivedType, basesBeingResolved, ref useSiteInfo).Contains(baseType);
}
return false;
}
private void MergeHidingLookupResults(LookupResult resultHiding, LookupResult resultHidden, ConsList<TypeSymbol> basesBeingResolved, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Invalid comparison between Unknown and I4
if (resultHiding.IsMultiViable && resultHidden.IsMultiViable)
{
ArrayBuilder<Symbol> symbols = resultHiding.Symbols;
int count = symbols.Count;
ArrayBuilder<Symbol> symbols2 = resultHidden.Symbols;
int count2 = symbols2.Count;
for (int i = 0; i < count2; i++)
{
Symbol symbol = symbols2[i];
NamedTypeSymbol containingType = symbol.ContainingType;
int num = 0;
while (true)
{
if (num < count)
{
Symbol symbol2 = symbols[num];
if ((!symbol2.ContainingType.IsInterface || IsDerivedType(containingType, symbol2.ContainingType, basesBeingResolved, Compilation, ref useSiteInfo) || (int)containingType.SpecialType == 1) && (!IsMethodOrIndexer(symbol2) || !IsMethodOrIndexer(symbol)))
{
break;
}
num++;
continue;
}
symbols.Add(symbol);
break;
}
}
}
else
{
resultHiding.MergePrioritized(resultHidden);
}
}
private static bool IsMethodOrIndexer(Symbol symbol)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
if ((int)symbol.Kind != 9)
{
return symbol.IsIndexer();
}
return true;
}
internal static ImmutableArray<Symbol> GetCandidateMembers(NamespaceOrTypeSymbol nsOrType, string name, LookupOptions options, Binder originalBinder)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Invalid comparison between Unknown and I4
if ((options & LookupOptions.NamespacesOrTypesOnly) != LookupOptions.Default && nsOrType is TypeSymbol)
{
return ImmutableArrayExtensions.Cast<NamedTypeSymbol, Symbol>(nsOrType.GetTypeMembers(name));
}
if ((int)nsOrType.Kind == 11 && originalBinder.IsEarlyAttributeBinder)
{
return ((NamedTypeSymbol)nsOrType).GetEarlyAttributeDecodingMembers(name);
}
if ((options & LookupOptions.LabelsOnly) != LookupOptions.Default)
{
return ImmutableArray<Symbol>.Empty;
}
if (nsOrType is SourceMemberContainerTypeSymbol { HasPrimaryConstructor: not false } sourceMemberContainerTypeSymbol)
{
return sourceMemberContainerTypeSymbol.GetCandidateMembersForLookup(name);
}
return nsOrType.GetMembers(name);
}
internal static ImmutableArray<Symbol> GetCandidateMembers(NamespaceOrTypeSymbol nsOrType, LookupOptions options, Binder originalBinder)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Invalid comparison between Unknown and I4
if ((options & LookupOptions.NamespacesOrTypesOnly) != LookupOptions.Default && nsOrType is TypeSymbol)
{
return StaticCast<Symbol>.From<NamedTypeSymbol>(nsOrType.GetTypeMembersUnordered());
}
if ((int)nsOrType.Kind == 11 && originalBinder.IsEarlyAttributeBinder)
{
return ((NamedTypeSymbol)nsOrType).GetEarlyAttributeDecodingMembers();
}
if ((options & LookupOptions.LabelsOnly) != LookupOptions.Default)
{
return ImmutableArray<Symbol>.Empty;
}
return nsOrType.GetMembersUnordered();
}
private bool IsInScopeOfAssociatedSyntaxTree(Symbol symbol)
{
while (((object)symbol != null && !(symbol is NamedTypeSymbol { IsFileLocal: not false })) ? true : false)
{
symbol = symbol.ContainingType;
}
if ((object)symbol == null)
{
return true;
}
if (symbol.DeclaringCompilation != Compilation && (Flags & BinderFlags.InEEMethodBinder) == 0)
{
return false;
}
FileIdentifier associatedFileIdentifier = ((NamedTypeSymbol)symbol).AssociatedFileIdentifier;
if (associatedFileIdentifier == null || associatedFileIdentifier.FilePathChecksumOpt.IsDefault)
{
return false;
}
FileIdentifier fileIdentifier = getFileIdentifierForFileTypes();
if (!fileIdentifier.FilePathChecksumOpt.IsDefault)
{
return fileIdentifier.FilePathChecksumOpt.SequenceEqual(associatedFileIdentifier.FilePathChecksumOpt);
}
return false;
FileIdentifier getFileIdentifierForFileTypes()
{
for (Binder binder = this; binder != null; binder = binder.Next)
{
if (binder is BuckStopsHereBinder buckStopsHereBinder)
{
return buckStopsHereBinder.AssociatedFileIdentifier ?? throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs", 1374);
}
}
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs", 1378);
}
}
internal SingleLookupResult CheckViability(Symbol symbol, int arity, LookupOptions options, TypeSymbol accessThroughType, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConsList<TypeSymbol> basesBeingResolved = null)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0381: Unknown result type (might be due to invalid IL or missing references)
//IL_0388: Invalid comparison between Unknown and I4
//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
//IL_03dd: Invalid comparison between Unknown and I4
Symbol unwrappedSymbol = (((int)symbol.Kind == 0) ? ((AliasSymbol)symbol).GetAliasTarget(basesBeingResolved) : symbol);
if ((options & LookupOptions.MustNotBeParameter) != LookupOptions.Default && unwrappedSymbol is ParameterSymbol)
{
return LookupResult.Empty();
}
if (!IsInScopeOfAssociatedSyntaxTree(unwrappedSymbol))
{
return LookupResult.Empty();
}
if (!Compilation.SourceModule.Equals(unwrappedSymbol.ContainingModule) && unwrappedSymbol.IsHiddenByCodeAnalysisEmbeddedAttribute())
{
return LookupResult.Empty();
}
if ((options & (LookupOptions.MustNotBeInstance | LookupOptions.MustBeAbstractOrVirtual)) == (LookupOptions.MustNotBeInstance | LookupOptions.MustBeAbstractOrVirtual) && ((!(unwrappedSymbol is TypeSymbol) && IsInstance(unwrappedSymbol)) || (!unwrappedSymbol.IsAbstract && !unwrappedSymbol.IsVirtual)))
{
return LookupResult.Empty();
}
if (WrongArity(symbol, arity, diagnose, options, out var diagInfo))
{
return LookupResult.WrongArity(symbol, diagInfo);
}
if (!InCref && !unwrappedSymbol.CanBeReferencedByNameIgnoringIllegalCharacters)
{
diagInfo = (DiagnosticInfo)(object)(diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_CantCallSpecialMethod, unwrappedSymbol) : null);
return LookupResult.NotReferencable(symbol, diagInfo);
}
if ((options & LookupOptions.NamespacesOrTypesOnly) != LookupOptions.Default && !(unwrappedSymbol is NamespaceOrTypeSymbol))
{
return LookupResult.NotTypeOrNamespace(unwrappedSymbol, symbol, diagnose);
}
if ((options & LookupOptions.MustBeInvocableIfMember) != LookupOptions.Default && IsNonInvocableMember(unwrappedSymbol))
{
return LookupResult.NotInvocable(unwrappedSymbol, symbol, diagnose);
}
if (InCref && !IsCrefAccessible(unwrappedSymbol))
{
ImmutableArray<Symbol> symbols = ImmutableArray.Create(unwrappedSymbol);
object obj;
if (!diagnose)
{
obj = null;
}
else
{
object[] args = new Symbol[1] { unwrappedSymbol };
obj = new CSDiagnosticInfo(ErrorCode.ERR_BadAccess, args, symbols, ImmutableArray<Location>.Empty);
}
diagInfo = (DiagnosticInfo)obj;
return LookupResult.Inaccessible(symbol, diagInfo);
}
if (!InCref && !IsAccessible(unwrappedSymbol, RefineAccessThroughType(options, accessThroughType), out var failedThroughTypeCheck, ref useSiteInfo, basesBeingResolved))
{
if (!diagnose)
{
diagInfo = null;
}
else if (failedThroughTypeCheck)
{
diagInfo = (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_BadProtectedAccess, unwrappedSymbol, accessThroughType, ContainingType);
}
else if (IsBadIvtSpecification())
{
diagInfo = (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_FriendRefNotEqualToThis, ((object)unwrappedSymbol.ContainingAssembly.Identity).ToString(), AssemblyIdentity.PublicKeyToString(Compilation.Assembly.PublicKey));
}
else
{
object[] args = new Symbol[1] { unwrappedSymbol };
diagInfo = (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_BadAccess, args, ImmutableArray.Create(unwrappedSymbol), ImmutableArray<Location>.Empty);
}
return LookupResult.Inaccessible(symbol, diagInfo);
}
if (!InCref && unwrappedSymbol.MustCallMethodsDirectly())
{
diagInfo = (DiagnosticInfo)(object)(diagnose ? MakeCallMethodsDirectlyDiagnostic(unwrappedSymbol) : null);
return LookupResult.NotReferencable(symbol, diagInfo);
}
if ((options & LookupOptions.MustBeInstance) != LookupOptions.Default && !IsInstance(unwrappedSymbol))
{
diagInfo = (DiagnosticInfo)(object)(diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_ObjectRequired, unwrappedSymbol) : null);
return LookupResult.StaticInstanceMismatch(symbol, diagInfo);
}
if ((options & LookupOptions.MustNotBeInstance) != LookupOptions.Default && IsInstance(unwrappedSymbol))
{
diagInfo = (DiagnosticInfo)(object)(diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_ObjectProhibited, unwrappedSymbol) : null);
return LookupResult.StaticInstanceMismatch(symbol, diagInfo);
}
if ((options & LookupOptions.MustNotBeNamespace) != LookupOptions.Default && (int)unwrappedSymbol.Kind == 12)
{
diagInfo = (DiagnosticInfo)(object)(diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_BadSKunknown, unwrappedSymbol, unwrappedSymbol.GetKindText()) : null);
return LookupResult.NotTypeOrNamespace(symbol, diagInfo);
}
if ((options & LookupOptions.LabelsOnly) != LookupOptions.Default && (int)unwrappedSymbol.Kind != 7)
{
diagInfo = (DiagnosticInfo)(object)(diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_LabelNotFound, unwrappedSymbol.Name) : null);
return LookupResult.NotLabel(symbol, diagInfo);
}
return LookupResult.Good(symbol);
bool IsBadIvtSpecification()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Invalid comparison between Unknown and I4
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Invalid comparison between Unknown and I4
if (((int)unwrappedSymbol.DeclaredAccessibility == 4 || (int)unwrappedSymbol.DeclaredAccessibility == 2 || (int)unwrappedSymbol.DeclaredAccessibility == 5) && !options.IsAttributeTypeLookup())
{
string assemblyName = ((Compilation)Compilation).AssemblyName;
if (assemblyName == null)
{
return false;
}
IEnumerable<ImmutableArray<byte>> internalsVisibleToPublicKeys = unwrappedSymbol.ContainingAssembly.GetInternalsVisibleToPublicKeys(assemblyName);
if (!internalsVisibleToPublicKeys.Any())
{
return false;
}
ImmutableArray<byte> publicKey = Compilation.Assembly.PublicKey;
if (!publicKey.IsDefault)
{
foreach (ImmutableArray<byte> item in internalsVisibleToPublicKeys)
{
if (item.SequenceEqual(publicKey))
{
return false;
}
}
}
return true;
}
return false;
}
}
private CSDiagnosticInfo MakeCallMethodsDirectlyDiagnostic(Symbol symbol)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
SymbolKind kind = symbol.Kind;
MethodSymbol methodSymbol;
MethodSymbol methodSymbol2;
if ((int)kind != 5)
{
if ((int)kind != 15)
{
throw ExceptionUtilities.UnexpectedValue((object)symbol.Kind);
}
PropertySymbol leastOverriddenProperty = ((PropertySymbol)symbol).GetLeastOverriddenProperty(ContainingType);
methodSymbol = leastOverriddenProperty.GetMethod;
methodSymbol2 = leastOverriddenProperty.SetMethod;
}
else
{
EventSymbol leastOverriddenEvent = ((EventSymbol)symbol).GetLeastOverriddenEvent(ContainingType);
methodSymbol = leastOverriddenEvent.AddMethod;
methodSymbol2 = leastOverriddenEvent.RemoveMethod;
}
if ((object)methodSymbol == null || (object)methodSymbol2 == null)
{
return new CSDiagnosticInfo(ErrorCode.ERR_BindToBogusProp1, symbol, methodSymbol ?? methodSymbol2);
}
return new CSDiagnosticInfo(ErrorCode.ERR_BindToBogusProp2, symbol, methodSymbol, methodSymbol2);
}
internal bool CanAddLookupSymbolInfo(Symbol symbol, LookupOptions options, LookupSymbolsInfo info, TypeSymbol accessThroughType, AliasSymbol aliasSymbol = null)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Invalid comparison between Unknown and I4
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
string text = ((aliasSymbol != null) ? aliasSymbol.Name : symbol.Name);
if (!((AbstractLookupSymbolsInfo<Symbol>)info).CanBeAdded(text))
{
return false;
}
if ((options & LookupOptions.NamespacesOrTypesOnly) != LookupOptions.Default && !(symbol is NamespaceOrTypeSymbol))
{
return false;
}
if ((options & LookupOptions.MustBeInvocableIfMember) != LookupOptions.Default && IsNonInvocableMember(symbol))
{
return false;
}
if (InCref ? (!IsCrefAccessible(symbol)) : (!IsAccessible(symbol, ref useSiteInfo, RefineAccessThroughType(options, accessThroughType))))
{
return false;
}
if (!IsInScopeOfAssociatedSyntaxTree(symbol))
{
return false;
}
if ((options & LookupOptions.MustBeInstance) != LookupOptions.Default && !IsInstance(symbol))
{
return false;
}
if ((options & LookupOptions.MustNotBeInstance) != LookupOptions.Default && IsInstance(symbol))
{
return false;
}
if ((options & LookupOptions.MustNotBeNamespace) != LookupOptions.Default && (int)symbol.Kind == 12)
{
return false;
}
return true;
}
private static TypeSymbol RefineAccessThroughType(LookupOptions options, TypeSymbol accessThroughType)
{
if ((options & LookupOptions.UseBaseReferenceAccessibility) == 0)
{
return accessThroughType;
}
return null;
}
private bool IsCrefAccessible(Symbol symbol)
{
if (IsEffectivelyPrivate(symbol))
{
return symbol.ContainingAssembly == Compilation.Assembly;
}
return true;
}
private static bool IsEffectivelyPrivate(Symbol symbol)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
Symbol symbol2 = symbol;
while ((object)symbol2 != null)
{
if ((int)symbol2.DeclaredAccessibility == 1)
{
return true;
}
symbol2 = symbol2.ContainingSymbol;
}
return false;
}
internal bool IsAccessible(Symbol symbol, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, TypeSymbol accessThroughType = null, ConsList<TypeSymbol> basesBeingResolved = null)
{
bool failedThroughTypeCheck;
return IsAccessible(symbol, accessThroughType, out failedThroughTypeCheck, ref useSiteInfo, basesBeingResolved);
}
internal bool IsAccessible(Symbol symbol, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
bool result = IsAccessible(symbol, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(syntax, useSiteInfo);
return result;
}
internal bool IsAccessible(Symbol symbol, TypeSymbol accessThroughType, out bool failedThroughTypeCheck, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConsList<TypeSymbol> basesBeingResolved = null)
{
if (Flags.Includes(BinderFlags.IgnoreAccessibility))
{
failedThroughTypeCheck = false;
return true;
}
return IsAccessibleHelper(symbol, accessThroughType, out failedThroughTypeCheck, ref useSiteInfo, basesBeingResolved);
}
internal virtual bool IsAccessibleHelper(Symbol symbol, TypeSymbol accessThroughType, out bool failedThroughTypeCheck, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConsList<TypeSymbol> basesBeingResolved)
{
return Next.IsAccessibleHelper(symbol, accessThroughType, out failedThroughTypeCheck, ref useSiteInfo, basesBeingResolved);
}
internal bool IsNonInvocableMember(Symbol symbol)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected I4, but got Unknown
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
SymbolKind kind = symbol.Kind;
switch (kind - 5)
{
default:
if ((int)kind != 15)
{
break;
}
goto case 0;
case 0:
case 1:
case 4:
case 6:
return !IsInvocableMember(symbol);
case 2:
case 3:
case 5:
break;
}
return false;
}
private bool IsInvocableMember(Symbol symbol)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: 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)
//IL_0025: Expected I4, but got Unknown
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Invalid comparison between Unknown and I4
TypeSymbol typeSymbol = null;
SymbolKind kind = symbol.Kind;
switch (kind - 5)
{
default:
if ((int)kind == 15)
{
typeSymbol = ((PropertySymbol)symbol).Type;
}
break;
case 0:
case 4:
return true;
case 1:
typeSymbol = ((FieldSymbol)symbol).GetFieldType(FieldsBeingBound).Type;
break;
case 2:
case 3:
break;
}
if ((object)typeSymbol != null)
{
if (!typeSymbol.IsDelegateType() && !typeSymbol.IsDynamic())
{
return typeSymbol.IsFunctionPointer();
}
return true;
}
return false;
}
private static bool IsInstance(Symbol symbol)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Invalid comparison between Unknown and I4
SymbolKind kind = symbol.Kind;
if (kind - 5 <= 1 || (int)kind == 9 || (int)kind == 15)
{
return symbol.RequiresInstanceReceiver();
}
return false;
}
private static bool WrongArity(Symbol symbol, int arity, bool diagnose, LookupOptions options, out DiagnosticInfo diagInfo)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
SymbolKind kind = symbol.Kind;
if ((int)kind != 9)
{
if ((int)kind == 11)
{
if (arity != 0 || (options & LookupOptions.AllNamedTypesOnArityZero) == 0)
{
NamedTypeSymbol namedTypeSymbol = (NamedTypeSymbol)symbol;
if (namedTypeSymbol.Arity != arity)
{
if (namedTypeSymbol.Arity == 0)
{
diagInfo = (DiagnosticInfo)(object)(diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_HasNoTypeVars, namedTypeSymbol, MessageID.IDS_SK_TYPE.Localize()) : null);
}
else
{
diagInfo = (DiagnosticInfo)(object)(diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_BadArity, namedTypeSymbol, MessageID.IDS_SK_TYPE.Localize(), namedTypeSymbol.Arity) : null);
}
return true;
}
}
}
else if (arity != 0)
{
diagInfo = (DiagnosticInfo)(object)(diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_TypeArgsNotAllowed, symbol, symbol.Kind.Localize()) : null);
return true;
}
}
else if (arity != 0 || (options & LookupOptions.AllMethodsOnArityZero) == 0)
{
MethodSymbol methodSymbol = (MethodSymbol)symbol;
if (methodSymbol.Arity != arity)
{
if (methodSymbol.Arity == 0)
{
diagInfo = (DiagnosticInfo)(object)(diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_HasNoTypeVars, methodSymbol, MessageID.IDS_SK_METHOD.Localize()) : null);
}
else
{
diagInfo = (DiagnosticInfo)(object)(diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_BadArity, methodSymbol, MessageID.IDS_SK_METHOD.Localize(), methodSymbol.Arity) : null);
}
return true;
}
}
diagInfo = null;
return false;
}
internal void AddLookupSymbolsInfo(LookupSymbolsInfo result, LookupOptions options = LookupOptions.Default)
{
Binder binder = this;
while (binder != null)
{
binder.AddLookupSymbolsInfoInSingleBinder(result, options, this);
if ((options & LookupOptions.LabelsOnly) == 0 || !binder.IsLastBinderWithinMember())
{
binder = binder.Next;
continue;
}
break;
}
}
internal virtual void AddLookupSymbolsInfoInSingleBinder(LookupSymbolsInfo info, LookupOptions options, Binder originalBinder)
{
}
internal void AddMemberLookupSymbolsInfo(LookupSymbolsInfo result, NamespaceOrTypeSymbol nsOrType, LookupOptions options, Binder originalBinder)
{
if (nsOrType.IsNamespace)
{
AddMemberLookupSymbolsInfoInNamespace(result, (NamespaceSymbol)nsOrType, options, originalBinder);
}
else
{
AddMemberLookupSymbolsInfoInType(result, (TypeSymbol)nsOrType, options, originalBinder);
}
}
private void AddMemberLookupSymbolsInfoInType(LookupSymbolsInfo result, TypeSymbol type, LookupOptions options, Binder originalBinder)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected I4, but got Unknown
TypeKind typeKind = type.TypeKind;
switch (typeKind - 1)
{
case 10:
AddMemberLookupSymbolsInfoInTypeParameter(result, (TypeParameterSymbol)type, options, originalBinder);
break;
case 6:
AddMemberLookupSymbolsInfoInInterface(result, type, options, originalBinder, type);
break;
case 0:
case 1:
case 2:
case 3:
case 4:
case 9:
case 11:
AddMemberLookupSymbolsInfoInClass(result, type, options, originalBinder, type);
break;
case 5:
case 7:
case 8:
break;
}
}
protected void AddMemberLookupSymbolsInfoInSubmissions(LookupSymbolsInfo result, TypeSymbol scriptClass, bool inUsings, LookupOptions options, Binder originalBinder)
{
for (CSharpCompilation cSharpCompilation = Compilation; cSharpCompilation != null; cSharpCompilation = cSharpCompilation.PreviousSubmission)
{
if ((object)cSharpCompilation.ScriptClass != null)
{
AddMemberLookupSymbolsInfoWithoutInheritance(result, cSharpCompilation.ScriptClass, options, originalBinder, scriptClass);
}
bool flag = cSharpCompilation == Compilation;
if ((options & LookupOptions.LabelsOnly) == 0 && !(flag && inUsings))
{
Imports imports = cSharpCompilation.GetSubmissionImports();
if (!flag)
{
imports = Imports.ExpandPreviousSubmissionImports(imports, Compilation);
}
AddLookupSymbolsInfoInAliases(imports.UsingAliases, imports.ExternAliases, result, options, originalBinder);
}
}
}
protected void AddLookupSymbolsInfoInAliases(ImmutableDictionary<string, AliasAndUsingDirective> usingAliases, ImmutableArray<AliasAndExternAliasDirective> externAliases, LookupSymbolsInfo result, LookupOptions options, Binder originalBinder)
{
if ((options & LookupOptions.LabelsOnly) != LookupOptions.Default)
{
return;
}
foreach (KeyValuePair<string, AliasAndUsingDirective> usingAlias in usingAliases)
{
addAliasSymbolToResult(result, usingAlias.Value.Alias, options, originalBinder);
}
ImmutableArray<AliasAndExternAliasDirective>.Enumerator enumerator2 = externAliases.GetEnumerator();
while (enumerator2.MoveNext())
{
AliasAndExternAliasDirective current = enumerator2.Current;
if (!current.SkipInLookup)
{
addAliasSymbolToResult(result, current.Alias, options, originalBinder);
}
}
static void addAliasSymbolToResult(LookupSymbolsInfo lookupSymbolsInfo, AliasSymbol aliasSymbol, LookupOptions options2, Binder binder)
{
NamespaceOrTypeSymbol aliasTarget = aliasSymbol.GetAliasTarget(null);
if (binder.CanAddLookupSymbolInfo(aliasTarget, options2, lookupSymbolsInfo, null, aliasSymbol))
{
((AbstractLookupSymbolsInfo<Symbol>)lookupSymbolsInfo).AddSymbol((Symbol)aliasSymbol, aliasSymbol.Name, 0);
}
}
}
private static void AddMemberLookupSymbolsInfoInNamespace(LookupSymbolsInfo result, NamespaceSymbol ns, LookupOptions options, Binder originalBinder)
{
ImmutableArray<Symbol>.Enumerator enumerator = ((((AbstractLookupSymbolsInfo<Symbol>)result).FilterName != null) ? GetCandidateMembers(ns, ((AbstractLookupSymbolsInfo<Symbol>)result).FilterName, options, originalBinder) : GetCandidateMembers(ns, options, originalBinder)).GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
if (originalBinder.CanAddLookupSymbolInfo(current, options, result, null))
{
((AbstractLookupSymbolsInfo<Symbol>)result).AddSymbol(current, current.Name, current.GetArity());
}
}
}
private static void AddMemberLookupSymbolsInfoWithoutInheritance(LookupSymbolsInfo result, TypeSymbol type, LookupOptions options, Binder originalBinder, TypeSymbol accessThroughType)
{
ImmutableArray<Symbol>.Enumerator enumerator = ((((AbstractLookupSymbolsInfo<Symbol>)result).FilterName != null) ? GetCandidateMembers(type, ((AbstractLookupSymbolsInfo<Symbol>)result).FilterName, options, originalBinder) : GetCandidateMembers(type, options, originalBinder)).GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
if (originalBinder.CanAddLookupSymbolInfo(current, options, result, accessThroughType))
{
((AbstractLookupSymbolsInfo<Symbol>)result).AddSymbol(current, current.Name, current.GetArity());
}
}
}
private void AddWinRTMembersLookupSymbolsInfo(LookupSymbolsInfo result, NamedTypeSymbol type, LookupOptions options, Binder originalBinder, TypeSymbol accessThroughType)
{
GetWellKnownWinRTMemberInterfaces(out var idictSymbol, out var iroDictSymbol, out var iListSymbol, out var iCollectionSymbol, out var inccSymbol, out var inpcSymbol);
ImmutableArray<NamedTypeSymbol>.Enumerator enumerator = type.AllInterfacesNoUseSiteDiagnostics.GetEnumerator();
while (enumerator.MoveNext())
{
NamedTypeSymbol current = enumerator.Current;
if (ShouldAddWinRTMembersForInterface(current, idictSymbol, iroDictSymbol, iListSymbol, iCollectionSymbol, inccSymbol, inpcSymbol))
{
AddMemberLookupSymbolsInfoWithoutInheritance(result, current, options, originalBinder, accessThroughType);
}
}
}
private void AddMemberLookupSymbolsInfoInClass(LookupSymbolsInfo result, TypeSymbol type, LookupOptions options, Binder originalBinder, TypeSymbol accessThroughType)
{
PooledHashSet<NamedTypeSymbol> visited = null;
while ((object)type != null && !type.IsVoidType())
{
AddMemberLookupSymbolsInfoWithoutInheritance(result, type, options, originalBinder, accessThroughType);
if (type is NamedTypeSymbol { ShouldAddWinRTMembers: not false } namedTypeSymbol)
{
AddWinRTMembersLookupSymbolsInfo(result, namedTypeSymbol, options, originalBinder, accessThroughType);
}
if (originalBinder.InCrefButNotParameterOrReturnType)
{
break;
}
type = type.GetNextBaseTypeNoUseSiteDiagnostics(null, Compilation, ref visited);
}
visited?.Free();
}
private void AddMemberLookupSymbolsInfoInInterface(LookupSymbolsInfo result, TypeSymbol type, LookupOptions options, Binder originalBinder, TypeSymbol accessThroughType)
{
AddMemberLookupSymbolsInfoWithoutInheritance(result, type, options, originalBinder, accessThroughType);
if (!originalBinder.InCrefButNotParameterOrReturnType)
{
ImmutableArray<NamedTypeSymbol>.Enumerator enumerator = type.AllInterfacesNoUseSiteDiagnostics.GetEnumerator();
while (enumerator.MoveNext())
{
NamedTypeSymbol current = enumerator.Current;
AddMemberLookupSymbolsInfoWithoutInheritance(result, current, options, originalBinder, accessThroughType);
}
AddMemberLookupSymbolsInfoInClass(result, Compilation.GetSpecialType((SpecialType)1), options, originalBinder, accessThroughType);
}
}
private void AddMemberLookupSymbolsInfoInTypeParameter(LookupSymbolsInfo result, TypeParameterSymbol type, LookupOptions options, Binder originalBinder)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)type.TypeParameterKind != 2)
{
NamedTypeSymbol effectiveBaseClassNoUseSiteDiagnostics = type.EffectiveBaseClassNoUseSiteDiagnostics;
AddMemberLookupSymbolsInfoInClass(result, effectiveBaseClassNoUseSiteDiagnostics, options, originalBinder, effectiveBaseClassNoUseSiteDiagnostics);
ImmutableArray<NamedTypeSymbol>.Enumerator enumerator = type.AllEffectiveInterfacesNoUseSiteDiagnostics.GetEnumerator();
while (enumerator.MoveNext())
{
NamedTypeSymbol current = enumerator.Current;
AddMemberLookupSymbolsInfoWithoutInheritance(result, current, options, originalBinder, type);
}
}
}
private bool ValidateLambdaParameterNameConflictsInScope(Location location, string name, BindingDiagnosticBag diagnostics)
{
return ValidateNameConflictsInScope(null, location, name, diagnostics);
}
internal bool ValidateDeclarationNameConflictsInScope(Symbol symbol, BindingDiagnosticBag diagnostics)
{
Location location = GetLocation(symbol);
return ValidateNameConflictsInScope(symbol, location, symbol.Name, diagnostics);
}
private static Location GetLocation(Symbol symbol)
{
return symbol.TryGetFirstLocation() ?? symbol.ContainingSymbol.GetFirstLocation();
}
internal void ValidateParameterNameConflicts(ImmutableArray<TypeParameterSymbol> typeParameters, ImmutableArray<ParameterSymbol> parameters, bool allowShadowingNames, BindingDiagnosticBag diagnostics)
{
PooledHashSet<string> val = null;
if (!typeParameters.IsDefaultOrEmpty)
{
val = PooledHashSet<string>.GetInstance();
ImmutableArray<TypeParameterSymbol>.Enumerator enumerator = typeParameters.GetEnumerator();
while (enumerator.MoveNext())
{
TypeParameterSymbol current = enumerator.Current;
string name = current.Name;
if (!string.IsNullOrEmpty(name) && ((HashSet<string>)(object)val).Add(name) && !allowShadowingNames)
{
ValidateDeclarationNameConflictsInScope(current, diagnostics);
}
}
}
PooledHashSet<string> val2 = null;
if (!parameters.IsDefaultOrEmpty)
{
val2 = PooledHashSet<string>.GetInstance();
ImmutableArray<ParameterSymbol>.Enumerator enumerator2 = parameters.GetEnumerator();
while (enumerator2.MoveNext())
{
ParameterSymbol current2 = enumerator2.Current;
string name2 = current2.Name;
if (!string.IsNullOrEmpty(name2))
{
if (val != null && ((HashSet<string>)(object)val).Contains(name2))
{
diagnostics.Add(ErrorCode.ERR_LocalSameNameAsTypeParam, GetLocation(current2), name2);
}
if (!((HashSet<string>)(object)val2).Add(name2))
{
diagnostics.Add(ErrorCode.ERR_DuplicateParamName, GetLocation(current2), name2);
}
else if (!allowShadowingNames)
{
ValidateDeclarationNameConflictsInScope(current2, diagnostics);
}
}
}
}
val?.Free();
val2?.Free();
}
private bool ValidateNameConflictsInScope(Symbol? symbol, Location location, string name, BindingDiagnosticBag diagnostics)
{
if (string.IsNullOrEmpty(name))
{
return false;
}
bool flag = Compilation.IsFeatureEnabled(MessageID.IDS_FeatureNameShadowingInNestedFunctions);
for (Binder binder = this; binder != null; binder = binder.Next)
{
if (binder is InContainerBinder)
{
return false;
}
LocalScopeBinder obj = binder as LocalScopeBinder;
if (obj != null && obj.EnsureSingleDefinition(symbol, name, location, diagnostics))
{
return true;
}
if (flag && binder.IsNestedFunctionBinder)
{
return false;
}
if (binder.IsLastBinderWithinMember())
{
return false;
}
}
return false;
}
private bool IsLastBinderWithinMember()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Invalid comparison between Unknown and I4
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Invalid comparison between Unknown and I4
Symbol containingMemberOrLambda = ContainingMemberOrLambda;
SymbolKind? val = containingMemberOrLambda?.Kind;
if (val.HasValue)
{
SymbolKind valueOrDefault = val.GetValueOrDefault();
if (valueOrDefault - 11 > 1)
{
Symbol containingSymbol = containingMemberOrLambda.ContainingSymbol;
if ((object)containingSymbol != null && (int)containingSymbol.Kind == 11)
{
return Next?.ContainingMemberOrLambda != containingMemberOrLambda;
}
return false;
}
}
return true;
}
private BoundExpression BindCompoundAssignment(AssignmentExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0478: Unknown result type (might be due to invalid IL or missing references)
node.Left.CheckDeconstructionCompatibleArgument(diagnostics);
BoundExpression boundExpression = BindValue(node.Left, diagnostics, GetBinaryAssignmentKind(node.Kind()));
ReportSuppressionIfNeeded(boundExpression, diagnostics);
BoundExpression boundExpression2 = BindValue(node.Right, diagnostics, BindValueKind.RValue);
BinaryOperatorKind binaryOperatorKind = SyntaxKindToBinaryOperatorKind(node.Kind());
if (boundExpression.Kind == BoundKind.EventAccess)
{
BinaryOperatorKind binaryOperatorKind2 = binaryOperatorKind.Operator();
if (binaryOperatorKind2 == BinaryOperatorKind.Addition || binaryOperatorKind2 == BinaryOperatorKind.Subtraction)
{
return BindEventAssignment(node, (BoundEventAccess)boundExpression, boundExpression2, binaryOperatorKind2, diagnostics);
}
}
if (boundExpression.HasAnyErrors || boundExpression2.HasAnyErrors)
{
boundExpression = BindToTypeForErrorRecovery(boundExpression);
boundExpression2 = BindToTypeForErrorRecovery(boundExpression2);
return new BoundCompoundAssignmentOperator((SyntaxNode)(object)node, BinaryOperatorSignature.Error, boundExpression, boundExpression2, null, null, null, null, LookupResultKind.Empty, CreateErrorType(), hasErrors: true);
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
if (boundExpression.HasDynamicType() || boundExpression2.HasDynamicType())
{
if (IsLegalDynamicOperand(boundExpression2) && IsLegalDynamicOperand(boundExpression) && binaryOperatorKind != BinaryOperatorKind.UnsignedRightShift)
{
boundExpression = BindToNaturalType(boundExpression, diagnostics);
boundExpression2 = BindToNaturalType(boundExpression2, diagnostics);
BoundValuePlaceholder boundValuePlaceholder = new BoundValuePlaceholder(boundExpression2.Syntax, boundExpression.HasDynamicType() ? boundExpression.Type : boundExpression2.Type).MakeCompilerGenerated();
Conversion conversion = Compilation.Conversions.ClassifyConversionFromExpression(boundValuePlaceholder, boundExpression.Type, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
BoundConversion boundConversion = (BoundConversion)CreateConversion((SyntaxNode)(object)node, boundValuePlaceholder, conversion, isCast: true, null, boundExpression.Type, diagnostics);
boundConversion = boundConversion.Update(boundConversion.Operand, boundConversion.Conversion, boundConversion.IsBaseConversion, boundConversion.Checked, explicitCastInCode: true, boundConversion.ConstantValueOpt, boundConversion.ConversionGroupOpt, boundConversion.Type);
return new BoundCompoundAssignmentOperator((SyntaxNode)(object)node, new BinaryOperatorSignature(binaryOperatorKind.WithType(BinaryOperatorKind.Dynamic).WithOverflowChecksIfApplicable(CheckOverflowAtRuntime), boundExpression.Type, boundExpression2.Type, Compilation.DynamicType), boundExpression, boundExpression2, null, null, boundValuePlaceholder, boundConversion, LookupResultKind.Viable, boundExpression.Type);
}
object[] array = new object[3];
SyntaxToken operatorToken = node.OperatorToken;
array[0] = ((SyntaxToken)(ref operatorToken)).Text;
array[1] = boundExpression.Display;
array[2] = boundExpression2.Display;
Error(diagnostics, ErrorCode.ERR_BadBinaryOps, (CSharpSyntaxNode)node, array);
boundExpression = BindToTypeForErrorRecovery(boundExpression);
boundExpression2 = BindToTypeForErrorRecovery(boundExpression2);
return new BoundCompoundAssignmentOperator((SyntaxNode)(object)node, BinaryOperatorSignature.Error, boundExpression, boundExpression2, null, null, null, null, LookupResultKind.Empty, CreateErrorType(), hasErrors: true);
}
if (boundExpression.Kind == BoundKind.EventAccess && !CheckEventValueKind((BoundEventAccess)boundExpression, BindValueKind.Assignable, diagnostics))
{
boundExpression = BindToTypeForErrorRecovery(boundExpression);
boundExpression2 = BindToTypeForErrorRecovery(boundExpression2);
return new BoundCompoundAssignmentOperator((SyntaxNode)(object)node, BinaryOperatorSignature.Error, boundExpression, boundExpression2, null, null, null, null, LookupResultKind.NotAVariable, CreateErrorType(), hasErrors: true);
}
LookupResultKind resultKind;
ImmutableArray<MethodSymbol> originalUserDefinedOperators;
BinaryOperatorAnalysisResult binaryOperatorAnalysisResult = BinaryOperatorOverloadResolution(binaryOperatorKind, CheckOverflowAtRuntime, boundExpression, boundExpression2, node, diagnostics, out resultKind, out originalUserDefinedOperators);
if (!binaryOperatorAnalysisResult.HasValue)
{
ReportAssignmentOperatorError(node, binaryOperatorKind, diagnostics, boundExpression, boundExpression2, resultKind);
boundExpression = BindToTypeForErrorRecovery(boundExpression);
boundExpression2 = BindToTypeForErrorRecovery(boundExpression2);
return new BoundCompoundAssignmentOperator((SyntaxNode)(object)node, BinaryOperatorSignature.Error, boundExpression, boundExpression2, null, null, null, null, resultKind, originalUserDefinedOperators, CreateErrorType(), hasErrors: true);
}
bool flag = false;
BinaryOperatorSignature binaryOperatorSignature = binaryOperatorAnalysisResult.Signature;
CheckNativeIntegerFeatureAvailability(binaryOperatorSignature.Kind, (SyntaxNode)(object)node, diagnostics);
CheckConstraintLanguageVersionAndRuntimeSupportForOperator((SyntaxNode)(object)node, binaryOperatorSignature.Method, binaryOperatorSignature.Kind.Operator() == BinaryOperatorKind.UnsignedRightShift, binaryOperatorSignature.ConstrainedToTypeOpt, diagnostics);
if (CheckOverflowAtRuntime)
{
binaryOperatorSignature = new BinaryOperatorSignature(binaryOperatorSignature.Kind.WithOverflowChecksIfApplicable(CheckOverflowAtRuntime), binaryOperatorSignature.LeftType, binaryOperatorSignature.RightType, binaryOperatorSignature.ReturnType, binaryOperatorSignature.Method, binaryOperatorSignature.ConstrainedToTypeOpt);
}
BoundExpression right = CreateConversion(boundExpression2, binaryOperatorAnalysisResult.RightConversion, binaryOperatorSignature.RightType, diagnostics);
bool flag2 = !binaryOperatorSignature.Kind.IsUserDefined();
TypeSymbol type = boundExpression.Type;
BoundValuePlaceholder boundValuePlaceholder2 = new BoundValuePlaceholder((SyntaxNode)(object)node, binaryOperatorSignature.ReturnType);
BoundExpression boundExpression3 = GenerateConversionForAssignment(type, boundValuePlaceholder2, diagnostics, (ConversionForAssignmentFlags)(8 | (flag2 ? 16 : 0)));
if (boundExpression3.HasErrors)
{
flag = true;
}
if (!(boundExpression3 is BoundConversion { Conversion: var conversion2 }))
{
if (boundExpression3 != boundValuePlaceholder2)
{
boundValuePlaceholder2 = null;
boundExpression3 = null;
}
}
else if (conversion2.IsExplicit && flag2 && !binaryOperatorKind.IsShift())
{
Conversion conversion3 = Conversions.ClassifyConversionFromExpression(boundExpression2, type, CheckOverflowAtRuntime, ref useSiteInfo);
if (!conversion3.IsImplicit || !conversion3.IsValid)
{
flag = true;
GenerateImplicitConversionError(diagnostics, (SyntaxNode)(object)node, conversion3, boundExpression2, type);
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
if (!flag && type.IsVoidPointer())
{
Error(diagnostics, ErrorCode.ERR_VoidError, (CSharpSyntaxNode)node);
flag = true;
}
BoundValuePlaceholder boundValuePlaceholder3 = new BoundValuePlaceholder(boundExpression.Syntax, type).MakeCompilerGenerated();
BoundExpression leftConversion = CreateConversion((SyntaxNode)(object)node, boundValuePlaceholder3, binaryOperatorAnalysisResult.LeftConversion, isCast: false, null, binaryOperatorAnalysisResult.Signature.LeftType, diagnostics);
return new BoundCompoundAssignmentOperator((SyntaxNode)(object)node, binaryOperatorSignature, boundExpression, right, boundValuePlaceholder3, leftConversion, boundValuePlaceholder2, boundExpression3, resultKind, originalUserDefinedOperators, type, flag);
}
private BoundExpression BindEventAssignment(AssignmentExpressionSyntax node, BoundEventAccess left, BoundExpression right, BinaryOperatorKind opKind, BindingDiagnosticBag diagnostics)
{
//IL_001a: 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)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
bool hasErrors = false;
EventSymbol eventSymbol = left.EventSymbol;
BoundExpression receiverOpt = left.ReceiverOpt;
TypeSymbol type = left.Type;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyConversionFromExpression(right, type, CheckOverflowAtRuntime, ref useSiteInfo);
if (!conversion.IsImplicit || !conversion.IsValid)
{
hasErrors = true;
if (type.IsDelegateType())
{
GenerateImplicitConversionError(diagnostics, (SyntaxNode)(object)node, conversion, right, type);
}
}
BoundExpression argument = CreateConversion(right, conversion, type, diagnostics);
bool flag = opKind == BinaryOperatorKind.Addition;
MethodSymbol methodSymbol = (flag ? eventSymbol.AddMethod : eventSymbol.RemoveMethod);
TypeSymbol type2;
if ((object)methodSymbol == null)
{
type2 = GetSpecialType((SpecialType)6, diagnostics, (SyntaxNode)(object)node);
if (!eventSymbol.OriginalDefinition.IsFromCompilation(Compilation))
{
Error(diagnostics, ErrorCode.ERR_MissingPredefinedMember, (CSharpSyntaxNode)node, new object[2]
{
type,
SourceEventSymbol.GetAccessorName(eventSymbol.Name, flag)
});
}
}
else
{
CheckImplicitThisCopyInReadOnlyMember(receiverOpt, methodSymbol, diagnostics);
if (!IsAccessible(methodSymbol, ref useSiteInfo, GetAccessThroughType(receiverOpt)))
{
Error(diagnostics, ErrorCode.ERR_BadAccess, (CSharpSyntaxNode)node, new object[1] { methodSymbol });
hasErrors = true;
}
else if (IsBadBaseAccess((SyntaxNode)(object)node, receiverOpt, methodSymbol, diagnostics, eventSymbol))
{
hasErrors = true;
}
else
{
CheckReceiverAndRuntimeSupportForSymbolAccess((SyntaxNode)(object)node, receiverOpt, methodSymbol, diagnostics);
}
type2 = ((!eventSymbol.IsWindowsRuntimeEvent) ? methodSymbol.ReturnType : GetSpecialType((SpecialType)6, diagnostics, (SyntaxNode)(object)node));
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
return new BoundEventAssignmentOperator((SyntaxNode)(object)node, eventSymbol, flag, right.HasDynamicType(), receiverOpt, argument, type2, hasErrors);
}
private static bool IsLegalDynamicOperand(BoundExpression operand)
{
TypeSymbol type = operand.Type;
if ((object)type == null)
{
return operand.IsLiteralNull();
}
if (!type.IsPointerOrFunctionPointer() && !type.IsRestrictedType())
{
return !type.IsVoidType();
}
return false;
}
private BoundExpression BindDynamicBinaryOperator(BinaryExpressionSyntax node, BinaryOperatorKind kind, BoundExpression left, BoundExpression right, BindingDiagnosticBag diagnostics)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
bool flag2 = IsLegalDynamicOperand(left);
bool flag3 = IsLegalDynamicOperand(right);
if (!flag2 || !flag3 || kind == BinaryOperatorKind.UnsignedRightShift)
{
object[] array = new object[3];
SyntaxToken operatorToken = node.OperatorToken;
array[0] = ((SyntaxToken)(ref operatorToken)).Text;
array[1] = left.Display;
array[2] = right.Display;
Error(diagnostics, ErrorCode.ERR_BadBinaryOps, (CSharpSyntaxNode)node, array);
flag = true;
}
MethodSymbol userDefinedOperator = null;
if (kind.IsLogical() && flag2)
{
if (!IsValidDynamicCondition(left, kind == BinaryOperatorKind.LogicalAnd, diagnostics, out userDefinedOperator))
{
Error(diagnostics, ErrorCode.ERR_InvalidDynamicCondition, (CSharpSyntaxNode)node.Left, new object[2]
{
left.Type,
(kind == BinaryOperatorKind.LogicalAnd) ? "false" : "true"
});
flag = true;
}
else
{
CheckConstraintLanguageVersionAndRuntimeSupportForOperator((SyntaxNode)(object)node, userDefinedOperator, isUnsignedRightShift: false, null, diagnostics);
}
}
return new BoundBinaryOperator((SyntaxNode)(object)node, (flag ? kind : kind.WithType(BinaryOperatorKind.Dynamic)).WithOverflowChecksIfApplicable(CheckOverflowAtRuntime), null, left: BindToNaturalType(left, diagnostics), right: BindToNaturalType(right, diagnostics), methodOpt: userDefinedOperator, constrainedToTypeOpt: null, resultKind: LookupResultKind.Viable, type: Compilation.DynamicType, hasErrors: flag);
}
protected static bool IsSimpleBinaryOperator(SyntaxKind kind)
{
switch (kind)
{
case SyntaxKind.AddExpression:
case SyntaxKind.SubtractExpression:
case SyntaxKind.MultiplyExpression:
case SyntaxKind.DivideExpression:
case SyntaxKind.ModuloExpression:
case SyntaxKind.LeftShiftExpression:
case SyntaxKind.RightShiftExpression:
case SyntaxKind.BitwiseOrExpression:
case SyntaxKind.BitwiseAndExpression:
case SyntaxKind.ExclusiveOrExpression:
case SyntaxKind.EqualsExpression:
case SyntaxKind.NotEqualsExpression:
case SyntaxKind.LessThanExpression:
case SyntaxKind.LessThanOrEqualExpression:
case SyntaxKind.GreaterThanExpression:
case SyntaxKind.GreaterThanOrEqualExpression:
case SyntaxKind.UnsignedRightShiftExpression:
return true;
default:
return false;
}
}
private BoundExpression BindSimpleBinaryOperator(BinaryExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
ArrayBuilder<BinaryExpressionSyntax> instance = ArrayBuilder<BinaryExpressionSyntax>.GetInstance();
ExpressionSyntax expressionSyntax = node;
while (IsSimpleBinaryOperator(expressionSyntax.Kind()))
{
BinaryExpressionSyntax binaryExpressionSyntax = (BinaryExpressionSyntax)expressionSyntax;
ArrayBuilderExtensions.Push<BinaryExpressionSyntax>(instance, binaryExpressionSyntax);
expressionSyntax = binaryExpressionSyntax.Left;
}
BoundExpression boundExpression = BindExpression(expressionSyntax, diagnostics);
if (((SyntaxNode?)(object)node).IsKind(SyntaxKind.SubtractExpression) && ((SyntaxNode?)(object)expressionSyntax).IsKind(SyntaxKind.ParenthesizedExpression))
{
if (boundExpression.Kind == BoundKind.TypeExpression && !((SyntaxNode?)(object)((ParenthesizedExpressionSyntax)expressionSyntax).Expression).IsKind(SyntaxKind.ParenthesizedExpression))
{
Error(diagnostics, ErrorCode.ERR_PossibleBadNegCast, (CSharpSyntaxNode)node);
}
else if (boundExpression.Kind == BoundKind.BadExpression)
{
ParenthesizedExpressionSyntax parenthesizedExpressionSyntax = (ParenthesizedExpressionSyntax)expressionSyntax;
if (((SyntaxNode?)(object)parenthesizedExpressionSyntax.Expression).IsKind(SyntaxKind.IdentifierName))
{
SyntaxToken identifier = ((IdentifierNameSyntax)parenthesizedExpressionSyntax.Expression).Identifier;
if (((SyntaxToken)(ref identifier)).ValueText == "dynamic")
{
Error(diagnostics, ErrorCode.ERR_PossibleBadNegCast, (CSharpSyntaxNode)node);
}
}
}
}
while (instance.Count > 0)
{
BinaryExpressionSyntax binaryExpressionSyntax2 = ArrayBuilderExtensions.Pop<BinaryExpressionSyntax>(instance);
BindValueKind binaryAssignmentKind = GetBinaryAssignmentKind(binaryExpressionSyntax2.Kind());
BoundExpression left = CheckValue(boundExpression, binaryAssignmentKind, diagnostics);
BoundExpression right = BindValue(binaryExpressionSyntax2.Right, diagnostics, BindValueKind.RValue);
boundExpression = BindSimpleBinaryOperator(binaryExpressionSyntax2, diagnostics, left, right, leaveUnconvertedIfInterpolatedString: true);
}
instance.Free();
return boundExpression;
}
private BoundExpression BindSimpleBinaryOperator(BinaryExpressionSyntax node, BindingDiagnosticBag diagnostics, BoundExpression left, BoundExpression right, bool leaveUnconvertedIfInterpolatedString)
{
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Invalid comparison between Unknown and I4
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Invalid comparison between Unknown and I4
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
BinaryOperatorKind binaryOperatorKind = SyntaxKindToBinaryOperatorKind(node.Kind());
if (left.HasAnyErrors || right.HasAnyErrors)
{
left = BindToTypeForErrorRecovery(left);
right = BindToTypeForErrorRecovery(right);
return new BoundBinaryOperator((SyntaxNode)(object)node, binaryOperatorKind, null, null, null, LookupResultKind.Empty, left, right, GetBinaryOperatorErrorType(binaryOperatorKind, diagnostics, node), hasErrors: true);
}
TypeSymbol type = left.Type;
TypeSymbol type2 = right.Type;
if (((object)type != null && type.IsDynamic()) || ((object)type2 != null && type2.IsDynamic()))
{
return BindDynamicBinaryOperator(node, binaryOperatorKind, left, right, diagnostics);
}
bool flag = left.IsLiteralNull();
bool flag2 = right.IsLiteralNull();
if ((binaryOperatorKind == BinaryOperatorKind.Equal || binaryOperatorKind == BinaryOperatorKind.NotEqual) && flag && flag2)
{
return new BoundLiteral((SyntaxNode)(object)node, ConstantValue.Create(binaryOperatorKind == BinaryOperatorKind.Equal), GetSpecialType((SpecialType)7, diagnostics, (SyntaxNode)(object)node));
}
if (IsTupleBinaryOperation(left, right) && (binaryOperatorKind == BinaryOperatorKind.Equal || binaryOperatorKind == BinaryOperatorKind.NotEqual))
{
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureTupleEquality, diagnostics);
return BindTupleBinaryOperator(node, binaryOperatorKind, left, right, diagnostics);
}
bool flag3 = leaveUnconvertedIfInterpolatedString && binaryOperatorKind == BinaryOperatorKind.Addition;
if (flag3)
{
bool flag4 = ((left is BoundUnconvertedInterpolatedString || left is BoundBinaryOperator { IsUnconvertedInterpolatedStringAddition: not false }) ? true : false);
flag3 = flag4;
}
bool flag5 = flag3;
if (flag5)
{
bool flag4 = ((right is BoundUnconvertedInterpolatedString || right is BoundBinaryOperator { IsUnconvertedInterpolatedStringAddition: not false }) ? true : false);
flag5 = flag4;
}
if (flag5)
{
ConstantValue constantValue = FoldBinaryOperator(node, BinaryOperatorKind.StringConcatenation, left, right, right.Type, diagnostics);
return new BoundBinaryOperator((SyntaxNode)(object)node, BinaryOperatorKind.StringConcatenation, BoundBinaryOperator.UncommonData.UnconvertedInterpolatedStringAddition(constantValue), LookupResultKind.Empty, left, right, right.Type);
}
LookupResultKind resultKind;
ImmutableArray<MethodSymbol> originalUserDefinedOperators;
BinaryOperatorSignature resultSignature;
BinaryOperatorAnalysisResult best;
bool flag6 = BindSimpleBinaryOperatorParts(node, diagnostics, left, right, binaryOperatorKind, out resultKind, out originalUserDefinedOperators, out resultSignature, out best);
BinaryOperatorKind binaryOperatorKind2 = resultSignature.Kind;
bool flag7 = false;
if (!flag6)
{
ReportBinaryOperatorError(node, diagnostics, node.OperatorToken, left, right, resultKind);
binaryOperatorKind2 &= ~BinaryOperatorKind.TypeMask;
flag7 = true;
}
SyntaxKind syntaxKind = node.Kind();
if (syntaxKind - 8680 <= (SyntaxKind)5)
{
if ((binaryOperatorKind2 & BinaryOperatorKind.Pointer) == BinaryOperatorKind.Pointer && (object)type != null && (int)type.TypeKind == 13 && (object)type2 != null && (int)type2.TypeKind == 13)
{
Error(diagnostics, ErrorCode.WRN_DoNotCompareFunctionPointers, node.OperatorToken);
}
}
else if (type.IsVoidPointer() || type2.IsVoidPointer())
{
Error(diagnostics, ErrorCode.ERR_VoidError, (CSharpSyntaxNode)node);
flag7 = true;
}
if (flag6)
{
CheckNativeIntegerFeatureAvailability(binaryOperatorKind2, (SyntaxNode)(object)node, diagnostics);
CheckConstraintLanguageVersionAndRuntimeSupportForOperator((SyntaxNode)(object)node, resultSignature.Method, binaryOperatorKind2.Operator() == BinaryOperatorKind.UnsignedRightShift, resultSignature.ConstrainedToTypeOpt, diagnostics);
}
TypeSymbol returnType = resultSignature.ReturnType;
BoundExpression expression = left;
BoundExpression expression2 = right;
ConstantValue val = null;
if (flag6 && binaryOperatorKind2.OperandTypes() != BinaryOperatorKind.NullableNull)
{
expression = CreateConversion(left, best.LeftConversion, resultSignature.LeftType, diagnostics);
expression2 = CreateConversion(right, best.RightConversion, resultSignature.RightType, diagnostics);
val = FoldBinaryOperator(node, binaryOperatorKind2, expression, expression2, returnType, diagnostics);
}
else
{
expression = BindToNaturalType(expression, diagnostics, reportNoTargetType: false);
expression2 = BindToNaturalType(expression2, diagnostics, reportNoTargetType: false);
}
flag7 = flag7 || (val != (ConstantValue)null && val.IsBad);
return new BoundBinaryOperator((SyntaxNode)(object)node, binaryOperatorKind2.WithOverflowChecksIfApplicable(CheckOverflowAtRuntime), expression, expression2, val, resultSignature.Method, resultSignature.ConstrainedToTypeOpt, resultKind, originalUserDefinedOperators, returnType, flag7);
}
private bool BindSimpleBinaryOperatorParts(BinaryExpressionSyntax node, BindingDiagnosticBag diagnostics, BoundExpression left, BoundExpression right, BinaryOperatorKind kind, out LookupResultKind resultKind, out ImmutableArray<MethodSymbol> originalUserDefinedOperators, out BinaryOperatorSignature resultSignature, out BinaryOperatorAnalysisResult best)
{
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
best = BinaryOperatorOverloadResolution(kind, CheckOverflowAtRuntime, left, right, node, diagnostics, out resultKind, out originalUserDefinedOperators);
bool result;
if (!best.HasValue)
{
resultSignature = new BinaryOperatorSignature(kind, null, null, CreateErrorType());
result = false;
}
else
{
BinaryOperatorSignature signature = best.Signature;
bool flag = signature.Kind == BinaryOperatorKind.ObjectEqual || signature.Kind == BinaryOperatorKind.ObjectNotEqual;
bool flag2 = left.IsLiteralNull();
bool flag3 = right.IsLiteralNull();
TypeSymbol type = left.Type;
TypeSymbol type2 = right.Type;
if ((object)signature.Method == null && (signature.Kind.Operator() == BinaryOperatorKind.Equal || signature.Kind.Operator() == BinaryOperatorKind.NotEqual) && ((flag2 && (object)type2 != null && type2.IsNullableType()) || (flag3 && (object)type != null && type.IsNullableType())))
{
resultSignature = new BinaryOperatorSignature(kind | BinaryOperatorKind.NullableNull, null, null, GetSpecialType((SpecialType)7, diagnostics, (SyntaxNode)(object)node));
result = true;
}
else
{
resultSignature = signature;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
bool leftIsDefault = left.IsLiteralDefault();
bool rightIsDefault = right.IsLiteralDefault();
result = !flag || BuiltInOperators.IsValidObjectEquality(Conversions, type, flag2, leftIsDefault, type2, flag3, rightIsDefault, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
}
}
return result;
}
private BoundExpression RebindSimpleBinaryOperatorAsConverted(BoundBinaryOperator unconvertedBinaryOperator, BindingDiagnosticBag diagnostics)
{
if (TryBindUnconvertedBinaryOperatorToDefaultInterpolatedStringHandler(unconvertedBinaryOperator, diagnostics, out BoundBinaryOperator convertedBinaryOperator))
{
return convertedBinaryOperator;
}
return doRebind(diagnostics, unconvertedBinaryOperator);
BoundExpression doRebind(BindingDiagnosticBag diagnostics2, BoundBinaryOperator? current)
{
ArrayBuilder<BoundBinaryOperator> instance = ArrayBuilder<BoundBinaryOperator>.GetInstance();
while (current != null)
{
ArrayBuilderExtensions.Push<BoundBinaryOperator>(instance, current);
current = current.Left as BoundBinaryOperator;
}
BoundExpression boundExpression = null;
while (ArrayBuilderExtensions.TryPop<BoundBinaryOperator>(instance, ref current))
{
BoundExpression right = current.Right;
BoundExpression boundExpression2;
if (!(right is BoundUnconvertedInterpolatedString boundUnconvertedInterpolatedString))
{
if (!(right is BoundBinaryOperator current2))
{
throw ExceptionUtilities.UnexpectedValue((object)current.Right.Kind);
}
boundExpression2 = doRebind(diagnostics2, current2);
}
else
{
boundExpression2 = boundUnconvertedInterpolatedString;
}
BoundExpression right2 = boundExpression2;
boundExpression = BindSimpleBinaryOperator((BinaryExpressionSyntax)(object)current.Syntax, diagnostics2, boundExpression ?? current.Left, right2, leaveUnconvertedIfInterpolatedString: false);
}
instance.Free();
return boundExpression;
}
}
private static void ReportUnaryOperatorError(CSharpSyntaxNode node, BindingDiagnosticBag diagnostics, string operatorName, BoundExpression operand, LookupResultKind resultKind)
{
if (!operand.IsLiteralDefault())
{
ErrorCode code = ((resultKind == LookupResultKind.Ambiguous) ? ErrorCode.ERR_AmbigUnaryOp : ErrorCode.ERR_BadUnaryOp);
Error(diagnostics, code, node, operatorName, operand.Display);
}
}
private void ReportAssignmentOperatorError(AssignmentExpressionSyntax node, BinaryOperatorKind kind, BindingDiagnosticBag diagnostics, BoundExpression left, BoundExpression right, LookupResultKind resultKind)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Invalid comparison between Unknown and I4
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
bool flag = IsTypelessExpressionAllowedInBinaryOperator(kind, left, right);
if (flag)
{
SyntaxToken operatorToken = node.OperatorToken;
int rawKind = ((SyntaxToken)(ref operatorToken)).RawKind;
bool flag2 = (uint)(rawKind - 8280) <= 1u;
flag = flag2;
}
if (flag && (object)left.Type != null && (int)left.Type.TypeKind == 3)
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
Conversion conversion = Conversions.ClassifyConversionFromExpression(right, left.Type, CheckOverflowAtRuntime, ref useSiteInfo);
GenerateImplicitConversionError(diagnostics, right.Syntax, conversion, right, left.Type);
}
else
{
ReportBinaryOperatorError(node, diagnostics, node.OperatorToken, left, right, resultKind);
}
}
private void ReportBinaryOperatorError(ExpressionSyntax node, BindingDiagnosticBag diagnostics, SyntaxToken operatorToken, BoundExpression left, BoundExpression right, LookupResultKind resultKind)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
bool flag = operatorToken.Kind() == SyntaxKind.EqualsEqualsToken || operatorToken.Kind() == SyntaxKind.ExclamationEqualsToken;
BoundKind kind = left.Kind;
BoundKind kind2 = right.Kind;
int num;
if (kind != BoundKind.DefaultLiteral)
{
if (kind2 != BoundKind.DefaultLiteral)
{
if (kind != BoundKind.UnconvertedObjectCreationExpression)
{
goto IL_0064;
}
goto IL_0154;
}
num = 3;
}
else
{
if (!flag)
{
goto IL_008e;
}
if (kind2 != BoundKind.DefaultLiteral)
{
if (right.Type is TypeParameterSymbol)
{
Error(diagnostics, ErrorCode.ERR_AmbigBinaryOpsOnUnconstrainedDefault, (CSharpSyntaxNode)node, new object[2]
{
((SyntaxToken)(ref operatorToken)).Text,
right.Type
});
return;
}
goto IL_0064;
}
num = 1;
}
if (flag)
{
if (num == 1)
{
Error(diagnostics, ErrorCode.ERR_AmbigBinaryOpsOnDefault, (CSharpSyntaxNode)node, new object[3]
{
((SyntaxToken)(ref operatorToken)).Text,
left.Display,
right.Display
});
return;
}
if (num == 3)
{
if (!(left.Type is TypeParameterSymbol))
{
if (kind == BoundKind.UnconvertedObjectCreationExpression)
{
goto IL_0154;
}
goto IL_01a2;
}
Error(diagnostics, ErrorCode.ERR_AmbigBinaryOpsOnUnconstrainedDefault, (CSharpSyntaxNode)node, new object[2]
{
((SyntaxToken)(ref operatorToken)).Text,
left.Type
});
return;
}
}
goto IL_008e;
IL_0064:
if (kind2 != BoundKind.UnconvertedObjectCreationExpression)
{
goto IL_01a2;
}
Error(diagnostics, ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, (CSharpSyntaxNode)node, new object[2]
{
((SyntaxToken)(ref operatorToken)).Text,
right.Display
});
return;
IL_008e:
Error(diagnostics, ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, (CSharpSyntaxNode)node, new object[2]
{
((SyntaxToken)(ref operatorToken)).Text,
"default"
});
return;
IL_01ea:
ErrorCode code = ErrorCode.ERR_BadBinaryOps;
goto IL_01ed;
IL_0154:
Error(diagnostics, ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, (CSharpSyntaxNode)node, new object[2]
{
((SyntaxToken)(ref operatorToken)).Text,
left.Display
});
return;
IL_01a2:
LookupResultKind lookupResultKind = resultKind;
if (lookupResultKind != LookupResultKind.OverloadResolutionFailure)
{
if (lookupResultKind != LookupResultKind.Ambiguous)
{
goto IL_01ea;
}
code = ErrorCode.ERR_AmbigBinaryOps;
}
else
{
if (operatorToken.Kind() != SyntaxKind.PlusToken || !isReadOnlySpanOfByte(left.Type) || !isReadOnlySpanOfByte(right.Type))
{
goto IL_01ea;
}
code = ErrorCode.ERR_BadBinaryReadOnlySpanConcatenation;
}
goto IL_01ed;
IL_01ed:
Error(diagnostics, code, (CSharpSyntaxNode)node, new object[3]
{
((SyntaxToken)(ref operatorToken)).Text,
left.Display,
right.Display
});
bool isReadOnlySpanOfByte(TypeSymbol? type)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Invalid comparison between Unknown and I4
if (type is NamedTypeSymbol namedTypeSymbol && Compilation.IsReadOnlySpanType(namedTypeSymbol))
{
return (int)namedTypeSymbol.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics.Single().Type.SpecialType == 10;
}
return false;
}
}
private BoundExpression BindConditionalLogicalOperator(BinaryExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
BinaryExpressionSyntax binaryExpressionSyntax = node;
ExpressionSyntax expressionSyntax;
while (true)
{
expressionSyntax = binaryExpressionSyntax.Left;
if (!(expressionSyntax is BinaryExpressionSyntax binaryExpressionSyntax2) || (binaryExpressionSyntax2.Kind() != SyntaxKind.LogicalOrExpression && binaryExpressionSyntax2.Kind() != SyntaxKind.LogicalAndExpression))
{
break;
}
binaryExpressionSyntax = binaryExpressionSyntax2;
}
BoundExpression boundExpression = BindRValueWithoutTargetType(expressionSyntax, diagnostics);
do
{
binaryExpressionSyntax = (BinaryExpressionSyntax)expressionSyntax.Parent;
BoundExpression right = BindRValueWithoutTargetType(binaryExpressionSyntax.Right, diagnostics);
boundExpression = BindConditionalLogicalOperator(binaryExpressionSyntax, boundExpression, right, diagnostics);
expressionSyntax = binaryExpressionSyntax;
}
while (expressionSyntax != node);
return boundExpression;
}
private BoundExpression BindConditionalLogicalOperator(BinaryExpressionSyntax node, BoundExpression left, BoundExpression right, BindingDiagnosticBag diagnostics)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Invalid comparison between Unknown and I4
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Invalid comparison between Unknown and I4
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Invalid comparison between Unknown and I4
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
BinaryOperatorKind binaryOperatorKind = SyntaxKindToBinaryOperatorKind(node.Kind());
if ((object)left.Type != null && (int)left.Type.SpecialType == 7 && (object)right.Type != null && (int)right.Type.SpecialType == 7)
{
ConstantValue val = FoldBinaryOperator(node, binaryOperatorKind | BinaryOperatorKind.Bool, left, right, left.Type, diagnostics);
return new BoundBinaryOperator((SyntaxNode)(object)node, binaryOperatorKind | BinaryOperatorKind.Bool, val, null, null, LookupResultKind.Viable, left, right, left.Type, val != (ConstantValue)null && val.IsBad);
}
if (left.HasAnyErrors || right.HasAnyErrors)
{
return new BoundBinaryOperator((SyntaxNode)(object)node, binaryOperatorKind, null, null, null, LookupResultKind.Empty, left, right, GetBinaryOperatorErrorType(binaryOperatorKind, diagnostics, node), hasErrors: true);
}
if (left.HasDynamicType() || right.HasDynamicType())
{
left = BindToNaturalType(left, diagnostics);
right = BindToNaturalType(right, diagnostics);
return BindDynamicBinaryOperator(node, binaryOperatorKind, left, right, diagnostics);
}
LookupResultKind resultKind;
ImmutableArray<MethodSymbol> originalUserDefinedOperators;
BinaryOperatorAnalysisResult binaryOperatorAnalysisResult = BinaryOperatorOverloadResolution(binaryOperatorKind, CheckOverflowAtRuntime, left, right, node, diagnostics, out resultKind, out originalUserDefinedOperators);
if (!binaryOperatorAnalysisResult.HasValue)
{
ReportBinaryOperatorError(node, diagnostics, node.OperatorToken, left, right, resultKind);
}
else
{
BinaryOperatorSignature signature = binaryOperatorAnalysisResult.Signature;
bool flag = (int)signature.LeftType.SpecialType == 7 && (int)signature.RightType.SpecialType == 7;
MethodSymbol trueOperator = null;
MethodSymbol falseOperator = null;
if (!flag && !signature.Kind.IsUserDefined())
{
ReportBinaryOperatorError(node, diagnostics, node.OperatorToken, left, right, resultKind);
}
else if (flag || IsValidUserDefinedConditionalLogicalOperator(node, signature, diagnostics, out trueOperator, out falseOperator))
{
BoundExpression left2 = CreateConversion(left, binaryOperatorAnalysisResult.LeftConversion, signature.LeftType, diagnostics);
BoundExpression right2 = CreateConversion(right, binaryOperatorAnalysisResult.RightConversion, signature.RightType, diagnostics);
BinaryOperatorKind binaryOperatorKind2 = binaryOperatorKind | signature.Kind.OperandTypes();
if (signature.Kind.IsLifted())
{
binaryOperatorKind2 |= BinaryOperatorKind.Lifted;
}
if (binaryOperatorKind2.IsUserDefined())
{
if (CheckConstraintLanguageVersionAndRuntimeSupportForOperator((SyntaxNode)(object)node, signature.Method, isUnsignedRightShift: false, signature.ConstrainedToTypeOpt, diagnostics))
{
CheckConstraintLanguageVersionAndRuntimeSupportForOperator((SyntaxNode)(object)node, (binaryOperatorKind == BinaryOperatorKind.LogicalAnd) ? falseOperator : trueOperator, isUnsignedRightShift: false, signature.ConstrainedToTypeOpt, diagnostics);
}
else
_ = 0;
return new BoundUserDefinedConditionalLogicalOperator((SyntaxNode)(object)node, binaryOperatorKind2, left2, right2, signature.Method, trueOperator, falseOperator, signature.ConstrainedToTypeOpt, resultKind, originalUserDefinedOperators, signature.ReturnType);
}
return new BoundBinaryOperator((SyntaxNode)(object)node, binaryOperatorKind2, left2, right2, null, signature.Method, signature.ConstrainedToTypeOpt, resultKind, originalUserDefinedOperators, signature.ReturnType);
}
}
return new BoundBinaryOperator((SyntaxNode)(object)node, binaryOperatorKind, left, right, null, null, null, resultKind, originalUserDefinedOperators, CreateErrorType(), hasErrors: true);
}
private bool IsValidDynamicCondition(BoundExpression left, bool isNegative, BindingDiagnosticBag diagnostics, out MethodSymbol userDefinedOperator)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Invalid comparison between Unknown and I4
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
userDefinedOperator = null;
TypeSymbol type = left.Type;
if ((object)type == null)
{
return false;
}
if (type.IsDynamic())
{
return true;
}
NamedTypeSymbol specialType = Compilation.GetSpecialType((SpecialType)7);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyImplicitConversionFromExpression(left, specialType, ref useSiteInfo);
if (conversion.Exists)
{
if ((object)left.Type != null)
{
BoundValuePlaceholder source = new BoundValuePlaceholder(left.Syntax, left.Type).MakeCompilerGenerated();
CreateConversion(left.Syntax, source, conversion, isCast: false, null, specialType, diagnostics);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(left.Syntax, useSiteInfo);
return true;
}
if ((int)type.Kind != 11)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(left.Syntax, useSiteInfo);
return false;
}
NamedTypeSymbol containingType = type as NamedTypeSymbol;
bool result = HasApplicableBooleanOperator(containingType, isNegative ? "op_False" : "op_True", type, ref useSiteInfo, out userDefinedOperator);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(left.Syntax, useSiteInfo);
return result;
}
private bool IsValidUserDefinedConditionalLogicalOperator(CSharpSyntaxNode syntax, BinaryOperatorSignature signature, BindingDiagnosticBag diagnostics, out MethodSymbol trueOperator, out MethodSymbol falseOperator)
{
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol containingType = signature.Method.ContainingType;
bool num = TypeSymbol.Equals(signature.LeftType, signature.RightType, (TypeCompareKind)0) && TypeSymbol.Equals(signature.LeftType, signature.ReturnType, (TypeCompareKind)0);
MethodSymbol originalDefinition;
bool flag = TypeSymbol.Equals(signature.ReturnType.StrippedType(), containingType, (TypeCompareKind)0) || (containingType.IsInterface && (signature.Method.IsAbstract || signature.Method.IsVirtual) && SourceUserDefinedOperatorSymbolBase.IsSelfConstrainedTypeParameter((originalDefinition = signature.Method.OriginalDefinition).ReturnType.StrippedType(), originalDefinition.ContainingType));
if (!num || !flag)
{
Error(diagnostics, ErrorCode.ERR_BadBoolOp, syntax, signature.Method);
trueOperator = null;
falseOperator = null;
return false;
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
if (!HasApplicableBooleanOperator(containingType, "op_True", signature.LeftType, ref useSiteInfo, out trueOperator) || !HasApplicableBooleanOperator(containingType, "op_False", signature.LeftType, ref useSiteInfo, out falseOperator))
{
Error(diagnostics, ErrorCode.ERR_MustHaveOpTF, syntax, signature.Method, containingType);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)syntax, useSiteInfo);
trueOperator = null;
falseOperator = null;
return false;
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)syntax, useSiteInfo);
return true;
}
private bool HasApplicableBooleanOperator(NamedTypeSymbol containingType, string name, TypeSymbol argumentType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out MethodSymbol @operator)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Invalid comparison between Unknown and I4
NamedTypeSymbol namedTypeSymbol = containingType;
while ((object)namedTypeSymbol != null)
{
ImmutableArray<MethodSymbol> operators = namedTypeSymbol.GetOperators(name);
for (int i = 0; i < operators.Length; i++)
{
MethodSymbol methodSymbol = operators[i];
if (methodSymbol.ParameterCount == 1 && (int)methodSymbol.DeclaredAccessibility == 6 && Conversions.ClassifyConversionFromType(argumentType, methodSymbol.GetParameterType(0), CheckOverflowAtRuntime, ref useSiteInfo).IsImplicit)
{
@operator = methodSymbol;
return true;
}
}
namedTypeSymbol = namedTypeSymbol.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteInfo);
}
@operator = null;
return false;
}
private TypeSymbol GetBinaryOperatorErrorType(BinaryOperatorKind kind, BindingDiagnosticBag diagnostics, CSharpSyntaxNode node)
{
switch (kind)
{
case BinaryOperatorKind.Equal:
case BinaryOperatorKind.NotEqual:
case BinaryOperatorKind.GreaterThan:
case BinaryOperatorKind.LessThan:
case BinaryOperatorKind.GreaterThanOrEqual:
case BinaryOperatorKind.LessThanOrEqual:
return GetSpecialType((SpecialType)7, diagnostics, (SyntaxNode)(object)node);
default:
return CreateErrorType();
}
}
private BinaryOperatorAnalysisResult BinaryOperatorOverloadResolution(BinaryOperatorKind kind, bool isChecked, BoundExpression left, BoundExpression right, CSharpSyntaxNode node, BindingDiagnosticBag diagnostics, out LookupResultKind resultKind, out ImmutableArray<MethodSymbol> originalUserDefinedOperators)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
if (!IsTypelessExpressionAllowedInBinaryOperator(kind, left, right))
{
resultKind = LookupResultKind.OverloadResolutionFailure;
originalUserDefinedOperators = default(ImmutableArray<MethodSymbol>);
return default(BinaryOperatorAnalysisResult);
}
BinaryOperatorOverloadResolutionResult instance = BinaryOperatorOverloadResolutionResult.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
OverloadResolution.BinaryOperatorOverloadResolution(kind, isChecked, left, right, instance, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
BinaryOperatorAnalysisResult best = instance.Best;
if (instance.Results.Any())
{
ArrayBuilder<MethodSymbol> instance2 = ArrayBuilder<MethodSymbol>.GetInstance();
Enumerator<BinaryOperatorAnalysisResult> enumerator = instance.Results.GetEnumerator();
while (enumerator.MoveNext())
{
MethodSymbol method = enumerator.Current.Signature.Method;
if ((object)method != null)
{
instance2.Add(method);
}
}
originalUserDefinedOperators = instance2.ToImmutableAndFree();
if (best.HasValue)
{
resultKind = LookupResultKind.Viable;
}
else if (instance.AnyValid())
{
resultKind = LookupResultKind.Ambiguous;
}
else
{
resultKind = LookupResultKind.OverloadResolutionFailure;
}
}
else
{
originalUserDefinedOperators = ImmutableArray<MethodSymbol>.Empty;
resultKind = (best.HasValue ? LookupResultKind.Viable : LookupResultKind.Empty);
}
if (best.HasValue)
{
MethodSymbol method2 = best.Signature.Method;
if ((object)method2 != null)
{
ReportObsoleteAndFeatureAvailabilityDiagnostics(method2, node, diagnostics);
ReportUseSite(method2, diagnostics, (SyntaxNode)(object)node);
}
}
instance.Free();
return best;
}
private void ReportObsoleteAndFeatureAvailabilityDiagnostics(MethodSymbol operatorMethod, CSharpSyntaxNode node, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if ((object)operatorMethod != null)
{
ReportDiagnosticsIfObsolete(diagnostics, operatorMethod, SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)node), hasBaseReceiver: false);
if (operatorMethod.ContainingType.IsInterface && operatorMethod.ContainingModule != Compilation.SourceModule)
{
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_DefaultInterfaceImplementation, diagnostics);
}
}
}
private bool IsTypelessExpressionAllowedInBinaryOperator(BinaryOperatorKind kind, BoundExpression left, BoundExpression right)
{
if (left.IsImplicitObjectCreation() || right.IsImplicitObjectCreation())
{
return false;
}
if (kind == BinaryOperatorKind.Equal || kind == BinaryOperatorKind.NotEqual)
{
if (left.IsLiteralDefault())
{
return !right.IsLiteralDefault();
}
return true;
}
if (!left.IsLiteralDefault())
{
return !right.IsLiteralDefault();
}
return false;
}
private UnaryOperatorAnalysisResult UnaryOperatorOverloadResolution(UnaryOperatorKind kind, BoundExpression operand, CSharpSyntaxNode node, BindingDiagnosticBag diagnostics, out LookupResultKind resultKind, out ImmutableArray<MethodSymbol> originalUserDefinedOperators)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Invalid comparison between Unknown and I4
UnaryOperatorOverloadResolutionResult instance = UnaryOperatorOverloadResolutionResult.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
OverloadResolution.UnaryOperatorOverloadResolution(kind, CheckOverflowAtRuntime, operand, instance, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
UnaryOperatorAnalysisResult best = instance.Best;
if (instance.Results.Any())
{
ArrayBuilder<MethodSymbol> instance2 = ArrayBuilder<MethodSymbol>.GetInstance();
Enumerator<UnaryOperatorAnalysisResult> enumerator = instance.Results.GetEnumerator();
while (enumerator.MoveNext())
{
MethodSymbol method = enumerator.Current.Signature.Method;
if ((object)method != null)
{
instance2.Add(method);
}
}
originalUserDefinedOperators = instance2.ToImmutableAndFree();
if (best.HasValue)
{
resultKind = LookupResultKind.Viable;
}
else if (instance.AnyValid())
{
if (kind == UnaryOperatorKind.UnaryMinus && (object)operand.Type != null && ((int)operand.Type.SpecialType == 16 || isNuint(operand.Type)))
{
resultKind = LookupResultKind.OverloadResolutionFailure;
}
else
{
resultKind = LookupResultKind.Ambiguous;
}
}
else
{
resultKind = LookupResultKind.OverloadResolutionFailure;
}
}
else
{
originalUserDefinedOperators = ImmutableArray<MethodSymbol>.Empty;
resultKind = (best.HasValue ? LookupResultKind.Viable : LookupResultKind.Empty);
}
if (best.HasValue)
{
MethodSymbol method2 = best.Signature.Method;
if ((object)method2 != null)
{
ReportObsoleteAndFeatureAvailabilityDiagnostics(method2, node, diagnostics);
ReportUseSite(method2, diagnostics, (SyntaxNode)(object)node);
}
}
instance.Free();
return best;
static bool isNuint(TypeSymbol type)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
if ((int)type.SpecialType == 22)
{
return type.IsNativeIntegerType;
}
return false;
}
}
private static object FoldDecimalBinaryOperators(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
{
return kind switch
{
BinaryOperatorKind.DecimalAddition => valueLeft.DecimalValue + valueRight.DecimalValue,
BinaryOperatorKind.DecimalSubtraction => valueLeft.DecimalValue - valueRight.DecimalValue,
BinaryOperatorKind.DecimalMultiplication => valueLeft.DecimalValue * valueRight.DecimalValue,
BinaryOperatorKind.DecimalDivision => valueLeft.DecimalValue / valueRight.DecimalValue,
BinaryOperatorKind.DecimalRemainder => valueLeft.DecimalValue % valueRight.DecimalValue,
_ => null,
};
}
private static object FoldNativeIntegerOverflowingBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
{
checked
{
switch (kind)
{
case BinaryOperatorKind.NIntAddition:
return valueLeft.Int32Value + valueRight.Int32Value;
case BinaryOperatorKind.NUIntAddition:
return valueLeft.UInt32Value + valueRight.UInt32Value;
case BinaryOperatorKind.NIntSubtraction:
return valueLeft.Int32Value - valueRight.Int32Value;
case BinaryOperatorKind.NUIntSubtraction:
return valueLeft.UInt32Value - valueRight.UInt32Value;
case BinaryOperatorKind.NIntMultiplication:
return valueLeft.Int32Value * valueRight.Int32Value;
case BinaryOperatorKind.NUIntMultiplication:
return valueLeft.UInt32Value * valueRight.UInt32Value;
case BinaryOperatorKind.NIntDivision:
return unchecked(valueLeft.Int32Value / valueRight.Int32Value);
case BinaryOperatorKind.NIntRemainder:
return unchecked(valueLeft.Int32Value % valueRight.Int32Value);
case BinaryOperatorKind.NIntLeftShift:
{
int num3 = valueLeft.Int32Value << valueRight.Int32Value;
long num4 = valueLeft.Int64Value << valueRight.Int32Value;
if (num3 != num4)
{
return null;
}
return num3;
}
case BinaryOperatorKind.NUIntLeftShift:
{
uint num = valueLeft.UInt32Value << valueRight.Int32Value;
ulong num2 = valueLeft.UInt64Value << valueRight.Int32Value;
if (num != num2)
{
return null;
}
return num;
}
default:
return null;
}
}
}
private static object FoldUncheckedIntegralBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
{
switch (kind)
{
case BinaryOperatorKind.IntAddition:
return valueLeft.Int32Value + valueRight.Int32Value;
case BinaryOperatorKind.LongAddition:
return valueLeft.Int64Value + valueRight.Int64Value;
case BinaryOperatorKind.UIntAddition:
return valueLeft.UInt32Value + valueRight.UInt32Value;
case BinaryOperatorKind.ULongAddition:
return valueLeft.UInt64Value + valueRight.UInt64Value;
case BinaryOperatorKind.IntSubtraction:
return valueLeft.Int32Value - valueRight.Int32Value;
case BinaryOperatorKind.LongSubtraction:
return valueLeft.Int64Value - valueRight.Int64Value;
case BinaryOperatorKind.UIntSubtraction:
return valueLeft.UInt32Value - valueRight.UInt32Value;
case BinaryOperatorKind.ULongSubtraction:
return valueLeft.UInt64Value - valueRight.UInt64Value;
case BinaryOperatorKind.IntMultiplication:
return valueLeft.Int32Value * valueRight.Int32Value;
case BinaryOperatorKind.LongMultiplication:
return valueLeft.Int64Value * valueRight.Int64Value;
case BinaryOperatorKind.UIntMultiplication:
return valueLeft.UInt32Value * valueRight.UInt32Value;
case BinaryOperatorKind.ULongMultiplication:
return valueLeft.UInt64Value * valueRight.UInt64Value;
case BinaryOperatorKind.IntDivision:
if (valueLeft.Int32Value == int.MinValue && valueRight.Int32Value == -1)
{
return int.MinValue;
}
return valueLeft.Int32Value / valueRight.Int32Value;
case BinaryOperatorKind.LongDivision:
if (valueLeft.Int64Value == long.MinValue && valueRight.Int64Value == -1)
{
return long.MinValue;
}
return valueLeft.Int64Value / valueRight.Int64Value;
default:
return null;
}
}
private static object FoldCheckedIntegralBinaryOperator(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
{
checked
{
return kind switch
{
BinaryOperatorKind.IntAddition => valueLeft.Int32Value + valueRight.Int32Value,
BinaryOperatorKind.LongAddition => valueLeft.Int64Value + valueRight.Int64Value,
BinaryOperatorKind.UIntAddition => valueLeft.UInt32Value + valueRight.UInt32Value,
BinaryOperatorKind.ULongAddition => valueLeft.UInt64Value + valueRight.UInt64Value,
BinaryOperatorKind.IntSubtraction => valueLeft.Int32Value - valueRight.Int32Value,
BinaryOperatorKind.LongSubtraction => valueLeft.Int64Value - valueRight.Int64Value,
BinaryOperatorKind.UIntSubtraction => valueLeft.UInt32Value - valueRight.UInt32Value,
BinaryOperatorKind.ULongSubtraction => valueLeft.UInt64Value - valueRight.UInt64Value,
BinaryOperatorKind.IntMultiplication => valueLeft.Int32Value * valueRight.Int32Value,
BinaryOperatorKind.LongMultiplication => valueLeft.Int64Value * valueRight.Int64Value,
BinaryOperatorKind.UIntMultiplication => valueLeft.UInt32Value * valueRight.UInt32Value,
BinaryOperatorKind.ULongMultiplication => valueLeft.UInt64Value * valueRight.UInt64Value,
BinaryOperatorKind.IntDivision => unchecked(valueLeft.Int32Value / valueRight.Int32Value),
BinaryOperatorKind.LongDivision => unchecked(valueLeft.Int64Value / valueRight.Int64Value),
_ => null,
};
}
}
internal static TypeSymbol GetEnumType(BinaryOperatorKind kind, BoundExpression left, BoundExpression right)
{
switch (kind)
{
case BinaryOperatorKind.EnumAndUnderlyingAddition:
case BinaryOperatorKind.EnumSubtraction:
case BinaryOperatorKind.EnumAndUnderlyingSubtraction:
case BinaryOperatorKind.EnumEqual:
case BinaryOperatorKind.EnumNotEqual:
case BinaryOperatorKind.EnumGreaterThan:
case BinaryOperatorKind.EnumLessThan:
case BinaryOperatorKind.EnumGreaterThanOrEqual:
case BinaryOperatorKind.EnumLessThanOrEqual:
case BinaryOperatorKind.EnumAnd:
case BinaryOperatorKind.EnumXor:
case BinaryOperatorKind.EnumOr:
return left.Type;
case BinaryOperatorKind.UnderlyingAndEnumAddition:
case BinaryOperatorKind.UnderlyingAndEnumSubtraction:
return right.Type;
default:
throw ExceptionUtilities.UnexpectedValue((object)kind);
}
}
internal static SpecialType GetEnumPromotedType(SpecialType underlyingType)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Invalid comparison between Unknown and I4
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Invalid comparison between Unknown and I4
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (underlyingType - 9 > 3)
{
if (underlyingType - 13 <= 3)
{
return underlyingType;
}
throw ExceptionUtilities.UnexpectedValue((object)underlyingType);
}
return (SpecialType)13;
}
private ConstantValue? FoldEnumBinaryOperator(CSharpSyntaxNode syntax, BinaryOperatorKind kind, BoundExpression left, BoundExpression right, TypeSymbol resultTypeSymbol, BindingDiagnosticBag diagnostics)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Invalid comparison between Unknown and I4
TypeSymbol enumType = GetEnumType(kind, left, right);
TypeSymbol enumUnderlyingType = enumType.GetEnumUnderlyingType();
BoundExpression source = CreateConversion(left, enumUnderlyingType, diagnostics);
BoundExpression source2 = CreateConversion(right, enumUnderlyingType, diagnostics);
SpecialType enumPromotedType = GetEnumPromotedType(enumUnderlyingType.SpecialType);
TypeSymbol typeSymbol = ((enumPromotedType == enumUnderlyingType.SpecialType) ? enumUnderlyingType : GetSpecialType(enumPromotedType, diagnostics, (SyntaxNode)(object)syntax));
source = CreateConversion(source, typeSymbol, diagnostics);
source2 = CreateConversion(source2, typeSymbol, diagnostics);
BinaryOperatorKind kind2 = kind.Operator().WithType(source.Type.SpecialType);
switch (kind2.Operator())
{
case BinaryOperatorKind.Addition:
case BinaryOperatorKind.Subtraction:
case BinaryOperatorKind.And:
case BinaryOperatorKind.Xor:
case BinaryOperatorKind.Or:
resultTypeSymbol = typeSymbol;
break;
default:
throw ExceptionUtilities.UnexpectedValue((object)kind2.Operator());
case BinaryOperatorKind.Equal:
case BinaryOperatorKind.NotEqual:
case BinaryOperatorKind.GreaterThan:
case BinaryOperatorKind.LessThan:
case BinaryOperatorKind.GreaterThanOrEqual:
case BinaryOperatorKind.LessThanOrEqual:
break;
}
ConstantValue val = FoldBinaryOperator(syntax, kind2, source, source2, resultTypeSymbol, diagnostics);
if ((int)resultTypeSymbol.SpecialType != 7 && val != (ConstantValue)null && !val.IsBad)
{
TypeSymbol destination = ((kind == BinaryOperatorKind.EnumSubtraction) ? enumUnderlyingType : enumType);
return FoldConstantNumericConversion((SyntaxNode)(object)syntax, val, destination, diagnostics);
}
return val;
}
private ConstantValue? FoldBinaryOperator(CSharpSyntaxNode syntax, BinaryOperatorKind kind, BoundExpression left, BoundExpression right, TypeSymbol resultTypeSymbol, BindingDiagnosticBag diagnostics)
{
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
if (left.HasAnyErrors || right.HasAnyErrors)
{
return null;
}
ConstantValue val = TryFoldingNullableEquality(kind, left, right);
if (val != (ConstantValue)null)
{
return val;
}
ConstantValue constantValueOpt = left.ConstantValueOpt;
ConstantValue constantValueOpt2 = right.ConstantValueOpt;
if (constantValueOpt == (ConstantValue)null || constantValueOpt2 == (ConstantValue)null)
{
return null;
}
if (constantValueOpt.IsBad || constantValueOpt2.IsBad)
{
return ConstantValue.Bad;
}
if (kind.IsEnum() && !kind.IsLifted())
{
return FoldEnumBinaryOperator(syntax, kind, left, right, resultTypeSymbol, diagnostics);
}
if (IsDivisionByZero(kind, constantValueOpt2))
{
Error(diagnostics, ErrorCode.ERR_IntDivByZero, syntax);
return ConstantValue.Bad;
}
object obj = null;
SpecialType specialType = resultTypeSymbol.SpecialType;
obj = FoldNeverOverflowBinaryOperators(kind, constantValueOpt, constantValueOpt2);
if (obj != null)
{
return ConstantValue.Create(obj, specialType);
}
ConstantValue val2 = FoldStringConcatenation(kind, constantValueOpt, constantValueOpt2);
if (val2 != (ConstantValue)null)
{
if (val2.IsBad)
{
Error(diagnostics, ErrorCode.ERR_ConstantStringTooLong, SyntaxNodeOrToken.op_Implicit(right.Syntax));
}
return val2;
}
try
{
obj = FoldDecimalBinaryOperators(kind, constantValueOpt, constantValueOpt2);
}
catch (OverflowException)
{
Error(diagnostics, ErrorCode.ERR_DecConstError, syntax);
return ConstantValue.Bad;
}
if (obj != null)
{
return ConstantValue.Create(obj, specialType);
}
try
{
obj = FoldNativeIntegerOverflowingBinaryOperator(kind, constantValueOpt, constantValueOpt2);
}
catch (OverflowException)
{
if (CheckOverflowAtCompileTime)
{
Error(diagnostics, ErrorCode.WRN_CompileTimeCheckedOverflow, syntax, resultTypeSymbol);
}
return null;
}
if (obj != null)
{
return ConstantValue.Create(obj, specialType);
}
if (CheckOverflowAtCompileTime)
{
try
{
obj = FoldCheckedIntegralBinaryOperator(kind, constantValueOpt, constantValueOpt2);
}
catch (OverflowException)
{
Error(diagnostics, ErrorCode.ERR_CheckedOverflow, syntax);
return ConstantValue.Bad;
}
}
else
{
obj = FoldUncheckedIntegralBinaryOperator(kind, constantValueOpt, constantValueOpt2);
}
if (obj != null)
{
return ConstantValue.Create(obj, specialType);
}
return null;
}
private static ConstantValue? TryFoldingNullableEquality(BinaryOperatorKind kind, BoundExpression left, BoundExpression right)
{
if (kind.IsLifted())
{
BinaryOperatorKind binaryOperatorKind = kind.Operator();
if ((binaryOperatorKind == BinaryOperatorKind.Equal || binaryOperatorKind == BinaryOperatorKind.NotEqual) && left.Kind == BoundKind.Conversion && right.Kind == BoundKind.Conversion)
{
BoundConversion obj = (BoundConversion)left;
BoundConversion boundConversion = (BoundConversion)right;
ConstantValue constantValueOpt = obj.Operand.ConstantValueOpt;
ConstantValue constantValueOpt2 = boundConversion.Operand.ConstantValueOpt;
if (constantValueOpt != (ConstantValue)null && constantValueOpt2 != (ConstantValue)null)
{
bool isNull = constantValueOpt.IsNull;
bool isNull2 = constantValueOpt2.IsNull;
if (isNull || isNull2)
{
if (isNull == isNull2 != (binaryOperatorKind == BinaryOperatorKind.Equal))
{
return ConstantValue.False;
}
return ConstantValue.True;
}
}
}
}
return null;
}
private static object? FoldNeverOverflowBinaryOperators(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
{
switch (kind)
{
case BinaryOperatorKind.ObjectEqual:
if (valueLeft.IsNull)
{
return valueRight.IsNull;
}
if (valueRight.IsNull)
{
return false;
}
break;
case BinaryOperatorKind.ObjectNotEqual:
if (valueLeft.IsNull)
{
return !valueRight.IsNull;
}
if (valueRight.IsNull)
{
return true;
}
break;
case BinaryOperatorKind.DoubleAddition:
return valueLeft.DoubleValue + valueRight.DoubleValue;
case BinaryOperatorKind.FloatAddition:
return valueLeft.SingleValue + valueRight.SingleValue;
case BinaryOperatorKind.DoubleSubtraction:
return valueLeft.DoubleValue - valueRight.DoubleValue;
case BinaryOperatorKind.FloatSubtraction:
return valueLeft.SingleValue - valueRight.SingleValue;
case BinaryOperatorKind.DoubleMultiplication:
return valueLeft.DoubleValue * valueRight.DoubleValue;
case BinaryOperatorKind.FloatMultiplication:
return valueLeft.SingleValue * valueRight.SingleValue;
case BinaryOperatorKind.DoubleDivision:
return valueLeft.DoubleValue / valueRight.DoubleValue;
case BinaryOperatorKind.FloatDivision:
return valueLeft.SingleValue / valueRight.SingleValue;
case BinaryOperatorKind.DoubleRemainder:
return valueLeft.DoubleValue % valueRight.DoubleValue;
case BinaryOperatorKind.FloatRemainder:
return valueLeft.SingleValue % valueRight.SingleValue;
case BinaryOperatorKind.IntLeftShift:
return valueLeft.Int32Value << valueRight.Int32Value;
case BinaryOperatorKind.LongLeftShift:
return valueLeft.Int64Value << valueRight.Int32Value;
case BinaryOperatorKind.UIntLeftShift:
return valueLeft.UInt32Value << valueRight.Int32Value;
case BinaryOperatorKind.ULongLeftShift:
return valueLeft.UInt64Value << valueRight.Int32Value;
case BinaryOperatorKind.IntRightShift:
case BinaryOperatorKind.NIntRightShift:
return valueLeft.Int32Value >> valueRight.Int32Value;
case BinaryOperatorKind.IntUnsignedRightShift:
return valueLeft.Int32Value >>> valueRight.Int32Value;
case BinaryOperatorKind.NIntUnsignedRightShift:
if (valueLeft.Int32Value < 0)
{
return null;
}
return valueLeft.Int32Value >> valueRight.Int32Value;
case BinaryOperatorKind.LongRightShift:
return valueLeft.Int64Value >> valueRight.Int32Value;
case BinaryOperatorKind.LongUnsignedRightShift:
return valueLeft.Int64Value >>> valueRight.Int32Value;
case BinaryOperatorKind.UIntRightShift:
case BinaryOperatorKind.NUIntRightShift:
case BinaryOperatorKind.UIntUnsignedRightShift:
case BinaryOperatorKind.NUIntUnsignedRightShift:
return valueLeft.UInt32Value >> valueRight.Int32Value;
case BinaryOperatorKind.ULongRightShift:
case BinaryOperatorKind.ULongUnsignedRightShift:
return valueLeft.UInt64Value >> valueRight.Int32Value;
case BinaryOperatorKind.BoolAnd:
return valueLeft.BooleanValue & valueRight.BooleanValue;
case BinaryOperatorKind.IntAnd:
case BinaryOperatorKind.NIntAnd:
return valueLeft.Int32Value & valueRight.Int32Value;
case BinaryOperatorKind.LongAnd:
return valueLeft.Int64Value & valueRight.Int64Value;
case BinaryOperatorKind.UIntAnd:
case BinaryOperatorKind.NUIntAnd:
return valueLeft.UInt32Value & valueRight.UInt32Value;
case BinaryOperatorKind.ULongAnd:
return valueLeft.UInt64Value & valueRight.UInt64Value;
case BinaryOperatorKind.BoolOr:
return valueLeft.BooleanValue | valueRight.BooleanValue;
case BinaryOperatorKind.IntOr:
case BinaryOperatorKind.NIntOr:
return valueLeft.Int32Value | valueRight.Int32Value;
case BinaryOperatorKind.LongOr:
return valueLeft.Int64Value | valueRight.Int64Value;
case BinaryOperatorKind.UIntOr:
case BinaryOperatorKind.NUIntOr:
return valueLeft.UInt32Value | valueRight.UInt32Value;
case BinaryOperatorKind.ULongOr:
return valueLeft.UInt64Value | valueRight.UInt64Value;
case BinaryOperatorKind.BoolXor:
return valueLeft.BooleanValue ^ valueRight.BooleanValue;
case BinaryOperatorKind.IntXor:
case BinaryOperatorKind.NIntXor:
return valueLeft.Int32Value ^ valueRight.Int32Value;
case BinaryOperatorKind.LongXor:
return valueLeft.Int64Value ^ valueRight.Int64Value;
case BinaryOperatorKind.UIntXor:
case BinaryOperatorKind.NUIntXor:
return valueLeft.UInt32Value ^ valueRight.UInt32Value;
case BinaryOperatorKind.ULongXor:
return valueLeft.UInt64Value ^ valueRight.UInt64Value;
case BinaryOperatorKind.LogicalBoolAnd:
return valueLeft.BooleanValue && valueRight.BooleanValue;
case BinaryOperatorKind.LogicalBoolOr:
return valueLeft.BooleanValue || valueRight.BooleanValue;
case BinaryOperatorKind.BoolEqual:
return valueLeft.BooleanValue == valueRight.BooleanValue;
case BinaryOperatorKind.StringEqual:
return valueLeft.StringValue == valueRight.StringValue;
case BinaryOperatorKind.DecimalEqual:
return valueLeft.DecimalValue == valueRight.DecimalValue;
case BinaryOperatorKind.FloatEqual:
return valueLeft.SingleValue == valueRight.SingleValue;
case BinaryOperatorKind.DoubleEqual:
return valueLeft.DoubleValue == valueRight.DoubleValue;
case BinaryOperatorKind.IntEqual:
case BinaryOperatorKind.NIntEqual:
return valueLeft.Int32Value == valueRight.Int32Value;
case BinaryOperatorKind.LongEqual:
return valueLeft.Int64Value == valueRight.Int64Value;
case BinaryOperatorKind.UIntEqual:
case BinaryOperatorKind.NUIntEqual:
return valueLeft.UInt32Value == valueRight.UInt32Value;
case BinaryOperatorKind.ULongEqual:
return valueLeft.UInt64Value == valueRight.UInt64Value;
case BinaryOperatorKind.BoolNotEqual:
return valueLeft.BooleanValue != valueRight.BooleanValue;
case BinaryOperatorKind.StringNotEqual:
return valueLeft.StringValue != valueRight.StringValue;
case BinaryOperatorKind.DecimalNotEqual:
return valueLeft.DecimalValue != valueRight.DecimalValue;
case BinaryOperatorKind.FloatNotEqual:
return valueLeft.SingleValue != valueRight.SingleValue;
case BinaryOperatorKind.DoubleNotEqual:
return valueLeft.DoubleValue != valueRight.DoubleValue;
case BinaryOperatorKind.IntNotEqual:
case BinaryOperatorKind.NIntNotEqual:
return valueLeft.Int32Value != valueRight.Int32Value;
case BinaryOperatorKind.LongNotEqual:
return valueLeft.Int64Value != valueRight.Int64Value;
case BinaryOperatorKind.UIntNotEqual:
case BinaryOperatorKind.NUIntNotEqual:
return valueLeft.UInt32Value != valueRight.UInt32Value;
case BinaryOperatorKind.ULongNotEqual:
return valueLeft.UInt64Value != valueRight.UInt64Value;
case BinaryOperatorKind.DecimalLessThan:
return valueLeft.DecimalValue < valueRight.DecimalValue;
case BinaryOperatorKind.FloatLessThan:
return valueLeft.SingleValue < valueRight.SingleValue;
case BinaryOperatorKind.DoubleLessThan:
return valueLeft.DoubleValue < valueRight.DoubleValue;
case BinaryOperatorKind.IntLessThan:
case BinaryOperatorKind.NIntLessThan:
return valueLeft.Int32Value < valueRight.Int32Value;
case BinaryOperatorKind.LongLessThan:
return valueLeft.Int64Value < valueRight.Int64Value;
case BinaryOperatorKind.UIntLessThan:
case BinaryOperatorKind.NUIntLessThan:
return valueLeft.UInt32Value < valueRight.UInt32Value;
case BinaryOperatorKind.ULongLessThan:
return valueLeft.UInt64Value < valueRight.UInt64Value;
case BinaryOperatorKind.DecimalGreaterThan:
return valueLeft.DecimalValue > valueRight.DecimalValue;
case BinaryOperatorKind.FloatGreaterThan:
return valueLeft.SingleValue > valueRight.SingleValue;
case BinaryOperatorKind.DoubleGreaterThan:
return valueLeft.DoubleValue > valueRight.DoubleValue;
case BinaryOperatorKind.IntGreaterThan:
case BinaryOperatorKind.NIntGreaterThan:
return valueLeft.Int32Value > valueRight.Int32Value;
case BinaryOperatorKind.LongGreaterThan:
return valueLeft.Int64Value > valueRight.Int64Value;
case BinaryOperatorKind.UIntGreaterThan:
case BinaryOperatorKind.NUIntGreaterThan:
return valueLeft.UInt32Value > valueRight.UInt32Value;
case BinaryOperatorKind.ULongGreaterThan:
return valueLeft.UInt64Value > valueRight.UInt64Value;
case BinaryOperatorKind.DecimalLessThanOrEqual:
return valueLeft.DecimalValue <= valueRight.DecimalValue;
case BinaryOperatorKind.FloatLessThanOrEqual:
return valueLeft.SingleValue <= valueRight.SingleValue;
case BinaryOperatorKind.DoubleLessThanOrEqual:
return valueLeft.DoubleValue <= valueRight.DoubleValue;
case BinaryOperatorKind.IntLessThanOrEqual:
case BinaryOperatorKind.NIntLessThanOrEqual:
return valueLeft.Int32Value <= valueRight.Int32Value;
case BinaryOperatorKind.LongLessThanOrEqual:
return valueLeft.Int64Value <= valueRight.Int64Value;
case BinaryOperatorKind.UIntLessThanOrEqual:
case BinaryOperatorKind.NUIntLessThanOrEqual:
return valueLeft.UInt32Value <= valueRight.UInt32Value;
case BinaryOperatorKind.ULongLessThanOrEqual:
return valueLeft.UInt64Value <= valueRight.UInt64Value;
case BinaryOperatorKind.DecimalGreaterThanOrEqual:
return valueLeft.DecimalValue >= valueRight.DecimalValue;
case BinaryOperatorKind.FloatGreaterThanOrEqual:
return valueLeft.SingleValue >= valueRight.SingleValue;
case BinaryOperatorKind.DoubleGreaterThanOrEqual:
return valueLeft.DoubleValue >= valueRight.DoubleValue;
case BinaryOperatorKind.IntGreaterThanOrEqual:
case BinaryOperatorKind.NIntGreaterThanOrEqual:
return valueLeft.Int32Value >= valueRight.Int32Value;
case BinaryOperatorKind.LongGreaterThanOrEqual:
return valueLeft.Int64Value >= valueRight.Int64Value;
case BinaryOperatorKind.UIntGreaterThanOrEqual:
case BinaryOperatorKind.NUIntGreaterThanOrEqual:
return valueLeft.UInt32Value >= valueRight.UInt32Value;
case BinaryOperatorKind.ULongGreaterThanOrEqual:
return valueLeft.UInt64Value >= valueRight.UInt64Value;
case BinaryOperatorKind.UIntDivision:
case BinaryOperatorKind.NUIntDivision:
return valueLeft.UInt32Value / valueRight.UInt32Value;
case BinaryOperatorKind.ULongDivision:
return valueLeft.UInt64Value / valueRight.UInt64Value;
case BinaryOperatorKind.IntRemainder:
return (valueRight.Int32Value != -1) ? (valueLeft.Int32Value % valueRight.Int32Value) : 0;
case BinaryOperatorKind.LongRemainder:
return (valueRight.Int64Value != -1) ? (valueLeft.Int64Value % valueRight.Int64Value) : 0;
case BinaryOperatorKind.UIntRemainder:
case BinaryOperatorKind.NUIntRemainder:
return valueLeft.UInt32Value % valueRight.UInt32Value;
case BinaryOperatorKind.ULongRemainder:
return valueLeft.UInt64Value % valueRight.UInt64Value;
}
return null;
}
private static ConstantValue? FoldStringConcatenation(BinaryOperatorKind kind, ConstantValue valueLeft, ConstantValue valueRight)
{
if (kind == BinaryOperatorKind.StringConcatenation)
{
Rope val = valueLeft.RopeValue ?? Rope.Empty;
Rope val2 = valueRight.RopeValue ?? Rope.Empty;
if ((long)val.Length + (long)val2.Length <= int.MaxValue)
{
return ConstantValue.CreateFromRope(Rope.Concat(val, val2));
}
return ConstantValue.Bad;
}
return null;
}
public static BinaryOperatorKind SyntaxKindToBinaryOperatorKind(SyntaxKind kind)
{
switch (kind)
{
case SyntaxKind.MultiplyExpression:
case SyntaxKind.MultiplyAssignmentExpression:
return BinaryOperatorKind.Multiplication;
case SyntaxKind.DivideExpression:
case SyntaxKind.DivideAssignmentExpression:
return BinaryOperatorKind.Division;
case SyntaxKind.ModuloExpression:
case SyntaxKind.ModuloAssignmentExpression:
return BinaryOperatorKind.Remainder;
case SyntaxKind.AddExpression:
case SyntaxKind.AddAssignmentExpression:
return BinaryOperatorKind.Addition;
case SyntaxKind.SubtractExpression:
case SyntaxKind.SubtractAssignmentExpression:
return BinaryOperatorKind.Subtraction;
case SyntaxKind.RightShiftExpression:
case SyntaxKind.RightShiftAssignmentExpression:
return BinaryOperatorKind.RightShift;
case SyntaxKind.UnsignedRightShiftExpression:
case SyntaxKind.UnsignedRightShiftAssignmentExpression:
return BinaryOperatorKind.UnsignedRightShift;
case SyntaxKind.LeftShiftExpression:
case SyntaxKind.LeftShiftAssignmentExpression:
return BinaryOperatorKind.LeftShift;
case SyntaxKind.EqualsExpression:
return BinaryOperatorKind.Equal;
case SyntaxKind.NotEqualsExpression:
return BinaryOperatorKind.NotEqual;
case SyntaxKind.GreaterThanExpression:
return BinaryOperatorKind.GreaterThan;
case SyntaxKind.LessThanExpression:
return BinaryOperatorKind.LessThan;
case SyntaxKind.GreaterThanOrEqualExpression:
return BinaryOperatorKind.GreaterThanOrEqual;
case SyntaxKind.LessThanOrEqualExpression:
return BinaryOperatorKind.LessThanOrEqual;
case SyntaxKind.BitwiseAndExpression:
case SyntaxKind.AndAssignmentExpression:
return BinaryOperatorKind.And;
case SyntaxKind.BitwiseOrExpression:
case SyntaxKind.OrAssignmentExpression:
return BinaryOperatorKind.Or;
case SyntaxKind.ExclusiveOrExpression:
case SyntaxKind.ExclusiveOrAssignmentExpression:
return BinaryOperatorKind.Xor;
case SyntaxKind.LogicalAndExpression:
return BinaryOperatorKind.LogicalAnd;
case SyntaxKind.LogicalOrExpression:
return BinaryOperatorKind.LogicalOr;
default:
throw ExceptionUtilities.UnexpectedValue((object)kind);
}
}
private BoundExpression BindIncrementOperator(CSharpSyntaxNode node, ExpressionSyntax operandSyntax, SyntaxToken operatorToken, BindingDiagnosticBag diagnostics)
{
operandSyntax.CheckDeconstructionCompatibleArgument(diagnostics);
BoundExpression boundExpression = BindToNaturalType(BindValue(operandSyntax, diagnostics, BindValueKind.IncrementDecrement), diagnostics);
UnaryOperatorKind unaryOperatorKind = SyntaxKindToUnaryOperatorKind(node.Kind());
if (boundExpression.HasAnyErrors)
{
return new BoundIncrementOperator(node, unaryOperatorKind, boundExpression, null, null, null, null, null, null, LookupResultKind.Empty, CreateErrorType(), hasErrors: true);
}
TypeSymbol type = boundExpression.Type;
if (type.IsDynamic())
{
return new BoundIncrementOperator((SyntaxNode)(object)node, unaryOperatorKind.WithType(UnaryOperatorKind.Dynamic).WithOverflowChecksIfApplicable(CheckOverflowAtRuntime), boundExpression, null, null, null, null, null, null, LookupResultKind.Viable, default(ImmutableArray<MethodSymbol>), type);
}
LookupResultKind resultKind;
ImmutableArray<MethodSymbol> originalUserDefinedOperators;
UnaryOperatorAnalysisResult unaryOperatorAnalysisResult = UnaryOperatorOverloadResolution(unaryOperatorKind, boundExpression, node, diagnostics, out resultKind, out originalUserDefinedOperators);
if (!unaryOperatorAnalysisResult.HasValue)
{
ReportUnaryOperatorError(node, diagnostics, ((SyntaxToken)(ref operatorToken)).Text, boundExpression, resultKind);
return new BoundIncrementOperator((SyntaxNode)(object)node, unaryOperatorKind, boundExpression, null, null, null, null, null, null, resultKind, originalUserDefinedOperators, CreateErrorType(), hasErrors: true);
}
UnaryOperatorSignature signature = unaryOperatorAnalysisResult.Signature;
CheckNativeIntegerFeatureAvailability(signature.Kind, (SyntaxNode)(object)node, diagnostics);
CheckConstraintLanguageVersionAndRuntimeSupportForOperator((SyntaxNode)(object)node, signature.Method, isUnsignedRightShift: false, signature.ConstrainedToTypeOpt, diagnostics);
BoundValuePlaceholder boundValuePlaceholder = new BoundValuePlaceholder((SyntaxNode)(object)node, signature.ReturnType).MakeCompilerGenerated();
BoundExpression boundExpression2 = GenerateConversionForAssignment(type, boundValuePlaceholder, diagnostics, ConversionForAssignmentFlags.IncrementAssignment);
bool flag = boundExpression2.HasErrors;
if (!(boundExpression2 is BoundConversion) && boundExpression2 != boundValuePlaceholder)
{
boundValuePlaceholder = null;
boundExpression2 = null;
}
if (!flag && type.IsVoidPointer())
{
Error(diagnostics, ErrorCode.ERR_VoidError, node);
flag = true;
}
BoundValuePlaceholder boundValuePlaceholder2 = new BoundValuePlaceholder(boundExpression.Syntax, boundExpression.Type).MakeCompilerGenerated();
BoundExpression operandConversion = CreateConversion((SyntaxNode)(object)node, boundValuePlaceholder2, unaryOperatorAnalysisResult.Conversion, isCast: false, null, unaryOperatorAnalysisResult.Signature.OperandType, diagnostics);
return new BoundIncrementOperator((SyntaxNode)(object)node, signature.Kind.WithOverflowChecksIfApplicable(CheckOverflowAtRuntime), boundExpression, signature.Method, signature.ConstrainedToTypeOpt, boundValuePlaceholder2, operandConversion, boundValuePlaceholder, boundExpression2, resultKind, originalUserDefinedOperators, type, flag);
}
private bool CheckConstraintLanguageVersionAndRuntimeSupportForOperator(SyntaxNode node, MethodSymbol? methodOpt, bool isUnsignedRightShift, TypeSymbol? constrainedToTypeOpt, BindingDiagnosticBag diagnostics)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
bool flag = true;
if ((object)methodOpt != null && methodOpt.ContainingType?.IsInterface == true && methodOpt.IsStatic)
{
if (methodOpt.IsAbstract || methodOpt.IsVirtual)
{
if (!(constrainedToTypeOpt is TypeParameterSymbol))
{
Error(diagnostics, ErrorCode.ERR_BadAbstractStaticMemberAccess, SyntaxNodeOrToken.op_Implicit(node));
return false;
}
if (Compilation.SourceModule != methodOpt.ContainingModule)
{
flag = CheckFeatureAvailability(node, MessageID.IDS_FeatureStaticAbstractMembersInInterfaces, diagnostics);
if (!Compilation.Assembly.RuntimeSupportsStaticAbstractMembersInInterfaces)
{
Error(diagnostics, ErrorCode.ERR_RuntimeDoesNotSupportStaticAbstractMembersInInterfaces, SyntaxNodeOrToken.op_Implicit(node));
return false;
}
}
}
else
{
string name = methodOpt.Name;
if ((name == "op_Equality" || name == "op_Inequality") ? true : false)
{
flag = CheckFeatureAvailability(node, MessageID.IDS_FeatureStaticAbstractMembersInInterfaces, diagnostics);
}
}
}
if ((object)methodOpt == null)
{
if (isUnsignedRightShift)
{
flag &= CheckFeatureAvailability(node, MessageID.IDS_FeatureUnsignedRightShift, diagnostics);
}
}
else if (Compilation.SourceModule != methodOpt.ContainingModule)
{
if (SyntaxFacts.IsCheckedOperator(methodOpt.Name))
{
flag &= CheckFeatureAvailability(node, MessageID.IDS_FeatureCheckedUserDefinedOperators, diagnostics);
}
else if (isUnsignedRightShift)
{
flag &= CheckFeatureAvailability(node, MessageID.IDS_FeatureUnsignedRightShift, diagnostics);
}
}
return flag;
}
private BoundExpression BindSuppressNullableWarningExpression(PostfixUnaryExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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)
MessageID.IDS_FeatureNullableReferenceTypes.CheckFeatureAvailability(diagnostics, node.OperatorToken);
BoundExpression boundExpression = BindExpression(node.Operand, diagnostics);
BoundKind kind = boundExpression.Kind;
if (kind == BoundKind.TypeExpression || kind == BoundKind.NamespaceExpression)
{
Error(diagnostics, ErrorCode.ERR_IllegalSuppression, SyntaxNodeOrToken.op_Implicit(boundExpression.Syntax));
}
else if (boundExpression.IsSuppressed)
{
Error(diagnostics, ErrorCode.ERR_DuplicateNullSuppression, SyntaxNodeOrToken.op_Implicit(boundExpression.Syntax));
}
return boundExpression.WithSuppression();
}
private BoundExpression BindPointerIndirectionExpression(PrefixUnaryExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
BoundExpression operand = BindToNaturalType(BindValue(node.Operand, diagnostics, GetUnaryAssignmentKind(node.Kind())), diagnostics);
BindPointerIndirectionExpressionInternal(node, operand, diagnostics, out var pointedAtType, out var hasErrors);
return new BoundPointerIndirectionOperator((SyntaxNode)(object)node, operand, refersToLocation: false, pointedAtType ?? CreateErrorType(), hasErrors);
}
private static void BindPointerIndirectionExpressionInternal(CSharpSyntaxNode node, BoundExpression operand, BindingDiagnosticBag diagnostics, out TypeSymbol pointedAtType, out bool hasErrors)
{
PointerTypeSymbol pointerTypeSymbol = operand.Type as PointerTypeSymbol;
hasErrors = operand.HasAnyErrors;
if ((object)pointerTypeSymbol == null)
{
pointedAtType = null;
if (!hasErrors)
{
Error(diagnostics, ErrorCode.ERR_PtrExpected, node);
hasErrors = true;
}
return;
}
pointedAtType = pointerTypeSymbol.PointedAtType;
if (pointedAtType.IsVoidType())
{
pointedAtType = null;
if (!hasErrors)
{
Error(diagnostics, ErrorCode.ERR_VoidError, node);
hasErrors = true;
}
}
}
private BoundExpression BindAddressOfExpression(PrefixUnaryExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
BoundExpression boundExpression = BindToNaturalType(BindValue(node.Operand, diagnostics, BindValueKind.AddressOf), diagnostics);
ReportSuppressionIfNeeded(boundExpression, diagnostics);
bool flag = boundExpression.HasAnyErrors;
bool flag2 = SyntaxFacts.IsFixedStatementExpression((SyntaxNode)(object)node);
if (!(boundExpression is BoundLambda) && !(boundExpression is UnboundLambda))
{
if (boundExpression is BoundMethodGroup operand)
{
return new BoundUnconvertedAddressOfOperator((SyntaxNode)(object)node, operand, flag);
}
TypeSymbol type = boundExpression.Type;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
ManagedKind managedKind = type.GetManagedKind(ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
if (!flag)
{
flag = CheckManagedAddr(Compilation, type, managedKind, ((SyntaxNode)node).Location, diagnostics);
}
bool flag3 = Flags.Includes(BinderFlags.AllowMoveableAddressOf);
if (!flag && !flag3 && IsMoveableVariable(boundExpression, out var _) != flag2)
{
Error(diagnostics, flag2 ? ErrorCode.ERR_FixedNotNeeded : ErrorCode.ERR_FixedNeeded, (CSharpSyntaxNode)node);
flag = true;
}
TypeSymbol type2 = new PointerTypeSymbol(TypeWithAnnotations.Create(type));
return new BoundAddressOfOperator((SyntaxNode)(object)node, boundExpression, type2, flag);
}
return new BoundAddressOfOperator((SyntaxNode)(object)node, boundExpression, CreateErrorType(), hasErrors: true);
}
internal bool IsMoveableVariable(BoundExpression expr, out Symbol accessedLocalOrParameterOpt)
{
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Invalid comparison between Unknown and I4
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Invalid comparison between Unknown and I4
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Invalid comparison between Unknown and I4
accessedLocalOrParameterOpt = null;
while (true)
{
FieldSymbol fieldSymbol;
BoundExpression receiverOpt;
switch (expr.Kind)
{
case BoundKind.FieldAccess:
{
BoundFieldAccess obj = (BoundFieldAccess)expr;
fieldSymbol = obj.FieldSymbol;
receiverOpt = obj.ReceiverOpt;
goto IL_00cc;
}
case BoundKind.EventAccess:
{
BoundEventAccess boundEventAccess = (BoundEventAccess)expr;
if (!boundEventAccess.IsUsableAsField || boundEventAccess.EventSymbol.IsWindowsRuntimeEvent)
{
return true;
}
fieldSymbol = boundEventAccess.EventSymbol.AssociatedField;
receiverOpt = boundEventAccess.ReceiverOpt;
goto IL_00cc;
}
case BoundKind.InlineArrayAccess:
{
BoundInlineArrayAccess boundInlineArrayAccess = (BoundInlineArrayAccess)expr;
WellKnownMember getItemOrSliceHelper = boundInlineArrayAccess.GetItemOrSliceHelper;
if (((int)getItemOrSliceHelper == 400 || (int)getItemOrSliceHelper == 406) ? true : false)
{
expr = boundInlineArrayAccess.Expression;
continue;
}
break;
}
case BoundKind.RangeVariable:
expr = ((BoundRangeVariable)expr).Value;
continue;
case BoundKind.Parameter:
{
ParameterSymbol parameterSymbol = (ParameterSymbol)(accessedLocalOrParameterOpt = ((BoundParameter)expr).ParameterSymbol);
if ((int)parameterSymbol.RefKind != 0)
{
return true;
}
if (parameterSymbol.ContainingSymbol is SynthesizedPrimaryConstructor synthesizedPrimaryConstructor && synthesizedPrimaryConstructor.GetCapturedParameters().ContainsKey(parameterSymbol))
{
return true;
}
return false;
}
case BoundKind.ThisReference:
case BoundKind.BaseReference:
accessedLocalOrParameterOpt = ContainingMemberOrLambda.EnclosingThisSymbol();
return true;
case BoundKind.Local:
return (int)((LocalSymbol)(accessedLocalOrParameterOpt = ((BoundLocal)expr).LocalSymbol)).RefKind > 0;
case BoundKind.PointerIndirectionOperator:
case BoundKind.ConvertedStackAllocExpression:
return false;
case BoundKind.PointerElementAccess:
{
if (((BoundPointerElementAccess)expr).Expression is BoundFieldAccess boundFieldAccess && boundFieldAccess.FieldSymbol.IsFixedSizeBuffer)
{
expr = boundFieldAccess.ReceiverOpt;
continue;
}
return false;
}
IL_00cc:
if ((object)fieldSymbol == null || fieldSymbol.IsStatic || receiverOpt == null)
{
return true;
}
if (!CheckValueKind(receiverOpt.Syntax, receiverOpt, BindValueKind.AddressOf, checkingReceiver: false, BindingDiagnosticBag.Discarded))
{
return true;
}
if (receiverOpt.Type.IsReferenceType)
{
return true;
}
expr = receiverOpt;
continue;
}
break;
}
return true;
}
private BoundExpression BindUnaryOperator(PrefixUnaryExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
BoundExpression operand = BindToNaturalType(BindValue(node.Operand, diagnostics, GetUnaryAssignmentKind(node.Kind())), diagnostics);
object obj = BindIntegralMinValConstants(node, operand, diagnostics);
if (obj == null)
{
SyntaxToken operatorToken = node.OperatorToken;
obj = BindUnaryOperatorCore(node, ((SyntaxToken)(ref operatorToken)).Text, operand, diagnostics);
}
return (BoundExpression)obj;
}
private void ReportSuppressionIfNeeded(BoundExpression expr, BindingDiagnosticBag diagnostics)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (expr.IsSuppressed)
{
Error(diagnostics, ErrorCode.ERR_IllegalSuppression, SyntaxNodeOrToken.op_Implicit(expr.Syntax));
}
}
private BoundExpression BindUnaryOperatorCore(CSharpSyntaxNode node, string operatorText, BoundExpression operand, BindingDiagnosticBag diagnostics)
{
UnaryOperatorKind unaryOperatorKind = SyntaxKindToUnaryOperatorKind(node.Kind());
bool flag = operand.IsLiteralNull() || operand.IsImplicitObjectCreation();
if (flag)
{
Error(diagnostics, ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, node, operatorText, operand.Display);
}
if (!flag)
{
TypeSymbol? type = operand.Type;
if ((object)type == null || !type.IsErrorType())
{
if (operand.HasDynamicType())
{
return new BoundUnaryOperator((SyntaxNode)(object)node, unaryOperatorKind.WithType(UnaryOperatorKind.Dynamic).WithOverflowChecksIfApplicable(CheckOverflowAtRuntime), operand, null, null, null, LookupResultKind.Viable, operand.Type);
}
LookupResultKind resultKind;
ImmutableArray<MethodSymbol> originalUserDefinedOperators;
UnaryOperatorAnalysisResult unaryOperatorAnalysisResult = UnaryOperatorOverloadResolution(unaryOperatorKind, operand, node, diagnostics, out resultKind, out originalUserDefinedOperators);
if (!unaryOperatorAnalysisResult.HasValue)
{
ReportUnaryOperatorError(node, diagnostics, operatorText, operand, resultKind);
return new BoundUnaryOperator((SyntaxNode)(object)node, unaryOperatorKind, operand, null, null, null, resultKind, originalUserDefinedOperators, CreateErrorType(), hasErrors: true);
}
UnaryOperatorSignature signature = unaryOperatorAnalysisResult.Signature;
BoundExpression operand2 = CreateConversion(operand.Syntax, operand, unaryOperatorAnalysisResult.Conversion, isCast: false, null, signature.OperandType, diagnostics);
TypeSymbol returnType = signature.ReturnType;
UnaryOperatorKind kind = signature.Kind;
ConstantValue constantValueOpt = FoldUnaryOperator(node, kind, operand2, returnType, diagnostics);
CheckNativeIntegerFeatureAvailability(kind, (SyntaxNode)(object)node, diagnostics);
CheckConstraintLanguageVersionAndRuntimeSupportForOperator((SyntaxNode)(object)node, signature.Method, isUnsignedRightShift: false, signature.ConstrainedToTypeOpt, diagnostics);
return new BoundUnaryOperator((SyntaxNode)(object)node, kind.WithOverflowChecksIfApplicable(CheckOverflowAtRuntime), operand2, constantValueOpt, signature.Method, signature.ConstrainedToTypeOpt, resultKind, returnType);
}
}
return new BoundUnaryOperator((SyntaxNode)(object)node, unaryOperatorKind, operand, null, null, null, LookupResultKind.Empty, CreateErrorType(), hasErrors: true);
}
private ConstantValue? FoldEnumUnaryOperator(CSharpSyntaxNode syntax, UnaryOperatorKind kind, BoundExpression operand, BindingDiagnosticBag diagnostics)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol enumUnderlyingType = operand.Type.GetEnumUnderlyingType();
BoundExpression source = CreateConversion(operand, enumUnderlyingType, diagnostics);
SpecialType enumPromotedType = GetEnumPromotedType(enumUnderlyingType.SpecialType);
NamedTypeSymbol namedTypeSymbol = ((enumPromotedType == enumUnderlyingType.SpecialType) ? enumUnderlyingType : GetSpecialType(enumPromotedType, diagnostics, (SyntaxNode)(object)syntax));
source = CreateConversion(source, namedTypeSymbol, diagnostics);
UnaryOperatorKind kind2 = kind.Operator().WithType(enumPromotedType);
ConstantValue val = FoldUnaryOperator(syntax, kind2, operand, namedTypeSymbol, diagnostics);
if (val != (ConstantValue)null && !val.IsBad)
{
return ((kind.Operator() == UnaryOperatorKind.BitwiseComplement) ? WithCheckedOrUncheckedRegion(@checked: false) : this).FoldConstantNumericConversion((SyntaxNode)(object)syntax, val, enumUnderlyingType, diagnostics);
}
return val;
}
private ConstantValue? FoldUnaryOperator(CSharpSyntaxNode syntax, UnaryOperatorKind kind, BoundExpression operand, TypeSymbol resultTypeSymbol, BindingDiagnosticBag diagnostics)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
if (operand.HasAnyErrors)
{
return null;
}
ConstantValue constantValueOpt = operand.ConstantValueOpt;
if (constantValueOpt == (ConstantValue)null || constantValueOpt.IsBad)
{
return constantValueOpt;
}
if (kind.IsEnum() && !kind.IsLifted())
{
return FoldEnumUnaryOperator(syntax, kind, operand, diagnostics);
}
SpecialType specialType = resultTypeSymbol.SpecialType;
object obj = FoldNeverOverflowUnaryOperator(kind, constantValueOpt);
if (obj != null)
{
return ConstantValue.Create(obj, specialType);
}
try
{
obj = FoldNativeIntegerOverflowingUnaryOperator(kind, constantValueOpt);
}
catch (OverflowException)
{
if (CheckOverflowAtCompileTime)
{
Error(diagnostics, ErrorCode.WRN_CompileTimeCheckedOverflow, syntax, resultTypeSymbol);
}
return null;
}
if (obj != null)
{
return ConstantValue.Create(obj, specialType);
}
if (CheckOverflowAtCompileTime)
{
try
{
obj = FoldCheckedIntegralUnaryOperator(kind, constantValueOpt);
}
catch (OverflowException)
{
Error(diagnostics, ErrorCode.ERR_CheckedOverflow, syntax);
return ConstantValue.Bad;
}
}
else
{
obj = FoldUncheckedIntegralUnaryOperator(kind, constantValueOpt);
}
if (obj != null)
{
return ConstantValue.Create(obj, specialType);
}
return null;
}
private static object? FoldNeverOverflowUnaryOperator(UnaryOperatorKind kind, ConstantValue value)
{
switch (kind)
{
case UnaryOperatorKind.DecimalUnaryMinus:
return -value.DecimalValue;
case UnaryOperatorKind.FloatUnaryMinus:
case UnaryOperatorKind.DoubleUnaryMinus:
return 0.0 - value.DoubleValue;
case UnaryOperatorKind.DecimalUnaryPlus:
return value.DecimalValue;
case UnaryOperatorKind.FloatUnaryPlus:
case UnaryOperatorKind.DoubleUnaryPlus:
return value.DoubleValue;
case UnaryOperatorKind.LongUnaryPlus:
return value.Int64Value;
case UnaryOperatorKind.ULongUnaryPlus:
return value.UInt64Value;
case UnaryOperatorKind.IntUnaryPlus:
case UnaryOperatorKind.NIntUnaryPlus:
return value.Int32Value;
case UnaryOperatorKind.UIntUnaryPlus:
case UnaryOperatorKind.NUIntUnaryPlus:
return value.UInt32Value;
case UnaryOperatorKind.BoolLogicalNegation:
return !value.BooleanValue;
case UnaryOperatorKind.IntBitwiseComplement:
return ~value.Int32Value;
case UnaryOperatorKind.LongBitwiseComplement:
return ~value.Int64Value;
case UnaryOperatorKind.UIntBitwiseComplement:
return ~value.UInt32Value;
case UnaryOperatorKind.ULongBitwiseComplement:
return ~value.UInt64Value;
default:
return null;
}
}
private static object? FoldUncheckedIntegralUnaryOperator(UnaryOperatorKind kind, ConstantValue value)
{
return kind switch
{
UnaryOperatorKind.LongUnaryMinus => -value.Int64Value,
UnaryOperatorKind.IntUnaryMinus => -value.Int32Value,
_ => null,
};
}
private static object? FoldCheckedIntegralUnaryOperator(UnaryOperatorKind kind, ConstantValue value)
{
return checked(kind switch
{
UnaryOperatorKind.LongUnaryMinus => -value.Int64Value,
UnaryOperatorKind.IntUnaryMinus => -value.Int32Value,
_ => null,
});
}
private static object? FoldNativeIntegerOverflowingUnaryOperator(UnaryOperatorKind kind, ConstantValue value)
{
switch (kind)
{
case UnaryOperatorKind.NIntUnaryMinus:
return checked(-value.Int32Value);
case UnaryOperatorKind.NIntBitwiseComplement:
case UnaryOperatorKind.NUIntBitwiseComplement:
return null;
default:
return null;
}
}
public static UnaryOperatorKind SyntaxKindToUnaryOperatorKind(SyntaxKind kind)
{
return kind switch
{
SyntaxKind.PreIncrementExpression => UnaryOperatorKind.PrefixIncrement,
SyntaxKind.PostIncrementExpression => UnaryOperatorKind.PostfixIncrement,
SyntaxKind.PreDecrementExpression => UnaryOperatorKind.PrefixDecrement,
SyntaxKind.PostDecrementExpression => UnaryOperatorKind.PostfixDecrement,
SyntaxKind.UnaryPlusExpression => UnaryOperatorKind.UnaryPlus,
SyntaxKind.UnaryMinusExpression => UnaryOperatorKind.UnaryMinus,
SyntaxKind.LogicalNotExpression => UnaryOperatorKind.LogicalNegation,
SyntaxKind.BitwiseNotExpression => UnaryOperatorKind.BitwiseComplement,
_ => throw ExceptionUtilities.UnexpectedValue((object)kind),
};
}
private static BindValueKind GetBinaryAssignmentKind(SyntaxKind kind)
{
switch (kind)
{
case SyntaxKind.SimpleAssignmentExpression:
return BindValueKind.Assignable;
case SyntaxKind.AddAssignmentExpression:
case SyntaxKind.SubtractAssignmentExpression:
case SyntaxKind.MultiplyAssignmentExpression:
case SyntaxKind.DivideAssignmentExpression:
case SyntaxKind.ModuloAssignmentExpression:
case SyntaxKind.AndAssignmentExpression:
case SyntaxKind.ExclusiveOrAssignmentExpression:
case SyntaxKind.OrAssignmentExpression:
case SyntaxKind.LeftShiftAssignmentExpression:
case SyntaxKind.RightShiftAssignmentExpression:
case SyntaxKind.CoalesceAssignmentExpression:
case SyntaxKind.UnsignedRightShiftAssignmentExpression:
return BindValueKind.CompoundAssignment;
default:
return BindValueKind.RValue;
}
}
private static BindValueKind GetUnaryAssignmentKind(SyntaxKind kind)
{
switch (kind)
{
case SyntaxKind.PreIncrementExpression:
case SyntaxKind.PreDecrementExpression:
case SyntaxKind.PostIncrementExpression:
case SyntaxKind.PostDecrementExpression:
return BindValueKind.IncrementDecrement;
default:
return BindValueKind.RValue;
}
}
private BoundLiteral BindIntegralMinValConstants(PrefixUnaryExpressionSyntax node, BoundExpression operand, BindingDiagnosticBag diagnostics)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
if (node.Kind() != SyntaxKind.UnaryMinusExpression)
{
return null;
}
if ((object)node.Operand != operand.Syntax || operand.Syntax.Kind() != SyntaxKind.NumericLiteralExpression)
{
return null;
}
SyntaxToken token = ((LiteralExpressionSyntax)(object)operand.Syntax).Token;
if (((SyntaxToken)(ref token)).Value is uint)
{
if ((uint)((SyntaxToken)(ref token)).Value != 2147483648u)
{
return null;
}
if (((SyntaxToken)(ref token)).Text.Contains("u") || ((SyntaxToken)(ref token)).Text.Contains("U") || ((SyntaxToken)(ref token)).Text.Contains("l") || ((SyntaxToken)(ref token)).Text.Contains("L"))
{
return null;
}
return new BoundLiteral((SyntaxNode)(object)node, ConstantValue.Create(int.MinValue), GetSpecialType((SpecialType)13, diagnostics, (SyntaxNode)(object)node));
}
if (((SyntaxToken)(ref token)).Value is ulong)
{
if ((ulong)((SyntaxToken)(ref token)).Value != 9223372036854775808uL)
{
return null;
}
if (((SyntaxToken)(ref token)).Text.Contains("u") || ((SyntaxToken)(ref token)).Text.Contains("U"))
{
return null;
}
return new BoundLiteral((SyntaxNode)(object)node, ConstantValue.Create(long.MinValue), GetSpecialType((SpecialType)15, diagnostics, (SyntaxNode)(object)node));
}
return null;
}
private static bool IsDivisionByZero(BinaryOperatorKind kind, ConstantValue valueRight)
{
switch (kind)
{
case BinaryOperatorKind.DecimalDivision:
case BinaryOperatorKind.DecimalRemainder:
return valueRight.DecimalValue == 0.0m;
case BinaryOperatorKind.IntDivision:
case BinaryOperatorKind.NIntDivision:
case BinaryOperatorKind.IntRemainder:
case BinaryOperatorKind.NIntRemainder:
return valueRight.Int32Value == 0;
case BinaryOperatorKind.LongDivision:
case BinaryOperatorKind.LongRemainder:
return valueRight.Int64Value == 0;
case BinaryOperatorKind.UIntDivision:
case BinaryOperatorKind.NUIntDivision:
case BinaryOperatorKind.UIntRemainder:
case BinaryOperatorKind.NUIntRemainder:
return valueRight.UInt32Value == 0;
case BinaryOperatorKind.ULongDivision:
case BinaryOperatorKind.ULongRemainder:
return valueRight.UInt64Value == 0;
default:
return false;
}
}
private bool IsOperandErrors(CSharpSyntaxNode node, ref BoundExpression operand, BindingDiagnosticBag diagnostics)
{
BoundKind kind = operand.Kind;
if (kind == BoundKind.MethodGroup || kind - 195 <= BoundKind.PropertyEqualsValue)
{
if (!operand.HasAnyErrors)
{
Error(diagnostics, ErrorCode.ERR_LambdaInIsAs, node);
}
operand = BadExpression((SyntaxNode)(object)node, operand).MakeCompilerGenerated();
return true;
}
if ((object)operand.Type == null && !operand.IsLiteralNull())
{
if (!operand.HasAnyErrors)
{
Error(diagnostics, ErrorCode.ERR_BadUnaryOp, node, SyntaxFacts.GetText(SyntaxKind.IsKeyword), operand.Display);
}
operand = BadExpression((SyntaxNode)(object)node, operand).MakeCompilerGenerated();
return true;
}
return operand.HasAnyErrors;
}
private bool IsOperatorErrors(CSharpSyntaxNode node, TypeSymbol operandType, BoundTypeExpression typeExpression, BindingDiagnosticBag diagnostics)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Invalid comparison between Unknown and I4
TypeSymbol type = typeExpression.Type;
if (type.IsStatic)
{
Error(diagnostics, ErrorCode.WRN_StaticInAsOrIs, node, type);
}
if (((object)operandType != null && operandType.IsPointerOrFunctionPointer()) || type.IsPointerOrFunctionPointer())
{
Error(diagnostics, ErrorCode.ERR_PointerInAsOrIs, node);
return true;
}
return (int)type.TypeKind == 6;
}
protected static bool IsUnderscore(ExpressionSyntax node)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
if (node is IdentifierNameSyntax identifierNameSyntax)
{
return identifierNameSyntax.Identifier.IsUnderscoreToken();
}
return false;
}
private BoundExpression BindIsOperator(BinaryExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Invalid comparison between Unknown and I4
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Invalid comparison between Unknown and I4
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0309: Unknown result type (might be due to invalid IL or missing references)
TypeSymbol specialType = GetSpecialType((SpecialType)7, diagnostics, (SyntaxNode)(object)node);
BoundExpression operand = BindRValueWithoutTargetType(node.Left, diagnostics);
bool flag = IsOperandErrors(node, ref operand, diagnostics);
bool flag2 = IsUnderscore(node.Right);
if (!tryBindAsType(node.Right, diagnostics, out var bindAsTypeDiagnostics, out var boundType) && !flag2 && ((CSharpParseOptions)(object)node.SyntaxTree.Options).IsFeatureEnabled(MessageID.IDS_FeaturePatternMatching))
{
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(diagnostics);
if ((object)operand.Type == null)
{
if (!flag)
{
instance.Add(ErrorCode.ERR_BadPatternExpression, ((SyntaxNode)node.Left).Location, operand.Display);
}
operand = ToBadExpression(operand);
}
bool hasErrors = ((SyntaxNode)node.Right).HasErrors;
ConstantValue constantValueOpt;
bool wasExpression;
Conversion patternExpressionConversion;
BoundExpression boundExpression = BindExpressionForPattern(operand.Type, node.Right, ref hasErrors, instance, out constantValueOpt, out wasExpression, out patternExpressionConversion);
if (wasExpression)
{
hasErrors = hasErrors || constantValueOpt == null;
((BindingDiagnosticBag<AssemblySymbol>)(object)bindAsTypeDiagnostics).Free();
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRangeAndFree((BindingDiagnosticBag<AssemblySymbol>)(object)instance);
BoundConstantPattern pattern = new BoundConstantPattern((SyntaxNode)(object)node.Right, boundExpression, constantValueOpt ?? ConstantValue.Bad, operand.Type, boundExpression.Type ?? operand.Type, hasErrors)
{
WasCompilerGenerated = true
};
return MakeIsPatternExpression((SyntaxNode)(object)node, operand, pattern, specialType, flag, diagnostics);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRangeAndFree((BindingDiagnosticBag<AssemblySymbol>)(object)bindAsTypeDiagnostics);
TypeWithAnnotations typeWithAnnotations = boundType.TypeWithAnnotations;
TypeSymbol type = boundType.Type;
if (type.IsReferenceType && typeWithAnnotations.NullableAnnotation.IsAnnotated())
{
Error(diagnostics, ErrorCode.ERR_IsNullableType, (CSharpSyntaxNode)node.Right, new object[1] { type });
flag = true;
}
TypeKind typeKind = type.TypeKind;
if (flag || IsOperatorErrors(node, operand.Type, boundType, diagnostics))
{
return new BoundIsOperator((SyntaxNode)(object)node, operand, boundType, ConversionKind.NoConversion, specialType, hasErrors: true);
}
if (flag2 && ((CSharpParseOptions)(object)node.SyntaxTree.Options).IsFeatureEnabled(MessageID.IDS_FeatureRecursivePatterns))
{
diagnostics.Add(ErrorCode.WRN_IsTypeNamedUnderscore, ((SyntaxNode)node.Right).Location, ((object)boundType.AliasOpt) ?? ((object)type));
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
if (operand.ConstantValueOpt == ConstantValue.Null || operand.Kind == BoundKind.MethodGroup || operand.Type.IsVoidType())
{
Error(diagnostics, ErrorCode.WRN_IsAlwaysFalse, (CSharpSyntaxNode)node, new object[1] { type });
Conversion conversion = Conversions.ClassifyConversionFromExpression(operand, type, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
return new BoundIsOperator((SyntaxNode)(object)node, operand, boundType, conversion.Kind, specialType);
}
if ((int)typeKind == 4)
{
object[] array = new object[3];
SyntaxToken operatorToken = node.OperatorToken;
array[0] = ((SyntaxToken)(ref operatorToken)).Text;
array[1] = type.Name;
array[2] = GetSpecialType((SpecialType)1, diagnostics, (SyntaxNode)(object)node).Name;
Error(diagnostics, ErrorCode.WRN_IsDynamicIsConfusing, (CSharpSyntaxNode)node, array);
}
TypeSymbol typeSymbol = operand.Type;
if ((int)typeSymbol.TypeKind == 4)
{
typeSymbol = GetSpecialType((SpecialType)1, diagnostics, (SyntaxNode)(object)node);
}
Conversion conversion2 = Conversions.ClassifyBuiltInConversion(typeSymbol, type, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
ReportIsOperatorDiagnostics(node, diagnostics, typeSymbol, type, conversion2.Kind, operand.ConstantValueOpt);
return new BoundIsOperator((SyntaxNode)(object)node, operand, boundType, conversion2.Kind, specialType);
bool tryBindAsType(ExpressionSyntax possibleType, BindingDiagnosticBag bindingDiagnosticBag, out BindingDiagnosticBag reference, out BoundTypeExpression reference2)
{
reference = BindingDiagnosticBag.GetInstance(withDiagnostics: true, ((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag).AccumulatesDependencies);
AliasSymbol alias;
TypeWithAnnotations typeWithAnnotations2 = BindType(possibleType, reference, out alias);
TypeSymbol type2 = typeWithAnnotations2.Type;
reference2 = new BoundTypeExpression((SyntaxNode)(object)possibleType, alias, typeWithAnnotations2);
if ((object)type2 != null && type2.IsErrorType())
{
return !((BindingDiagnosticBag)reference).HasAnyResolvedErrors();
}
return true;
}
}
private static void ReportIsOperatorDiagnostics(CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics, TypeSymbol operandType, TypeSymbol targetType, ConversionKind conversionKind, ConstantValue operandConstantValue)
{
ConstantValue isOperatorConstantResult = GetIsOperatorConstantResult(operandType, targetType, conversionKind, operandConstantValue);
if (isOperatorConstantResult != (ConstantValue)null)
{
if (isOperatorConstantResult.IsBad)
{
Error(diagnostics, ErrorCode.ERR_BadBinaryOps, syntax, "is", operandType, targetType);
}
else
{
ErrorCode code = ((isOperatorConstantResult == ConstantValue.True) ? ErrorCode.WRN_IsAlwaysTrue : ErrorCode.WRN_IsAlwaysFalse);
Error(diagnostics, code, syntax, targetType);
}
}
}
internal static ConstantValue GetIsOperatorConstantResult(TypeSymbol operandType, TypeSymbol targetType, ConversionKind conversionKind, ConstantValue operandConstantValue, bool operandCouldBeNull = true)
{
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Invalid comparison between Unknown and I4
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Invalid comparison between Unknown and I4
if (operandConstantValue == ConstantValue.Null)
{
return ConstantValue.False;
}
operandCouldBeNull = operandCouldBeNull && operandType.CanContainNull() && (operandConstantValue == (ConstantValue)null || operandConstantValue == ConstantValue.Null);
switch (conversionKind)
{
case ConversionKind.NoConversion:
if (!operandType.ContainsTypeParameter() && !targetType.ContainsTypeParameter())
{
return ConstantValue.False;
}
if ((operandType.IsValueType && targetType.IsClassType() && (int)targetType.SpecialType != 2) || (targetType.IsValueType && operandType.IsClassType() && (int)operandType.SpecialType != 2))
{
return ConstantValue.False;
}
if (targetType.IsRestrictedType() || operandType.IsRestrictedType())
{
return ConstantValue.Bad;
}
return null;
case ConversionKind.ImplicitNumeric:
case ConversionKind.ImplicitEnumeration:
case ConversionKind.ImplicitTuple:
case ConversionKind.ExplicitTuple:
case ConversionKind.ImplicitConstant:
case ConversionKind.ImplicitUserDefined:
case ConversionKind.ExplicitNumeric:
case ConversionKind.ExplicitUserDefined:
case ConversionKind.IntPtr:
return ConstantValue.False;
case ConversionKind.ExplicitEnumeration:
if (!operandType.IsEnumType() || !targetType.IsEnumType())
{
return ConstantValue.False;
}
goto case ConversionKind.NoConversion;
case ConversionKind.ExplicitNullable:
if (targetType.IsNullableType())
{
return ConstantValue.False;
}
if (ConversionsBase.HasIdentityConversion(operandType.GetNullableUnderlyingType(), targetType))
{
if (!operandCouldBeNull)
{
return ConstantValue.True;
}
return null;
}
return ConstantValue.False;
case ConversionKind.ImplicitReference:
if (!operandCouldBeNull)
{
return ConstantValue.True;
}
return null;
case ConversionKind.ExplicitReference:
case ConversionKind.Unboxing:
return null;
case ConversionKind.Identity:
if (!operandCouldBeNull)
{
return ConstantValue.True;
}
return null;
case ConversionKind.Boxing:
if (!operandCouldBeNull)
{
return ConstantValue.True;
}
return null;
case ConversionKind.ImplicitNullable:
if (!operandType.Equals(targetType.GetNullableUnderlyingType(), (TypeCompareKind)63))
{
return ConstantValue.False;
}
return ConstantValue.True;
default:
throw ExceptionUtilities.UnexpectedValue((object)conversionKind);
}
}
private BoundExpression BindAsOperator(BinaryExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Invalid comparison between Unknown and I4
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Invalid comparison between Unknown and I4
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Invalid comparison between Unknown and I4
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Invalid comparison between Unknown and I4
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Invalid comparison between Unknown and I4
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Invalid comparison between Unknown and I4
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
BoundExpression boundExpression = BindRValueWithoutTargetType(node.Left, diagnostics);
AliasSymbol alias;
TypeWithAnnotations typeWithAnnotations = BindType(node.Right, diagnostics, out alias);
TypeSymbol typeSymbol = typeWithAnnotations.Type;
BoundTypeExpression targetType = new BoundTypeExpression((SyntaxNode)(object)node.Right, alias, typeWithAnnotations);
TypeKind typeKind = typeSymbol.TypeKind;
TypeSymbol typeSymbol2 = typeSymbol;
switch (boundExpression.Kind)
{
case BoundKind.MethodGroup:
case BoundKind.Lambda:
case BoundKind.UnboundLambda:
if (!boundExpression.HasAnyErrors)
{
Error(diagnostics, ErrorCode.ERR_LambdaInIsAs, (CSharpSyntaxNode)node);
}
return new BoundAsOperator((SyntaxNode)(object)node, boundExpression, targetType, null, null, typeSymbol2, hasErrors: true);
case BoundKind.TupleLiteral:
case BoundKind.ConvertedTupleLiteral:
if ((object)boundExpression.Type == null)
{
Error(diagnostics, ErrorCode.ERR_TypelessTupleInAs, (CSharpSyntaxNode)node);
return new BoundAsOperator((SyntaxNode)(object)node, boundExpression, targetType, null, null, typeSymbol2, hasErrors: true);
}
break;
}
if (boundExpression.HasAnyErrors || (int)typeKind == 6)
{
return new BoundAsOperator((SyntaxNode)(object)node, boundExpression, targetType, null, null, typeSymbol2, hasErrors: true);
}
if (typeSymbol.IsReferenceType && typeWithAnnotations.NullableAnnotation.IsAnnotated())
{
Error(diagnostics, ErrorCode.ERR_AsNullableType, (CSharpSyntaxNode)node.Right, new object[1] { typeSymbol });
return new BoundAsOperator((SyntaxNode)(object)node, boundExpression, targetType, null, null, typeSymbol2, hasErrors: true);
}
if (!typeSymbol.IsReferenceType && !typeSymbol.IsNullableType())
{
if ((int)typeKind == 11)
{
Error(diagnostics, ErrorCode.ERR_AsWithTypeVar, (CSharpSyntaxNode)node, new object[1] { typeSymbol });
}
else if ((int)typeKind == 9 || (int)typeKind == 13)
{
Error(diagnostics, ErrorCode.ERR_PointerInAsOrIs, (CSharpSyntaxNode)node);
}
else
{
Error(diagnostics, ErrorCode.ERR_AsMustHaveReferenceType, (CSharpSyntaxNode)node, new object[1] { typeSymbol });
}
return new BoundAsOperator((SyntaxNode)(object)node, boundExpression, targetType, null, null, typeSymbol2, hasErrors: true);
}
if (typeSymbol.IsStatic)
{
Error(diagnostics, ErrorCode.WRN_StaticInAsOrIs, (CSharpSyntaxNode)node, new object[1] { typeSymbol });
}
BoundValuePlaceholder boundValuePlaceholder;
BoundExpression operandConversion;
if (boundExpression.IsLiteralNull())
{
boundValuePlaceholder = new BoundValuePlaceholder(boundExpression.Syntax, boundExpression.Type).MakeCompilerGenerated();
operandConversion = CreateConversion((SyntaxNode)(object)node, boundValuePlaceholder, Conversion.NullLiteral, isCast: false, null, typeSymbol2, diagnostics);
return new BoundAsOperator((SyntaxNode)(object)node, boundExpression, targetType, boundValuePlaceholder, operandConversion, typeSymbol2);
}
if (boundExpression.IsLiteralDefault())
{
boundExpression = new BoundDefaultExpression(boundExpression.Syntax, null, ConstantValue.Null, GetSpecialType((SpecialType)1, diagnostics, (SyntaxNode)(object)node));
}
TypeSymbol typeSymbol3 = boundExpression.Type;
TypeKind typeKind2 = typeSymbol3.TypeKind;
if (typeSymbol3.IsPointerOrFunctionPointer())
{
Error(diagnostics, ErrorCode.ERR_PointerInAsOrIs, (CSharpSyntaxNode)node);
return new BoundAsOperator((SyntaxNode)(object)node, boundExpression, targetType, null, null, typeSymbol2, hasErrors: true);
}
if ((int)typeKind2 == 4)
{
typeSymbol3 = GetSpecialType((SpecialType)1, diagnostics, (SyntaxNode)(object)node);
typeKind2 = typeSymbol3.TypeKind;
}
if ((int)typeKind == 4)
{
typeSymbol = GetSpecialType((SpecialType)1, diagnostics, (SyntaxNode)(object)node);
typeKind = typeSymbol.TypeKind;
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyBuiltInConversion(typeSymbol3, typeSymbol, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
bool hasErrors = ReportAsOperatorConversionDiagnostics(node, diagnostics, Compilation, typeSymbol3, typeSymbol, conversion.Kind, boundExpression.ConstantValueOpt);
if (conversion.Exists)
{
boundValuePlaceholder = new BoundValuePlaceholder(boundExpression.Syntax, boundExpression.Type).MakeCompilerGenerated();
operandConversion = CreateConversion((SyntaxNode)(object)node, boundValuePlaceholder, conversion, isCast: false, null, typeSymbol2, diagnostics);
}
else
{
boundValuePlaceholder = null;
operandConversion = null;
}
return new BoundAsOperator((SyntaxNode)(object)node, boundExpression, targetType, boundValuePlaceholder, operandConversion, typeSymbol2, hasErrors);
}
private static bool ReportAsOperatorConversionDiagnostics(CSharpSyntaxNode node, BindingDiagnosticBag diagnostics, CSharpCompilation compilation, TypeSymbol operandType, TypeSymbol targetType, ConversionKind conversionKind, ConstantValue operandConstantValue)
{
bool flag = false;
switch (conversionKind)
{
default:
if ((!operandType.ContainsTypeParameter() && !targetType.ContainsTypeParameter()) || operandType.IsVoidType())
{
SymbolDistinguisher symbolDistinguisher = new SymbolDistinguisher(compilation, operandType, targetType);
Error(diagnostics, ErrorCode.ERR_NoExplicitBuiltinConv, node, symbolDistinguisher.First, symbolDistinguisher.Second);
flag = true;
}
break;
case ConversionKind.Identity:
case ConversionKind.ImplicitNullable:
case ConversionKind.ImplicitReference:
case ConversionKind.Boxing:
case ConversionKind.ExplicitNullable:
case ConversionKind.ExplicitReference:
case ConversionKind.Unboxing:
break;
}
if (!flag)
{
ReportAsOperatorDiagnostics(node, diagnostics, operandType, targetType, conversionKind, operandConstantValue);
}
return flag;
}
private static void ReportAsOperatorDiagnostics(CSharpSyntaxNode node, BindingDiagnosticBag diagnostics, TypeSymbol operandType, TypeSymbol targetType, ConversionKind conversionKind, ConstantValue operandConstantValue)
{
ConstantValue asOperatorConstantResult = GetAsOperatorConstantResult(operandType, targetType, conversionKind, operandConstantValue);
if (asOperatorConstantResult != (ConstantValue)null)
{
if (asOperatorConstantResult.IsBad)
{
Error(diagnostics, ErrorCode.ERR_BadBinaryOps, node, "as", operandType, targetType);
}
else
{
Error(diagnostics, ErrorCode.WRN_AlwaysNull, node, targetType);
}
}
}
internal static ConstantValue GetAsOperatorConstantResult(TypeSymbol operandType, TypeSymbol targetType, ConversionKind conversionKind, ConstantValue operandConstantValue)
{
ConstantValue isOperatorConstantResult = GetIsOperatorConstantResult(operandType, targetType, conversionKind, operandConstantValue);
if (isOperatorConstantResult != (ConstantValue)null)
{
if (isOperatorConstantResult.IsBad)
{
return isOperatorConstantResult;
}
if (!isOperatorConstantResult.BooleanValue)
{
return ConstantValue.Null;
}
}
return null;
}
private BoundExpression GenerateNullCoalescingBadBinaryOpsError(BinaryExpressionSyntax node, BoundExpression leftOperand, BoundExpression rightOperand, BindingDiagnosticBag diagnostics)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
Error(diagnostics, ErrorCode.ERR_BadBinaryOps, (CSharpSyntaxNode)node, new object[3]
{
SyntaxFacts.GetText(node.OperatorToken.Kind()),
leftOperand.Display,
rightOperand.Display
});
leftOperand = BindToTypeForErrorRecovery(leftOperand);
rightOperand = BindToTypeForErrorRecovery(rightOperand);
return new BoundNullCoalescingOperator((SyntaxNode)(object)node, leftOperand, rightOperand, null, null, BoundNullCoalescingOperatorResultKind.NoCommonType, CheckOverflowAtRuntime, CreateErrorType(), hasErrors: true);
}
private BoundExpression BindNullCoalescingOperator(BinaryExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_033e: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
BoundExpression expression = BindValue(node.Left, diagnostics, BindValueKind.RValue);
expression = BindToNaturalType(expression, diagnostics);
BoundExpression boundExpression = BindValue(node.Right, diagnostics, BindValueKind.RValue);
if (expression.HasAnyErrors || boundExpression.HasAnyErrors)
{
expression = BindToTypeForErrorRecovery(expression);
boundExpression = BindToTypeForErrorRecovery(boundExpression);
return new BoundNullCoalescingOperator((SyntaxNode)(object)node, expression, boundExpression, null, null, BoundNullCoalescingOperatorResultKind.NoCommonType, CheckOverflowAtRuntime, CreateErrorType(), hasErrors: true);
}
if (expression.IsLiteralDefault())
{
object[] array = new object[2];
SyntaxToken operatorToken = node.OperatorToken;
array[0] = ((SyntaxToken)(ref operatorToken)).Text;
array[1] = "default";
Error(diagnostics, ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, (CSharpSyntaxNode)node, array);
return new BoundNullCoalescingOperator((SyntaxNode)(object)node, expression, boundExpression, null, null, BoundNullCoalescingOperatorResultKind.NoCommonType, CheckOverflowAtRuntime, CreateErrorType(), hasErrors: true);
}
TypeSymbol type = expression.Type;
TypeSymbol type2 = boundExpression.Type;
bool flag = type?.IsNullableType() ?? false;
TypeSymbol typeSymbol = (flag ? type.GetNullableUnderlyingType() : type);
if (expression.Kind == BoundKind.UnboundLambda || expression.Kind == BoundKind.MethodGroup)
{
return GenerateNullCoalescingBadBinaryOpsError(node, expression, boundExpression, diagnostics);
}
if ((object)type != null && !type.IsReferenceType && !flag)
{
if (type.IsValueType)
{
return GenerateNullCoalescingBadBinaryOpsError(node, expression, boundExpression, diagnostics);
}
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureUnconstrainedTypeParameterInNullCoalescingOperator, diagnostics);
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
if ((object)type2 != null && type2.IsDynamic())
{
BoundValuePlaceholder boundValuePlaceholder = new BoundValuePlaceholder(expression.Syntax, type).MakeCompilerGenerated();
NamedTypeSymbol specialType = GetSpecialType((SpecialType)1, diagnostics, (SyntaxNode)(object)node);
BoundExpression leftConversion = CreateConversion((SyntaxNode)(object)node, boundValuePlaceholder, Conversions.ClassifyConversionFromExpression(expression, specialType, CheckOverflowAtRuntime, ref useSiteInfo), isCast: false, null, specialType, diagnostics);
boundExpression = BindToNaturalType(boundExpression, diagnostics);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
return new BoundNullCoalescingOperator((SyntaxNode)(object)node, expression, boundExpression, boundValuePlaceholder, leftConversion, BoundNullCoalescingOperatorResultKind.RightDynamicType, CheckOverflowAtRuntime, type2);
}
if (flag)
{
Conversion conversion = Conversions.ClassifyImplicitConversionFromExpression(boundExpression, typeSymbol, ref useSiteInfo);
if (conversion.Exists)
{
BoundValuePlaceholder boundValuePlaceholder2 = new BoundValuePlaceholder(expression.Syntax, typeSymbol).MakeCompilerGenerated();
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
BoundExpression rightOperand = CreateConversion(boundExpression, conversion, typeSymbol, diagnostics);
return new BoundNullCoalescingOperator((SyntaxNode)(object)node, expression, rightOperand, boundValuePlaceholder2, boundValuePlaceholder2, BoundNullCoalescingOperatorResultKind.LeftUnwrappedType, CheckOverflowAtRuntime, typeSymbol);
}
}
if ((object)type != null)
{
Conversion conversion2 = Conversions.ClassifyImplicitConversionFromExpression(boundExpression, type, ref useSiteInfo);
if (conversion2.Exists)
{
BoundExpression rightOperand2 = CreateConversion(boundExpression, conversion2, type, diagnostics);
BoundValuePlaceholder boundValuePlaceholder3 = new BoundValuePlaceholder(expression.Syntax, type).MakeCompilerGenerated();
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
return new BoundNullCoalescingOperator((SyntaxNode)(object)node, expression, rightOperand2, boundValuePlaceholder3, boundValuePlaceholder3, BoundNullCoalescingOperatorResultKind.LeftType, CheckOverflowAtRuntime, type);
}
}
if ((object)type2 != null)
{
boundExpression = BindToNaturalType(boundExpression, diagnostics);
if (flag)
{
Conversion conversion3 = Conversions.ClassifyImplicitConversionFromType(typeSymbol, type2, ref useSiteInfo);
BoundNullCoalescingOperatorResultKind operatorResultKind = BoundNullCoalescingOperatorResultKind.LeftUnwrappedRightType;
if (conversion3.Exists)
{
BoundValuePlaceholder boundValuePlaceholder4 = new BoundValuePlaceholder(expression.Syntax, typeSymbol).MakeCompilerGenerated();
BoundExpression leftConversion2 = CreateConversion((SyntaxNode)(object)node, boundValuePlaceholder4, conversion3, isCast: false, null, type2, diagnostics);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
return new BoundNullCoalescingOperator((SyntaxNode)(object)node, expression, boundExpression, boundValuePlaceholder4, leftConversion2, operatorResultKind, CheckOverflowAtRuntime, type2);
}
}
else
{
Conversion conversion3 = Conversions.ClassifyImplicitConversionFromExpression(expression, type2, ref useSiteInfo);
BoundNullCoalescingOperatorResultKind operatorResultKind = BoundNullCoalescingOperatorResultKind.RightType;
if (conversion3.Exists)
{
BoundValuePlaceholder boundValuePlaceholder5 = new BoundValuePlaceholder(expression.Syntax, type).MakeCompilerGenerated();
BoundExpression leftConversion3 = CreateConversion((SyntaxNode)(object)node, boundValuePlaceholder5, conversion3, isCast: false, null, type2, diagnostics);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
return new BoundNullCoalescingOperator((SyntaxNode)(object)node, expression, boundExpression, boundValuePlaceholder5, leftConversion3, operatorResultKind, CheckOverflowAtRuntime, type2);
}
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
return GenerateNullCoalescingBadBinaryOpsError(node, expression, boundExpression, diagnostics);
}
private BoundExpression BindNullCoalescingAssignmentOperator(AssignmentExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureCoalesceAssignmentExpression.CheckFeatureAvailability(diagnostics, node.OperatorToken);
BoundExpression boundExpression = BindValue(node.Left, diagnostics, BindValueKind.CompoundAssignment);
ReportSuppressionIfNeeded(boundExpression, diagnostics);
BoundExpression boundExpression2 = BindValue(node.Right, diagnostics, BindValueKind.RValue);
if (boundExpression.HasAnyErrors || boundExpression2.HasAnyErrors)
{
boundExpression = BindToTypeForErrorRecovery(boundExpression);
boundExpression2 = BindToTypeForErrorRecovery(boundExpression2);
return new BoundNullCoalescingAssignmentOperator((SyntaxNode)(object)node, boundExpression, boundExpression2, CreateErrorType(), hasErrors: true);
}
TypeSymbol type = boundExpression.Type;
if (type.IsValueType && !type.IsNullableType())
{
return GenerateNullCoalescingAssignmentBadBinaryOpsError(node, boundExpression, boundExpression2, diagnostics);
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
if (type.IsNullableType())
{
TypeSymbol nullableUnderlyingType = type.GetNullableUnderlyingType();
Conversion conversion = Conversions.ClassifyImplicitConversionFromExpression(boundExpression2, nullableUnderlyingType, ref useSiteInfo);
if (conversion.Exists)
{
TypeSymbol? type2 = boundExpression2.Type;
if ((object)type2 == null || !type2.IsDynamic())
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
BoundExpression rightOperand = CreateConversion(boundExpression2, conversion, nullableUnderlyingType, diagnostics);
return new BoundNullCoalescingAssignmentOperator((SyntaxNode)(object)node, boundExpression, rightOperand, nullableUnderlyingType);
}
}
}
useSiteInfo._002Ector(useSiteInfo);
Conversion conversion2 = Conversions.ClassifyImplicitConversionFromExpression(boundExpression2, type, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
if (conversion2.Exists)
{
BoundExpression rightOperand2 = CreateConversion(boundExpression2, conversion2, type, diagnostics);
return new BoundNullCoalescingAssignmentOperator((SyntaxNode)(object)node, boundExpression, rightOperand2, type);
}
return GenerateNullCoalescingAssignmentBadBinaryOpsError(node, boundExpression, boundExpression2, diagnostics);
}
private BoundExpression GenerateNullCoalescingAssignmentBadBinaryOpsError(AssignmentExpressionSyntax node, BoundExpression leftOperand, BoundExpression rightOperand, BindingDiagnosticBag diagnostics)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
Error(diagnostics, ErrorCode.ERR_BadBinaryOps, (CSharpSyntaxNode)node, new object[3]
{
SyntaxFacts.GetText(node.OperatorToken.Kind()),
leftOperand.Display,
rightOperand.Display
});
leftOperand = BindToTypeForErrorRecovery(leftOperand);
rightOperand = BindToTypeForErrorRecovery(rightOperand);
return new BoundNullCoalescingAssignmentOperator((SyntaxNode)(object)node, leftOperand, rightOperand, CreateErrorType(), hasErrors: true);
}
private BoundExpression BindConditionalOperator(ConditionalExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Invalid comparison between Unknown and I4
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Invalid comparison between Unknown and I4
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: 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_0063: Unknown result type (might be due to invalid IL or missing references)
RefKind refKind;
ExpressionSyntax expressionSyntax = node.WhenTrue.CheckAndUnwrapRefExpression(diagnostics, out refKind);
RefKind refKind2;
ExpressionSyntax expressionSyntax2 = node.WhenFalse.CheckAndUnwrapRefExpression(diagnostics, out refKind2);
int num;
if ((int)refKind == 1)
{
num = (((int)refKind2 == 1) ? 1 : 0);
if (num != 0)
{
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureRefConditional, diagnostics);
goto IL_0082;
}
}
else
{
num = 0;
}
SyntaxToken firstToken;
if ((int)refKind2 == 1)
{
firstToken = expressionSyntax2.GetFirstToken();
diagnostics.Add(ErrorCode.ERR_RefConditionalNeedsTwoRefs, ((SyntaxToken)(ref firstToken)).GetLocation());
}
if ((int)refKind == 1)
{
firstToken = expressionSyntax.GetFirstToken();
diagnostics.Add(ErrorCode.ERR_RefConditionalNeedsTwoRefs, ((SyntaxToken)(ref firstToken)).GetLocation());
}
goto IL_0082;
IL_0082:
if (num == 0)
{
return BindValueConditionalOperator(node, expressionSyntax, expressionSyntax2, diagnostics);
}
return BindRefConditionalOperator(node, expressionSyntax, expressionSyntax2, diagnostics);
}
private BoundExpression BindValueConditionalOperator(ConditionalExpressionSyntax node, ExpressionSyntax whenTrue, ExpressionSyntax whenFalse, BindingDiagnosticBag diagnostics)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
BoundExpression condition = BindBooleanExpression(node.Condition, diagnostics);
BoundExpression boundExpression = BindValue(whenTrue, diagnostics, BindValueKind.RValue);
BoundExpression boundExpression2 = BindValue(whenFalse, diagnostics, BindValueKind.RValue);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
ConstantValue val = null;
bool hadMultipleCandidates;
TypeSymbol typeSymbol = BestTypeInferrer.InferBestTypeForConditionalOperator(boundExpression, boundExpression2, Conversions, out hadMultipleCandidates, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
if ((object)typeSymbol == null)
{
ErrorCode noCommonTypeError = (hadMultipleCandidates ? ErrorCode.ERR_AmbigQM : ErrorCode.ERR_InvalidQM);
val = FoldConditionalOperator(condition, boundExpression, boundExpression2);
return new BoundUnconvertedConditionalOperator((SyntaxNode)(object)node, condition, boundExpression, boundExpression2, val, noCommonTypeError, val != null && val.IsBad);
}
TypeSymbol typeSymbol2;
bool flag;
if (typeSymbol.IsErrorType())
{
boundExpression = BindToNaturalType(boundExpression, diagnostics, reportNoTargetType: false);
boundExpression2 = BindToNaturalType(boundExpression2, diagnostics, reportNoTargetType: false);
typeSymbol2 = typeSymbol;
flag = true;
}
else
{
boundExpression = GenerateConversionForAssignment(typeSymbol, boundExpression, diagnostics);
boundExpression2 = GenerateConversionForAssignment(typeSymbol, boundExpression2, diagnostics);
flag = boundExpression.HasAnyErrors || boundExpression2.HasAnyErrors;
typeSymbol2 = (flag ? CreateErrorType() : typeSymbol);
}
if (!flag)
{
val = FoldConditionalOperator(condition, boundExpression, boundExpression2);
flag = val != (ConstantValue)null && val.IsBad;
}
return new BoundConditionalOperator((SyntaxNode)(object)node, isRef: false, condition, boundExpression, boundExpression2, val, typeSymbol2, wasTargetTyped: false, typeSymbol2, flag);
}
private BoundExpression BindRefConditionalOperator(ConditionalExpressionSyntax node, ExpressionSyntax whenTrue, ExpressionSyntax whenFalse, BindingDiagnosticBag diagnostics)
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
BoundExpression condition = BindBooleanExpression(node.Condition, diagnostics);
BoundExpression boundExpression = BindValue(whenTrue, diagnostics, BindValueKind.ReadonlyRef);
BoundExpression boundExpression2 = BindValue(whenFalse, diagnostics, BindValueKind.ReadonlyRef);
bool flag = boundExpression.HasErrors | boundExpression2.HasErrors;
TypeSymbol type = boundExpression.Type;
TypeSymbol type2 = boundExpression2.Type;
TypeSymbol typeSymbol;
if (!ConversionsBase.HasIdentityConversion(type, type2))
{
if (!flag)
{
diagnostics.Add(ErrorCode.ERR_RefConditionalDifferentTypes, boundExpression2.Syntax.Location, type);
}
typeSymbol = CreateErrorType();
flag = true;
}
else
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
typeSymbol = BestTypeInferrer.InferBestTypeForConditionalOperator(boundExpression, boundExpression2, Conversions, out var _, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
}
boundExpression = BindToNaturalType(boundExpression, diagnostics, reportNoTargetType: false);
boundExpression2 = BindToNaturalType(boundExpression2, diagnostics, reportNoTargetType: false);
return new BoundConditionalOperator((SyntaxNode)(object)node, isRef: true, condition, boundExpression, boundExpression2, null, typeSymbol, wasTargetTyped: false, typeSymbol, flag);
}
private static ConstantValue FoldConditionalOperator(BoundExpression condition, BoundExpression trueExpr, BoundExpression falseExpr)
{
ConstantValue constantValueOpt = trueExpr.ConstantValueOpt;
if (constantValueOpt == (ConstantValue)null || constantValueOpt.IsBad)
{
return constantValueOpt;
}
ConstantValue constantValueOpt2 = falseExpr.ConstantValueOpt;
if (constantValueOpt2 == (ConstantValue)null || constantValueOpt2.IsBad)
{
return constantValueOpt2;
}
ConstantValue constantValueOpt3 = condition.ConstantValueOpt;
if (constantValueOpt3 == (ConstantValue)null || constantValueOpt3.IsBad)
{
return constantValueOpt3;
}
if (constantValueOpt3 == ConstantValue.True)
{
return constantValueOpt;
}
if (constantValueOpt3 == ConstantValue.False)
{
return constantValueOpt2;
}
return ConstantValue.Bad;
}
private void CheckNativeIntegerFeatureAvailability(BinaryOperatorKind operatorKind, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
{
if (!Compilation.Assembly.RuntimeSupportsNumericIntPtr)
{
BinaryOperatorKind binaryOperatorKind = operatorKind & BinaryOperatorKind.TypeMask;
if ((uint)(binaryOperatorKind - 9) <= 1u)
{
CheckFeatureAvailability(syntax, MessageID.IDS_FeatureNativeInt, diagnostics);
}
}
}
private void CheckNativeIntegerFeatureAvailability(UnaryOperatorKind operatorKind, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
{
if (!Compilation.Assembly.RuntimeSupportsNumericIntPtr)
{
UnaryOperatorKind unaryOperatorKind = operatorKind & UnaryOperatorKind.TypeMask;
if ((uint)(unaryOperatorKind - 9) <= 1u)
{
CheckFeatureAvailability(syntax, MessageID.IDS_FeatureNativeInt, diagnostics);
}
}
}
private BoundExpression BindIsPatternExpression(IsPatternExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeaturePatternMatching.CheckFeatureAvailability(diagnostics, node.IsKeyword);
BoundExpression operand = BindRValueWithoutTargetType(node.Expression, diagnostics);
bool flag = IsOperandErrors(node, ref operand, diagnostics);
TypeSymbol type = operand.Type;
if ((object)type == null || type.IsVoidType())
{
if (!flag)
{
diagnostics.Add(ErrorCode.ERR_BadPatternExpression, ((SyntaxNode)node.Expression).Location, operand.Display);
flag = true;
}
operand = BadExpression(operand.Syntax, operand);
}
BoundPattern boundPattern = BindPattern(node.Pattern, operand.Type, permitDesignations: true, flag, diagnostics, underIsPattern: true);
flag |= boundPattern.HasErrors;
return MakeIsPatternExpression((SyntaxNode)(object)node, operand, boundPattern, GetSpecialType((SpecialType)7, diagnostics, (SyntaxNode)(object)node), flag, diagnostics);
}
private BoundExpression MakeIsPatternExpression(SyntaxNode node, BoundExpression expression, BoundPattern pattern, TypeSymbol boolType, bool hasErrors, BindingDiagnosticBag diagnostics)
{
LabelSymbol whenTrueLabel = new GeneratedLabelSymbol("isPatternSuccess");
LabelSymbol whenFalseLabel = new GeneratedLabelSymbol("isPatternFailure");
BoundPattern innerPattern;
bool flag = pattern.IsNegated(out innerPattern);
BoundDecisionDag boundDecisionDag = DecisionDagBuilder.CreateDecisionDagForIsPattern(Compilation, pattern.Syntax, expression, innerPattern, whenTrueLabel, whenFalseLabel, diagnostics);
if (!hasErrors)
{
bool? flag2 = getConstantResult(boundDecisionDag, flag, whenTrueLabel, whenFalseLabel);
if (flag2.HasValue)
{
if (flag2 != true)
{
diagnostics.Add(ErrorCode.ERR_IsPatternImpossible, node.Location, expression.Type);
hasErrors = true;
}
else
{
if (pattern is BoundConstantPattern || pattern is BoundITuplePattern)
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs", 76);
}
if (!(pattern is BoundRelationalPattern) && !(pattern is BoundTypePattern) && !(pattern is BoundNegatedPattern) && !(pattern is BoundBinaryPattern) && !(pattern is BoundListPattern))
{
if (!(pattern is BoundDiscardPattern) && !(pattern is BoundDeclarationPattern) && pattern is BoundRecursivePattern)
{
}
}
else
{
diagnostics.Add(ErrorCode.WRN_IsPatternAlways, node.Location, expression.Type);
}
}
goto IL_01d4;
}
}
if (expression.ConstantValueOpt != (ConstantValue)null)
{
boundDecisionDag = boundDecisionDag.SimplifyDecisionDagIfConstantInput(expression);
if (!hasErrors)
{
bool? flag2 = getConstantResult(boundDecisionDag, flag, whenTrueLabel, whenFalseLabel);
if (flag2.HasValue)
{
if (flag2 != true)
{
diagnostics.Add(ErrorCode.WRN_GivenExpressionNeverMatchesPattern, node.Location);
}
else if (!(pattern is BoundConstantPattern))
{
if (pattern is BoundRelationalPattern || pattern is BoundTypePattern || pattern is BoundNegatedPattern || pattern is BoundBinaryPattern || pattern is BoundDiscardPattern)
{
diagnostics.Add(ErrorCode.WRN_GivenExpressionAlwaysMatchesPattern, node.Location);
}
}
else
{
diagnostics.Add(ErrorCode.WRN_GivenExpressionAlwaysMatchesConstant, node.Location);
}
}
}
}
goto IL_01d4;
IL_01d4:
return new BoundIsPatternExpression(node, expression, pattern, flag, boundDecisionDag, whenTrueLabel, whenFalseLabel, boolType, hasErrors);
static bool? getConstantResult(BoundDecisionDag decisionDag, bool negated, LabelSymbol item, LabelSymbol item2)
{
if (!decisionDag.ReachableLabels.Contains(item))
{
return negated;
}
if (!decisionDag.ReachableLabels.Contains(item2))
{
return !negated;
}
return null;
}
}
private BoundExpression BindSwitchExpression(SwitchExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureRecursivePatterns.CheckFeatureAvailability(diagnostics, node.SwitchKeyword);
Binder binder = GetBinder((SyntaxNode)(object)node);
return binder.BindSwitchExpressionCore(node, binder, diagnostics);
}
internal virtual BoundExpression BindSwitchExpressionCore(SwitchExpressionSyntax node, Binder originalBinder, BindingDiagnosticBag diagnostics)
{
return Next.BindSwitchExpressionCore(node, originalBinder, diagnostics);
}
internal BoundPattern BindPattern(PatternSyntax node, TypeSymbol inputType, bool permitDesignations, bool hasErrors, BindingDiagnosticBag diagnostics, bool underIsPattern = false)
{
if (!(node is DiscardPatternSyntax node2))
{
if (!(node is DeclarationPatternSyntax node3))
{
if (!(node is ConstantPatternSyntax node4))
{
if (!(node is RecursivePatternSyntax node5))
{
if (!(node is VarPatternSyntax node6))
{
if (!(node is ParenthesizedPatternSyntax node7))
{
if (!(node is BinaryPatternSyntax node8))
{
if (!(node is UnaryPatternSyntax node9))
{
if (!(node is RelationalPatternSyntax node10))
{
if (!(node is TypePatternSyntax node11))
{
if (!(node is ListPatternSyntax node12))
{
if (node is SlicePatternSyntax node13)
{
return BindSlicePattern(node13, inputType, permitDesignations, ref hasErrors, misplaced: true, diagnostics);
}
throw ExceptionUtilities.UnexpectedValue((object)node.Kind());
}
return BindListPattern(node12, inputType, permitDesignations, hasErrors, diagnostics);
}
return BindTypePattern(node11, inputType, hasErrors, diagnostics);
}
return BindRelationalPattern(node10, inputType, hasErrors, diagnostics);
}
return BindUnaryPattern(node9, inputType, hasErrors, diagnostics, underIsPattern);
}
return BindBinaryPattern(node8, inputType, permitDesignations, hasErrors, diagnostics);
}
return BindParenthesizedPattern(node7, inputType, permitDesignations, hasErrors, diagnostics, underIsPattern);
}
return BindVarPattern(node6, inputType, permitDesignations, hasErrors, diagnostics);
}
return BindRecursivePattern(node5, inputType, permitDesignations, hasErrors, diagnostics);
}
return BindConstantPatternWithFallbackToTypePattern(node4, inputType, hasErrors, diagnostics);
}
return BindDeclarationPattern(node3, inputType, permitDesignations, hasErrors, diagnostics);
}
return BindDiscardPattern(node2, inputType, diagnostics);
}
private BoundPattern BindParenthesizedPattern(ParenthesizedPatternSyntax node, TypeSymbol inputType, bool permitDesignations, bool hasErrors, BindingDiagnosticBag diagnostics, bool underIsPattern)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureParenthesizedPattern.CheckFeatureAvailability(diagnostics, node.OpenParenToken);
return BindPattern(node.Pattern, inputType, permitDesignations, hasErrors, diagnostics, underIsPattern);
}
private BoundPattern BindSlicePattern(SlicePatternSyntax node, TypeSymbol inputType, bool permitDesignations, ref bool hasErrors, bool misplaced, BindingDiagnosticBag diagnostics)
{
if (misplaced && !hasErrors)
{
diagnostics.Add(ErrorCode.ERR_MisplacedSlicePattern, ((SyntaxNode)node).Location);
hasErrors = true;
}
BoundExpression boundExpression = null;
BoundPattern pattern = null;
BoundSlicePatternReceiverPlaceholder boundSlicePatternReceiverPlaceholder = null;
BoundSlicePatternRangePlaceholder boundSlicePatternRangePlaceholder = null;
if (node.Pattern != null)
{
boundSlicePatternReceiverPlaceholder = new BoundSlicePatternReceiverPlaceholder((SyntaxNode)(object)node, inputType)
{
WasCompilerGenerated = true
};
NamedTypeSymbol wellKnownType = GetWellKnownType((WellKnownType)285, diagnostics, (SyntaxNode)(object)node);
boundSlicePatternRangePlaceholder = new BoundSlicePatternRangePlaceholder((SyntaxNode)(object)node, wellKnownType)
{
WasCompilerGenerated = true
};
TypeSymbol inputType2;
if (inputType.IsErrorType())
{
hasErrors = true;
inputType2 = inputType;
}
else
{
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
instance.Arguments.Add((BoundExpression)boundSlicePatternRangePlaceholder);
boundExpression = BindElementAccessCore((SyntaxNode)(object)node, boundSlicePatternReceiverPlaceholder, instance, diagnostics).MakeCompilerGenerated();
boundExpression = CheckValue(boundExpression, BindValueKind.RValue, diagnostics);
instance.Free();
if (!wellKnownType.HasUseSiteError)
{
GetWellKnownTypeMember((WellKnownMember)419, diagnostics, null, (SyntaxNode)(object)node);
}
inputType2 = boundExpression.Type;
}
pattern = BindPattern(node.Pattern, inputType2, permitDesignations, hasErrors, diagnostics);
}
return new BoundSlicePattern((SyntaxNode)(object)node, pattern, boundExpression, boundSlicePatternReceiverPlaceholder, boundSlicePatternRangePlaceholder, inputType, inputType, hasErrors);
}
private ImmutableArray<BoundPattern> BindListPatternSubpatterns(SeparatedSyntaxList<PatternSyntax> subpatterns, TypeSymbol inputType, TypeSymbol elementType, bool permitDesignations, ref bool hasErrors, out bool sawSlice, BindingDiagnosticBag diagnostics)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
sawSlice = false;
ArrayBuilder<BoundPattern> instance = ArrayBuilder<BoundPattern>.GetInstance(subpatterns.Count);
Enumerator<PatternSyntax> enumerator = subpatterns.GetEnumerator();
while (enumerator.MoveNext())
{
PatternSyntax current = enumerator.Current;
BoundPattern boundPattern;
if (current is SlicePatternSyntax node)
{
boundPattern = BindSlicePattern(node, inputType, permitDesignations, ref hasErrors, sawSlice, diagnostics);
sawSlice = true;
}
else
{
boundPattern = BindPattern(current, elementType, permitDesignations, hasErrors, diagnostics);
}
instance.Add(boundPattern);
}
return instance.ToImmutableAndFree();
}
private BoundListPattern BindListPattern(ListPatternSyntax node, TypeSymbol inputType, bool permitDesignations, bool hasErrors, BindingDiagnosticBag diagnostics)
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureListPattern, diagnostics);
TypeSymbol typeSymbol = inputType.StrippedType();
if (inputType.IsDynamic())
{
Error(diagnostics, ErrorCode.ERR_UnsupportedTypeForListPattern, (CSharpSyntaxNode)node, new object[1] { inputType });
}
TypeSymbol elementType;
BoundExpression indexerAccess;
BoundExpression lengthAccess;
BoundListPatternReceiverPlaceholder receiverPlaceholder;
BoundListPatternIndexPlaceholder argumentPlaceholder;
if (inputType.IsErrorType() || inputType.IsDynamic())
{
hasErrors = true;
elementType = inputType;
indexerAccess = null;
lengthAccess = null;
receiverPlaceholder = null;
argumentPlaceholder = null;
}
else
{
hasErrors |= !BindLengthAndIndexerForListPattern((SyntaxNode)(object)node, typeSymbol, diagnostics, out indexerAccess, out lengthAccess, out receiverPlaceholder, out argumentPlaceholder);
elementType = indexerAccess.Type;
}
bool sawSlice;
ImmutableArray<BoundPattern> subpatterns = BindListPatternSubpatterns(node.Patterns, typeSymbol, elementType, permitDesignations, ref hasErrors, out sawSlice, diagnostics);
BindPatternDesignation(node.Designation, TypeWithAnnotations.Create(typeSymbol, NullableAnnotation.NotAnnotated), permitDesignations, null, diagnostics, ref hasErrors, out Symbol variableSymbol, out BoundExpression variableAccess);
return new BoundListPattern((SyntaxNode)(object)node, subpatterns, sawSlice, lengthAccess, indexerAccess, receiverPlaceholder, argumentPlaceholder, variableSymbol, variableAccess, inputType, typeSymbol, hasErrors);
}
private bool IsCountableAndIndexable(SyntaxNode node, TypeSymbol inputType, out PropertySymbol? lengthProperty)
{
BoundExpression indexerAccess;
BoundExpression lengthAccess;
BoundListPatternReceiverPlaceholder receiverPlaceholder;
BoundListPatternIndexPlaceholder argumentPlaceholder;
bool flag = BindLengthAndIndexerForListPattern(node, inputType, BindingDiagnosticBag.Discarded, out indexerAccess, out lengthAccess, out receiverPlaceholder, out argumentPlaceholder);
lengthProperty = (flag ? GetPropertySymbol(lengthAccess, out indexerAccess, out var _) : null);
return flag;
}
private bool BindLengthAndIndexerForListPattern(SyntaxNode node, TypeSymbol inputType, BindingDiagnosticBag diagnostics, out BoundExpression indexerAccess, out BoundExpression lengthAccess, out BoundListPatternReceiverPlaceholder? receiverPlaceholder, out BoundListPatternIndexPlaceholder argumentPlaceholder)
{
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
receiverPlaceholder = new BoundListPatternReceiverPlaceholder(node, inputType)
{
WasCompilerGenerated = true
};
if (inputType.IsSZArray())
{
flag |= !TryGetSpecialTypeMember<PropertySymbol>(Compilation, (SpecialMember)93, node, diagnostics, out var symbol);
if ((object)symbol != null)
{
lengthAccess = new BoundPropertyAccess(node, receiverPlaceholder, (ThreeState)1, symbol, LookupResultKind.Viable, symbol.Type)
{
WasCompilerGenerated = true
};
}
else
{
lengthAccess = new BoundBadExpression(node, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray<BoundExpression>.Empty, CreateErrorType(), hasErrors: true)
{
WasCompilerGenerated = true
};
}
}
else if (!TryBindLengthOrCount(node, receiverPlaceholder, out lengthAccess, diagnostics))
{
flag = true;
Error(diagnostics, ErrorCode.ERR_ListPatternRequiresLength, SyntaxNodeOrToken.op_Implicit(node), inputType);
}
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
NamedTypeSymbol wellKnownType = GetWellKnownType((WellKnownType)284, diagnostics, node);
argumentPlaceholder = new BoundListPatternIndexPlaceholder(node, wellKnownType)
{
WasCompilerGenerated = true
};
instance.Arguments.Add((BoundExpression)argumentPlaceholder);
indexerAccess = BindElementAccessCore(node, receiverPlaceholder, instance, diagnostics).MakeCompilerGenerated();
indexerAccess = CheckValue(indexerAccess, BindValueKind.RValue, diagnostics);
instance.Free();
if (!wellKnownType.HasUseSiteError)
{
GetWellKnownTypeMember((WellKnownMember)417, diagnostics, null, node);
}
if (!flag && !lengthAccess.HasErrors)
{
return !indexerAccess.HasErrors;
}
return false;
}
private static BoundPattern BindDiscardPattern(DiscardPatternSyntax node, TypeSymbol inputType, BindingDiagnosticBag diagnostics)
{
MessageID.IDS_FeatureRecursivePatterns.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)node);
return new BoundDiscardPattern((SyntaxNode)(object)node, inputType, inputType);
}
private BoundPattern BindConstantPatternWithFallbackToTypePattern(ConstantPatternSyntax node, TypeSymbol inputType, bool hasErrors, BindingDiagnosticBag diagnostics)
{
return BindConstantPatternWithFallbackToTypePattern((SyntaxNode)(object)node, node.Expression, inputType, hasErrors, diagnostics);
}
internal BoundPattern BindConstantPatternWithFallbackToTypePattern(SyntaxNode node, ExpressionSyntax expression, TypeSymbol inputType, bool hasErrors, BindingDiagnosticBag diagnostics)
{
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Invalid comparison between Unknown and I4
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Invalid comparison between Unknown and I4
ExpressionSyntax expressionSyntax = SkipParensAndNullSuppressions(expression, diagnostics, ref hasErrors);
ConstantValue constantValueOpt;
bool wasExpression;
Conversion patternExpressionConversion;
BoundExpression boundExpression = BindExpressionOrTypeForPattern(inputType, expressionSyntax, ref hasErrors, diagnostics, out constantValueOpt, out wasExpression, out patternExpressionConversion);
if (wasExpression)
{
TypeSymbol typeSymbol = boundExpression.Type ?? inputType;
if ((int)typeSymbol.SpecialType == 20 && inputType.IsSpanOrReadOnlySpanChar())
{
typeSymbol = inputType;
}
if (constantValueOpt != null && constantValueOpt.IsNumeric && ShouldBlockINumberBaseConversion(patternExpressionConversion, inputType))
{
diagnostics.Add(ErrorCode.ERR_CannotMatchOnINumberBase, node.Location, inputType);
}
return new BoundConstantPattern(node, boundExpression, constantValueOpt ?? ConstantValue.Bad, inputType, typeSymbol, hasErrors || constantValueOpt == null);
}
if (!hasErrors)
{
CheckFeatureAvailability((SyntaxNode)(object)expressionSyntax, MessageID.IDS_FeatureTypePattern, diagnostics);
}
BoundTypeExpression boundTypeExpression = (BoundTypeExpression)boundExpression;
bool isExplicitNotNullTest = (int)boundTypeExpression.Type.SpecialType == 1;
return new BoundTypePattern(node, boundTypeExpression, isExplicitNotNullTest, inputType, boundTypeExpression.Type, hasErrors);
}
private bool ShouldBlockINumberBaseConversion(Conversion patternConversion, TypeSymbol inputType)
{
if (patternConversion.IsIdentity || patternConversion.IsConstantExpression || patternConversion.IsNumeric)
{
return false;
}
if (!ImmutableArrayExtensions.Any<NamedTypeSymbol, int>((inputType is TypeParameterSymbol typeParameterSymbol) ? typeParameterSymbol.EffectiveInterfacesNoUseSiteDiagnostics : inputType.AllInterfacesNoUseSiteDiagnostics, (Func<NamedTypeSymbol, int, bool>)((NamedTypeSymbol i, int _) => i.IsWellKnownINumberBaseType()), 0))
{
return inputType.IsWellKnownINumberBaseType();
}
return true;
}
private static ExpressionSyntax SkipParensAndNullSuppressions(ExpressionSyntax e, BindingDiagnosticBag diagnostics, ref bool hasErrors)
{
while (true)
{
switch (e.Kind())
{
case SyntaxKind.DefaultLiteralExpression:
diagnostics.Add(ErrorCode.ERR_DefaultPattern, ((SyntaxNode)e).Location);
hasErrors = true;
return e;
case SyntaxKind.ParenthesizedExpression:
e = ((ParenthesizedExpressionSyntax)e).Expression;
break;
case SyntaxKind.SuppressNullableWarningExpression:
diagnostics.Add(ErrorCode.ERR_IllegalSuppression, ((SyntaxNode)e).Location);
hasErrors = true;
e = ((PostfixUnaryExpressionSyntax)e).Operand;
break;
default:
return e;
}
}
}
private BoundExpression BindExpressionOrTypeForPattern(TypeSymbol inputType, ExpressionSyntax patternExpression, ref bool hasErrors, BindingDiagnosticBag diagnostics, out ConstantValue? constantValueOpt, out bool wasExpression, out Conversion patternExpressionConversion)
{
constantValueOpt = null;
BoundExpression boundExpression = BindTypeOrRValue(patternExpression, diagnostics);
wasExpression = boundExpression.Kind != BoundKind.TypeExpression;
if (wasExpression)
{
return BindExpressionForPatternContinued(boundExpression, inputType, patternExpression, ref hasErrors, diagnostics, out constantValueOpt, out patternExpressionConversion);
}
hasErrors |= CheckValidPatternType((SyntaxNode)(object)patternExpression, inputType, boundExpression.Type, diagnostics);
patternExpressionConversion = Conversion.NoConversion;
return boundExpression;
}
private BoundExpression BindExpressionForPattern(TypeSymbol inputType, ExpressionSyntax patternExpression, ref bool hasErrors, BindingDiagnosticBag diagnostics, out ConstantValue? constantValueOpt, out bool wasExpression, out Conversion patternExpressionConversion)
{
constantValueOpt = null;
BoundExpression expr = BindExpression(patternExpression, diagnostics, invoked: false, indexed: false);
expr = CheckValue(expr, BindValueKind.RValue, diagnostics);
wasExpression = expr.Kind switch
{
BoundKind.BadExpression => false,
BoundKind.TypeExpression => false,
_ => true,
};
patternExpressionConversion = Conversion.NoConversion;
if (!wasExpression)
{
return expr;
}
return BindExpressionForPatternContinued(expr, inputType, patternExpression, ref hasErrors, diagnostics, out constantValueOpt, out patternExpressionConversion);
}
private BoundExpression BindExpressionForPatternContinued(BoundExpression expression, TypeSymbol inputType, ExpressionSyntax patternExpression, ref bool hasErrors, BindingDiagnosticBag diagnostics, out ConstantValue? constantValueOpt, out Conversion patternExpressionConversion)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Invalid comparison between Unknown and I4
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Invalid comparison between Unknown and I4
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Invalid comparison between Unknown and I4
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Invalid comparison between Unknown and I4
BoundExpression boundExpression = ConvertPatternExpression(inputType, patternExpression, expression, out constantValueOpt, hasErrors, diagnostics, out patternExpressionConversion);
ConstantValueUtils.CheckLangVersionForConstantValue(boundExpression, diagnostics);
if (!boundExpression.HasErrors && !hasErrors)
{
if (constantValueOpt == (ConstantValue)null)
{
TypeSymbol typeSymbol = inputType.StrippedType();
SymbolKind kind = typeSymbol.Kind;
if ((int)kind != 4 && (int)kind != 3 && (int)kind != 17)
{
SpecialType specialType = typeSymbol.SpecialType;
if ((int)specialType != 1 && (int)specialType != 5)
{
diagnostics.Add(ErrorCode.ERR_ConstantValueOfTypeExpected, ((SyntaxNode)patternExpression).Location, typeSymbol);
goto IL_0095;
}
}
diagnostics.Add(ErrorCode.ERR_ConstantExpected, ((SyntaxNode)patternExpression).Location);
goto IL_0095;
}
if (inputType.IsPointerType())
{
CheckFeatureAvailability((SyntaxNode)(object)patternExpression, MessageID.IDS_FeatureNullPointerConstantPattern, diagnostics);
}
}
goto IL_00b2;
IL_0095:
hasErrors = true;
goto IL_00b2;
IL_00b2:
if ((object)boundExpression.Type == null && constantValueOpt != ConstantValue.Null)
{
boundExpression = BindToTypeForErrorRecovery(boundExpression);
}
return boundExpression;
}
internal BoundExpression ConvertPatternExpression(TypeSymbol inputType, CSharpSyntaxNode node, BoundExpression expression, out ConstantValue? constantValue, bool hasErrors, BindingDiagnosticBag diagnostics, out Conversion patternExpressionConversion)
{
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Invalid comparison between Unknown and I4
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
BoundExpression boundExpression;
BoundExpression operand;
if (inputType.ContainsTypeParameter())
{
boundExpression = expression;
if (!hasErrors && expression.ConstantValueOpt != null)
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
if (expression.ConstantValueOpt == ConstantValue.Null)
{
if (inputType.IsNonNullableValueType() && !inputType.IsPointerOrFunctionPointer())
{
diagnostics.Add(ErrorCode.ERR_ValueCantBeNull, expression.Syntax.Location, inputType);
hasErrors = true;
}
}
else
{
Conversion conversion;
ConstantValue val = ExpressionOfTypeMatchesPatternType(Conversions, inputType, expression.Type, ref useSiteInfo, out conversion);
if (val == ConstantValue.False || val == ConstantValue.Bad)
{
diagnostics.Add(ErrorCode.ERR_PatternWrongType, expression.Syntax.Location, inputType, expression.Display);
hasErrors = true;
}
}
if (!hasErrors)
{
LanguageVersion languageVersion = MessageID.IDS_FeatureRecursivePatterns.RequiredVersion();
patternExpressionConversion = Conversions.ClassifyConversionFromExpression(expression, inputType, CheckOverflowAtRuntime, ref useSiteInfo);
if (Compilation.LanguageVersion < languageVersion && !patternExpressionConversion.IsImplicit)
{
diagnostics.Add(ErrorCode.ERR_ConstantPatternVsOpenType, expression.Syntax.Location, inputType, expression.Display, new CSharpRequiredLanguageVersion(languageVersion));
}
}
else
{
patternExpressionConversion = Conversion.NoConversion;
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
}
else
{
patternExpressionConversion = Conversion.NoConversion;
}
}
else
{
TypeSymbol? type = expression.Type;
if ((object)type != null && (int)type.SpecialType == 20 && inputType.IsSpanOrReadOnlySpanChar())
{
if (MessageID.IDS_FeatureSpanCharConstantPattern.CheckFeatureAvailability(diagnostics, (Compilation)(object)Compilation, ((SyntaxNode)node).Location))
{
bool flag = inputType.IsReadOnlySpanChar();
GetWellKnownTypeMember((WellKnownMember)(flag ? 474 : 473), diagnostics, null, (SyntaxNode)(object)node);
GetWellKnownTypeMember((WellKnownMember)475, diagnostics, null, (SyntaxNode)(object)node);
GetWellKnownTypeMember((WellKnownMember)(flag ? 407 : 401), diagnostics, null, (SyntaxNode)(object)node);
}
boundExpression = BindToNaturalType(expression, diagnostics);
constantValue = boundExpression.ConstantValueOpt;
if (constantValue == ConstantValue.Null)
{
diagnostics.Add(ErrorCode.ERR_PatternSpanCharCannotBeStringNull, boundExpression.Syntax.Location, inputType);
}
patternExpressionConversion = Conversion.NoConversion;
return boundExpression;
}
boundExpression = GenerateConversionForAssignment(inputType, expression, diagnostics, out patternExpressionConversion);
if (boundExpression.Kind == BoundKind.Conversion)
{
BoundConversion boundConversion = (BoundConversion)boundExpression;
operand = boundConversion.Operand;
if (inputType.IsNullableType() && (boundExpression.ConstantValueOpt == (ConstantValue)null || !boundExpression.ConstantValueOpt.IsNull))
{
boundExpression = CreateConversion(operand, inputType.GetNullableUnderlyingType(), BindingDiagnosticBag.Discarded);
}
else if ((boundConversion.ConversionKind == ConversionKind.Boxing || boundConversion.ConversionKind == ConversionKind.ImplicitReference) && operand.ConstantValueOpt != (ConstantValue)null && boundExpression.ConstantValueOpt == (ConstantValue)null)
{
boundExpression = operand;
}
else
{
if (boundConversion.ConversionKind == ConversionKind.ImplicitNullToPointer)
{
goto IL_0328;
}
if (boundConversion.ConversionKind == ConversionKind.NoConversion)
{
TypeSymbol? type2 = boundExpression.Type;
if ((object)type2 != null && type2.IsErrorType())
{
goto IL_0328;
}
}
}
}
}
goto IL_032b;
IL_0328:
boundExpression = operand;
goto IL_032b;
IL_032b:
constantValue = boundExpression.ConstantValueOpt;
return boundExpression;
}
private bool CheckValidPatternType(SyntaxNode typeSyntax, TypeSymbol inputType, TypeSymbol patternType, BindingDiagnosticBag diagnostics)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
if (inputType.IsErrorType() || patternType.IsErrorType())
{
return false;
}
if (inputType.IsPointerOrFunctionPointer() || patternType.IsPointerOrFunctionPointer())
{
diagnostics.Add(ErrorCode.ERR_PointerTypeInPatternMatching, typeSyntax.Location);
return true;
}
if (patternType.IsNullableType())
{
Error(diagnostics, ErrorCode.ERR_PatternNullableType, SyntaxNodeOrToken.op_Implicit(typeSyntax), patternType.GetNullableUnderlyingType());
return true;
}
if (typeSyntax is NullableTypeSyntax)
{
Error(diagnostics, ErrorCode.ERR_PatternNullableType, SyntaxNodeOrToken.op_Implicit(typeSyntax), patternType);
return true;
}
if (patternType.IsStatic)
{
Error(diagnostics, ErrorCode.ERR_VarDeclIsStaticClass, SyntaxNodeOrToken.op_Implicit(typeSyntax), patternType);
return true;
}
if (patternType.IsDynamic())
{
Error(diagnostics, ErrorCode.ERR_PatternDynamicType, SyntaxNodeOrToken.op_Implicit(typeSyntax));
return true;
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion;
ConstantValue val = ExpressionOfTypeMatchesPatternType(Conversions, inputType, patternType, ref useSiteInfo, out conversion, null, operandCouldBeNull: true);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(typeSyntax, useSiteInfo);
if (val != ConstantValue.False && val != ConstantValue.Bad)
{
if (!conversion.Exists && (inputType.ContainsTypeParameter() || patternType.ContainsTypeParameter()))
{
LanguageVersion languageVersion = MessageID.IDS_FeatureGenericPatternMatching.RequiredVersion();
if (languageVersion > Compilation.LanguageVersion)
{
Error(diagnostics, ErrorCode.ERR_PatternWrongGenericTypeInVersion, SyntaxNodeOrToken.op_Implicit(typeSyntax), inputType, patternType, Compilation.LanguageVersion.ToDisplayString(), new CSharpRequiredLanguageVersion(languageVersion));
return true;
}
}
return false;
}
Error(diagnostics, ErrorCode.ERR_PatternWrongType, SyntaxNodeOrToken.op_Implicit(typeSyntax), inputType, patternType);
return true;
}
internal static ConstantValue ExpressionOfTypeMatchesPatternType(Conversions conversions, TypeSymbol expressionType, TypeSymbol patternType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out Conversion conversion, ConstantValue? operandConstantValue = null, bool operandCouldBeNull = false)
{
if (expressionType.Equals(patternType, (TypeCompareKind)63))
{
conversion = Conversion.Identity;
return ConstantValue.True;
}
if (expressionType.IsDynamic())
{
expressionType = conversions.CorLibrary.GetSpecialType((SpecialType)1);
}
conversion = conversions.ClassifyBuiltInConversion(expressionType, patternType, isChecked: false, ref useSiteInfo);
return GetIsOperatorConstantResult(expressionType, patternType, conversion.Kind, operandConstantValue, operandCouldBeNull);
}
private BoundPattern BindDeclarationPattern(DeclarationPatternSyntax node, TypeSymbol inputType, bool permitDesignations, bool hasErrors, BindingDiagnosticBag diagnostics)
{
TypeSyntax type = node.Type;
BoundTypeExpression boundTypeExpression = BindTypeForPattern(type, inputType, diagnostics, ref hasErrors);
BindPatternDesignation(node.Designation, boundTypeExpression.TypeWithAnnotations, permitDesignations, type, diagnostics, ref hasErrors, out Symbol variableSymbol, out BoundExpression variableAccess);
return new BoundDeclarationPattern((SyntaxNode)(object)node, boundTypeExpression, isVar: false, variableSymbol, variableAccess, inputType, boundTypeExpression.Type, hasErrors);
}
private BoundTypeExpression BindTypeForPattern(TypeSyntax typeSyntax, TypeSymbol inputType, BindingDiagnosticBag diagnostics, ref bool hasErrors)
{
AliasSymbol alias;
TypeWithAnnotations typeWithAnnotations = BindType(typeSyntax, diagnostics, out alias);
BoundTypeExpression result = new BoundTypeExpression((SyntaxNode)(object)typeSyntax, alias, typeWithAnnotations);
hasErrors |= CheckValidPatternType((SyntaxNode)(object)typeSyntax, inputType, typeWithAnnotations.Type, diagnostics);
return result;
}
private void BindPatternDesignation(VariableDesignationSyntax? designation, TypeWithAnnotations declType, bool permitDesignations, TypeSyntax? typeSyntax, BindingDiagnosticBag diagnostics, ref bool hasErrors, out Symbol? variableSymbol, out BoundExpression? variableAccess)
{
//IL_0021: 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)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Invalid comparison between Unknown and I4
if (!(designation is SingleVariableDesignationSyntax { Identifier: var identifier } singleVariableDesignationSyntax))
{
if (designation is DiscardDesignationSyntax || designation == null)
{
variableSymbol = null;
variableAccess = null;
return;
}
throw ExceptionUtilities.UnexpectedValue((object)designation.Kind());
}
SourceLocalSymbol sourceLocalSymbol = LookupLocal(identifier);
if (!permitDesignations && !((SyntaxToken)(ref identifier)).IsMissing)
{
diagnostics.Add(ErrorCode.ERR_DesignatorBeneathPatternCombinator, ((SyntaxToken)(ref identifier)).GetLocation());
}
if ((object)sourceLocalSymbol != null)
{
if ((InConstructorInitializer || InFieldInitializer) && (int)ContainingMemberOrLambda.ContainingSymbol.Kind == 11)
{
CheckFeatureAvailability((SyntaxNode)(object)designation, MessageID.IDS_FeatureExpressionVariablesInQueriesAndInitializers, diagnostics);
}
sourceLocalSymbol.SetTypeWithAnnotations(declType);
hasErrors |= sourceLocalSymbol.ScopeBinder.ValidateDeclarationNameConflictsInScope(sourceLocalSymbol, diagnostics);
if (!hasErrors)
{
CheckRestrictedTypeInAsyncMethod(ContainingMemberOrLambda, declType.Type, diagnostics, (SyntaxNode)(((object)typeSyntax) ?? ((object)designation)));
}
variableSymbol = sourceLocalSymbol;
variableAccess = new BoundLocal((SyntaxNode)(object)designation, sourceLocalSymbol, (!sourceLocalSymbol.IsVar) ? BoundLocalDeclarationKind.WithExplicitType : BoundLocalDeclarationKind.WithInferredType, null, isNullableUnknown: false, declType.Type);
}
else
{
GlobalExpressionVariable globalExpressionVariable = LookupDeclaredField(singleVariableDesignationSyntax);
globalExpressionVariable.SetTypeWithAnnotations(declType, BindingDiagnosticBag.Discarded);
BoundExpression receiver = SynthesizeReceiver((SyntaxNode)(object)designation, globalExpressionVariable, diagnostics);
variableSymbol = globalExpressionVariable;
variableAccess = new BoundFieldAccess((SyntaxNode)(object)designation, receiver, globalExpressionVariable, null, hasErrors);
}
}
private TypeWithAnnotations BindRecursivePatternType(TypeSyntax? typeSyntax, TypeSymbol inputType, BindingDiagnosticBag diagnostics, ref bool hasErrors, out BoundTypeExpression? boundDeclType)
{
if (typeSyntax != null)
{
boundDeclType = BindTypeForPattern(typeSyntax, inputType, diagnostics, ref hasErrors);
return boundDeclType.TypeWithAnnotations;
}
boundDeclType = null;
return TypeWithAnnotations.Create(inputType.StrippedType(), NullableAnnotation.NotAnnotated);
}
internal static bool IsZeroElementTupleType(TypeSymbol type)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Invalid comparison between Unknown and I4
if (type.IsStructType() && type.Name == "ValueTuple" && type.GetArity() == 0)
{
Symbol containingSymbol = type.ContainingSymbol;
if ((int)containingSymbol.Kind == 12 && containingSymbol.Name == "System")
{
return (containingSymbol.ContainingSymbol as NamespaceSymbol)?.IsGlobalNamespace ?? false;
}
}
return false;
}
private BoundPattern BindRecursivePattern(RecursivePatternSyntax node, TypeSymbol inputType, bool permitDesignations, bool hasErrors, BindingDiagnosticBag diagnostics)
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureRecursivePatterns.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)node);
if (inputType.IsPointerOrFunctionPointer())
{
diagnostics.Add(ErrorCode.ERR_PointerTypeInPatternMatching, ((SyntaxNode)node).Location);
hasErrors = true;
inputType = CreateErrorType();
}
TypeSyntax type = node.Type;
BoundTypeExpression boundDeclType;
TypeWithAnnotations declType = BindRecursivePatternType(type, inputType, diagnostics, ref hasErrors, out boundDeclType);
TypeSymbol type2 = declType.Type;
MethodSymbol methodSymbol = null;
ImmutableArray<BoundPositionalSubpattern> deconstruction = default(ImmutableArray<BoundPositionalSubpattern>);
if (node.PositionalPatternClause != null)
{
PositionalPatternClauseSyntax positionalPatternClause = node.PositionalPatternClause;
ArrayBuilder<BoundPositionalSubpattern> instance = ArrayBuilder<BoundPositionalSubpattern>.GetInstance(positionalPatternClause.Subpatterns.Count);
if (IsZeroElementTupleType(type2))
{
BindValueTupleSubpatterns(positionalPatternClause, type2, ImmutableArray<TypeWithAnnotations>.Empty, permitDesignations, ref hasErrors, instance, diagnostics);
}
else if (type2.IsTupleType)
{
BindValueTupleSubpatterns(positionalPatternClause, type2, type2.TupleElementTypesWithAnnotations, permitDesignations, ref hasErrors, instance, diagnostics);
}
else
{
BoundImplicitReceiver receiver = new BoundImplicitReceiver((SyntaxNode)(object)positionalPatternClause, type2);
BindingDiagnosticBag instance2 = BindingDiagnosticBag.GetInstance(diagnostics);
ImmutableArray<BoundDeconstructValuePlaceholder> outPlaceholders;
bool anyApplicableCandidates;
BoundExpression deconstruct = MakeDeconstructInvocationExpression(positionalPatternClause.Subpatterns.Count, receiver, (SyntaxNode)(object)positionalPatternClause, instance2, out outPlaceholders, out anyApplicableCandidates);
if (!anyApplicableCandidates && ShouldUseITupleForRecursivePattern(node, type2, diagnostics, out NamedTypeSymbol iTupleType, out MethodSymbol iTupleGetLength, out MethodSymbol iTupleGetItem))
{
((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).Free();
BindITupleSubpatterns(positionalPatternClause, instance, permitDesignations, diagnostics);
deconstruction = instance.ToImmutableAndFree();
return new BoundITuplePattern((SyntaxNode)(object)node, iTupleGetLength, iTupleGetItem, deconstruction, inputType, iTupleType, hasErrors);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRangeAndFree((BindingDiagnosticBag<AssemblySymbol>)(object)instance2);
methodSymbol = BindDeconstructSubpatterns(positionalPatternClause, permitDesignations, deconstruct, outPlaceholders, instance, ref hasErrors, diagnostics);
}
deconstruction = instance.ToImmutableAndFree();
}
ImmutableArray<BoundPropertySubpattern> properties = default(ImmutableArray<BoundPropertySubpattern>);
if (node.PropertyPatternClause != null)
{
properties = BindPropertyPatternClause(node.PropertyPatternClause, type2, permitDesignations, diagnostics, ref hasErrors);
}
BindPatternDesignation(node.Designation, declType, permitDesignations, type, diagnostics, ref hasErrors, out Symbol variableSymbol, out BoundExpression variableAccess);
bool isExplicitNotNullTest = node.Designation == null && boundDeclType == null && properties.IsDefaultOrEmpty && (object)methodSymbol == null && deconstruction.IsDefault;
return new BoundRecursivePattern((SyntaxNode)(object)node, boundDeclType, methodSymbol, deconstruction, properties, isExplicitNotNullTest, variableSymbol, variableAccess, inputType, boundDeclType?.Type ?? inputType.StrippedType(), hasErrors);
}
private MethodSymbol? BindDeconstructSubpatterns(PositionalPatternClauseSyntax node, bool permitDesignations, BoundExpression deconstruct, ImmutableArray<BoundDeconstructValuePlaceholder> outPlaceholders, ArrayBuilder<BoundPositionalSubpattern> patterns, ref bool hasErrors, BindingDiagnosticBag diagnostics)
{
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
MethodSymbol methodSymbol = deconstruct.ExpressionSymbol as MethodSymbol;
if ((object)methodSymbol == null)
{
hasErrors = true;
}
int num = ((methodSymbol?.IsExtensionMethod ?? false) ? 1 : 0);
for (int i = 0; i < node.Subpatterns.Count; i++)
{
SubpatternSyntax subpatternSyntax = node.Subpatterns[i];
bool flag = hasErrors || outPlaceholders.IsDefaultOrEmpty || i >= outPlaceholders.Length;
TypeSymbol inputType = (flag ? CreateErrorType() : outPlaceholders[i].Type);
ParameterSymbol parameterSymbol = null;
if (!flag)
{
int num2 = i + num;
if (num2 < methodSymbol.ParameterCount)
{
parameterSymbol = methodSymbol.Parameters[num2];
}
if (subpatternSyntax.NameColon != null)
{
if ((object)parameterSymbol != null)
{
SyntaxToken identifier = subpatternSyntax.NameColon.Name.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
string name = parameterSymbol.Name;
if (valueText != name)
{
diagnostics.Add(ErrorCode.ERR_DeconstructParameterNameMismatch, ((SyntaxNode)subpatternSyntax.NameColon.Name).Location, valueText, name);
}
}
}
else if (subpatternSyntax.ExpressionColon != null)
{
MessageID.IDS_FeatureExtendedPropertyPatterns.CheckFeatureAvailability(diagnostics, subpatternSyntax.ExpressionColon.ColonToken);
diagnostics.Add(ErrorCode.ERR_IdentifierExpected, ((SyntaxNode)subpatternSyntax.ExpressionColon.Expression).Location);
}
}
BoundPositionalSubpattern boundPositionalSubpattern = new BoundPositionalSubpattern((SyntaxNode)(object)subpatternSyntax, parameterSymbol, BindPattern(subpatternSyntax.Pattern, inputType, permitDesignations, flag, diagnostics));
patterns.Add(boundPositionalSubpattern);
}
return methodSymbol;
}
private void BindITupleSubpatterns(PositionalPatternClauseSyntax node, ArrayBuilder<BoundPositionalSubpattern> patterns, bool permitDesignations, BindingDiagnosticBag diagnostics)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol specialType = Compilation.GetSpecialType((SpecialType)1);
Enumerator<SubpatternSyntax> enumerator = node.Subpatterns.GetEnumerator();
while (enumerator.MoveNext())
{
SubpatternSyntax current = enumerator.Current;
if (current.NameColon != null)
{
diagnostics.Add(ErrorCode.ERR_ArgumentNameInITuplePattern, ((SyntaxNode)current.NameColon).Location);
}
else if (current.ExpressionColon != null)
{
diagnostics.Add(ErrorCode.ERR_IdentifierExpected, ((SyntaxNode)current.ExpressionColon.Expression).Location);
}
BoundPositionalSubpattern boundPositionalSubpattern = new BoundPositionalSubpattern((SyntaxNode)(object)current, null, BindPattern(current.Pattern, specialType, permitDesignations, hasErrors: false, diagnostics));
patterns.Add(boundPositionalSubpattern);
}
}
private void BindITupleSubpatterns(ParenthesizedVariableDesignationSyntax node, ArrayBuilder<BoundPositionalSubpattern> patterns, bool permitDesignations, BindingDiagnosticBag diagnostics)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol specialType = Compilation.GetSpecialType((SpecialType)1);
Enumerator<VariableDesignationSyntax> enumerator = node.Variables.GetEnumerator();
while (enumerator.MoveNext())
{
VariableDesignationSyntax current = enumerator.Current;
BoundPattern pattern = BindVarDesignation(current, specialType, permitDesignations, hasErrors: false, diagnostics);
BoundPositionalSubpattern boundPositionalSubpattern = new BoundPositionalSubpattern((SyntaxNode)(object)current, null, pattern);
patterns.Add(boundPositionalSubpattern);
}
}
private void BindValueTupleSubpatterns(PositionalPatternClauseSyntax node, TypeSymbol declType, ImmutableArray<TypeWithAnnotations> elementTypesWithAnnotations, bool permitDesignations, ref bool hasErrors, ArrayBuilder<BoundPositionalSubpattern> patterns, BindingDiagnosticBag diagnostics)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
if (elementTypesWithAnnotations.Length != node.Subpatterns.Count && !hasErrors)
{
diagnostics.Add(ErrorCode.ERR_WrongNumberOfSubpatterns, ((SyntaxNode)node).Location, declType, elementTypesWithAnnotations.Length, node.Subpatterns.Count);
hasErrors = true;
}
for (int i = 0; i < node.Subpatterns.Count; i++)
{
SubpatternSyntax subpatternSyntax = node.Subpatterns[i];
bool flag = i >= elementTypesWithAnnotations.Length;
TypeSymbol inputType = (flag ? CreateErrorType() : elementTypesWithAnnotations[i].Type);
FieldSymbol symbol = null;
if (!flag)
{
if (subpatternSyntax.NameColon != null)
{
SyntaxToken identifier = subpatternSyntax.NameColon.Name.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
symbol = CheckIsTupleElement((SyntaxNode)(object)subpatternSyntax.NameColon.Name, (NamedTypeSymbol)declType, valueText, i, diagnostics);
}
else if (subpatternSyntax.ExpressionColon != null)
{
diagnostics.Add(ErrorCode.ERR_IdentifierExpected, ((SyntaxNode)subpatternSyntax.ExpressionColon.Expression).Location);
}
}
BoundPositionalSubpattern boundPositionalSubpattern = new BoundPositionalSubpattern((SyntaxNode)(object)subpatternSyntax, symbol, BindPattern(subpatternSyntax.Pattern, inputType, permitDesignations, flag, diagnostics));
patterns.Add(boundPositionalSubpattern);
}
}
private bool ShouldUseITupleForRecursivePattern(RecursivePatternSyntax node, TypeSymbol declType, BindingDiagnosticBag diagnostics, [NotNullWhen(true)] out NamedTypeSymbol? iTupleType, [NotNullWhen(true)] out MethodSymbol? iTupleGetLength, [NotNullWhen(true)] out MethodSymbol? iTupleGetItem)
{
iTupleType = null;
iTupleGetLength = (iTupleGetItem = null);
if (node.Type != null)
{
return false;
}
if (node.PropertyPatternClause != null)
{
return false;
}
if (node.PositionalPatternClause == null)
{
return false;
}
VariableDesignationSyntax? designation = node.Designation;
if (designation != null && designation.Kind() == SyntaxKind.SingleVariableDesignation)
{
return false;
}
return ShouldUseITuple((SyntaxNode)(object)node, declType, diagnostics, out iTupleType, out iTupleGetLength, out iTupleGetItem);
}
private bool ShouldUseITuple(SyntaxNode node, TypeSymbol declType, BindingDiagnosticBag diagnostics, [NotNullWhen(true)] out NamedTypeSymbol? iTupleType, [NotNullWhen(true)] out MethodSymbol? iTupleGetLength, [NotNullWhen(true)] out MethodSymbol? iTupleGetItem)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Invalid comparison between Unknown and I4
iTupleType = null;
iTupleGetLength = (iTupleGetItem = null);
if (Compilation.LanguageVersion < MessageID.IDS_FeatureRecursivePatterns.RequiredVersion())
{
return false;
}
iTupleType = Compilation.GetWellKnownType((WellKnownType)283);
if ((int)iTupleType.TypeKind != 7)
{
return false;
}
if ((object)declType != Compilation.GetSpecialType((SpecialType)1) && (object)declType != Compilation.DynamicType && (object)declType != iTupleType && !hasBaseInterface(declType, iTupleType))
{
return false;
}
iTupleGetLength = (MethodSymbol)Compilation.GetWellKnownTypeMember((WellKnownMember)452);
iTupleGetItem = (MethodSymbol)Compilation.GetWellKnownTypeMember((WellKnownMember)451);
if ((object)iTupleGetLength == null || (object)iTupleGetItem == null)
{
return false;
}
if (diagnostics.ReportUseSite(iTupleType, node) || diagnostics.ReportUseSite(iTupleGetLength, node))
{
_ = 1;
}
else
diagnostics.ReportUseSite(iTupleGetItem, node);
return true;
bool hasBaseInterface(TypeSymbol type, NamedTypeSymbol possibleBaseInterface)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
bool isImplicit = Compilation.Conversions.ClassifyBuiltInConversion(type, possibleBaseInterface, CheckOverflowAtRuntime, ref useSiteInfo).IsImplicit;
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(node, useSiteInfo);
return isImplicit;
}
}
private static FieldSymbol? CheckIsTupleElement(SyntaxNode node, NamedTypeSymbol tupleType, string name, int tupleIndex, BindingDiagnosticBag diagnostics)
{
FieldSymbol fieldSymbol = null;
ImmutableArray<Symbol>.Enumerator enumerator = tupleType.GetMembers(name).GetEnumerator();
while (enumerator.MoveNext())
{
if (enumerator.Current is FieldSymbol fieldSymbol2 && fieldSymbol2.IsTupleElement())
{
fieldSymbol = fieldSymbol2;
break;
}
}
if ((object)fieldSymbol == null || fieldSymbol.TupleElementIndex != tupleIndex)
{
diagnostics.Add(ErrorCode.ERR_TupleElementNameMismatch, node.Location, name, $"Item{tupleIndex + 1}");
}
return fieldSymbol;
}
private BoundPattern BindVarPattern(VarPatternSyntax node, TypeSymbol inputType, bool permitDesignations, bool hasErrors, BindingDiagnosticBag diagnostics)
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
if ((inputType.IsPointerOrFunctionPointer() && node.Designation.Kind() == SyntaxKind.ParenthesizedVariableDesignation) || (inputType.IsPointerType() && Compilation.LanguageVersion < MessageID.IDS_FeatureRecursivePatterns.RequiredVersion()))
{
diagnostics.Add(ErrorCode.ERR_PointerTypeInPatternMatching, ((SyntaxNode)node).Location);
hasErrors = true;
inputType = CreateErrorType();
}
bool isKeyword;
Symbol symbol = BindTypeOrAliasOrKeyword(node.VarKeyword, (SyntaxNode)(object)node, diagnostics, out isKeyword).Symbol;
if (!isKeyword)
{
SyntaxToken varKeyword = node.VarKeyword;
diagnostics.Add(ErrorCode.ERR_VarMayNotBindToType, ((SyntaxToken)(ref varKeyword)).GetLocation(), symbol.ToDisplayString());
hasErrors = true;
}
return BindVarDesignation(node.Designation, inputType, permitDesignations, hasErrors, diagnostics);
}
private BoundPattern BindVarDesignation(VariableDesignationSyntax node, TypeSymbol inputType, bool permitDesignations, bool hasErrors, BindingDiagnosticBag diagnostics)
{
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
switch (node.Kind())
{
case SyntaxKind.DiscardDesignation:
return new BoundDiscardPattern((SyntaxNode)(object)node, inputType, inputType);
case SyntaxKind.SingleVariableDesignation:
{
TypeWithAnnotations typeWithAnnotations = TypeWithState.ForType(inputType).ToTypeWithAnnotations(Compilation);
BindPatternDesignation(node, typeWithAnnotations, permitDesignations, null, diagnostics, ref hasErrors, out Symbol variableSymbol, out BoundExpression variableAccess);
BoundTypeExpression declaredType = new BoundTypeExpression((SyntaxNode)(object)node, null, typeWithAnnotations);
return new BoundDeclarationPattern((SyntaxNode)(object)((node.Parent.Kind() == SyntaxKind.VarPattern) ? node.Parent : node), declaredType, isVar: true, variableSymbol, variableAccess, inputType, inputType, hasErrors);
}
case SyntaxKind.ParenthesizedVariableDesignation:
{
MessageID.IDS_FeatureRecursivePatterns.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)node);
ParenthesizedVariableDesignationSyntax tupleDesignation = (ParenthesizedVariableDesignationSyntax)node;
ArrayBuilder<BoundPositionalSubpattern> subPatterns = ArrayBuilder<BoundPositionalSubpattern>.GetInstance(tupleDesignation.Variables.Count);
MethodSymbol deconstructMethod = null;
TypeSymbol strippedInputType = inputType.StrippedType();
if (IsZeroElementTupleType(strippedInputType))
{
addSubpatternsForTuple(ImmutableArray<TypeWithAnnotations>.Empty);
}
else if (strippedInputType.IsTupleType)
{
addSubpatternsForTuple(strippedInputType.TupleElementTypesWithAnnotations);
}
else
{
BoundImplicitReceiver receiver = new BoundImplicitReceiver((SyntaxNode)(object)node, strippedInputType);
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(diagnostics);
ImmutableArray<BoundDeconstructValuePlaceholder> outPlaceholders;
bool anyApplicableCandidates;
BoundExpression boundExpression = MakeDeconstructInvocationExpression(tupleDesignation.Variables.Count, receiver, (SyntaxNode)(object)node, instance, out outPlaceholders, out anyApplicableCandidates);
if (!anyApplicableCandidates && ShouldUseITuple((SyntaxNode)(object)node, strippedInputType, diagnostics, out NamedTypeSymbol iTupleType, out MethodSymbol iTupleGetLength, out MethodSymbol iTupleGetItem))
{
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
BindITupleSubpatterns(tupleDesignation, subPatterns, permitDesignations, diagnostics);
return new BoundITuplePattern((SyntaxNode)(object)node, iTupleGetLength, iTupleGetItem, subPatterns.ToImmutableAndFree(), strippedInputType, iTupleType, hasErrors);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRangeAndFree((BindingDiagnosticBag<AssemblySymbol>)(object)instance);
deconstructMethod = boundExpression.ExpressionSymbol as MethodSymbol;
if (!hasErrors)
{
hasErrors = outPlaceholders.IsDefault || tupleDesignation.Variables.Count != outPlaceholders.Length;
}
for (int i = 0; i < tupleDesignation.Variables.Count; i++)
{
VariableDesignationSyntax variableDesignationSyntax = tupleDesignation.Variables[i];
bool flag = outPlaceholders.IsDefaultOrEmpty || i >= outPlaceholders.Length;
TypeSymbol inputType2 = (flag ? CreateErrorType() : outPlaceholders[i].Type);
BoundPattern pattern = BindVarDesignation(variableDesignationSyntax, inputType2, permitDesignations, flag, diagnostics);
subPatterns.Add(new BoundPositionalSubpattern((SyntaxNode)(object)variableDesignationSyntax, null, pattern));
}
}
return new BoundRecursivePattern((SyntaxNode)(object)node, null, deconstructMethod, subPatterns.ToImmutableAndFree(), default(ImmutableArray<BoundPropertySubpattern>), isExplicitNotNullTest: false, null, null, inputType, inputType.StrippedType(), hasErrors);
}
default:
throw ExceptionUtilities.UnexpectedValue((object)node.Kind());
}
}
private ImmutableArray<BoundPropertySubpattern> BindPropertyPatternClause(PropertyPatternClauseSyntax node, TypeSymbol inputType, bool permitDesignations, BindingDiagnosticBag diagnostics, ref bool hasErrors)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Invalid comparison between Unknown and I4
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Invalid comparison between Unknown and I4
ArrayBuilder<BoundPropertySubpattern> instance = ArrayBuilder<BoundPropertySubpattern>.GetInstance(node.Subpatterns.Count);
SubpatternSyntax current;
PatternSyntax pattern;
bool isLengthOrCount;
TypeSymbol typeSymbol;
BoundPropertySubpatternMember boundPropertySubpatternMember;
Symbol symbol = default(Symbol);
BoundPattern pattern2;
for (Enumerator<SubpatternSyntax> enumerator = node.Subpatterns.GetEnumerator(); enumerator.MoveNext(); pattern2 = BindPattern(pattern, typeSymbol, permitDesignations, hasErrors, diagnostics), instance.Add(new BoundPropertySubpattern((SyntaxNode)(object)current, boundPropertySubpatternMember, isLengthOrCount, pattern2)))
{
current = enumerator.Current;
if (current.ExpressionColon is ExpressionColonSyntax)
{
MessageID.IDS_FeatureExtendedPropertyPatterns.CheckFeatureAvailability(diagnostics, current.ExpressionColon.ColonToken);
}
ExpressionSyntax expressionSyntax = current.ExpressionColon?.Expression;
pattern = current.Pattern;
isLengthOrCount = false;
if (expressionSyntax == null)
{
if (!hasErrors)
{
diagnostics.Add(ErrorCode.ERR_PropertyPatternNameMissing, ((SyntaxNode)pattern).Location, pattern);
}
typeSymbol = CreateErrorType();
boundPropertySubpatternMember = null;
hasErrors = true;
continue;
}
boundPropertySubpatternMember = LookupMembersForPropertyPattern(inputType, expressionSyntax, diagnostics, ref hasErrors);
typeSymbol = boundPropertySubpatternMember.Type;
bool flag = (int)typeSymbol.SpecialType == 13;
bool flag2;
if (flag)
{
symbol = boundPropertySubpatternMember.Symbol;
if ((object)symbol != null)
{
string name = symbol.Name;
if ((name == "Length" || name == "Count") && (int)symbol.Kind == 15)
{
flag2 = true;
goto IL_0124;
}
}
flag2 = false;
goto IL_0124;
}
goto IL_0128;
IL_0128:
if (flag)
{
TypeSymbol typeSymbol2 = boundPropertySubpatternMember.Receiver?.Type ?? inputType;
if (!typeSymbol2.IsErrorType())
{
isLengthOrCount = IsCountableAndIndexable((SyntaxNode)(object)node, typeSymbol2, out PropertySymbol lengthProperty) && symbol.Equals(lengthProperty, (TypeCompareKind)0);
}
}
continue;
IL_0124:
flag = flag2;
goto IL_0128;
}
return instance.ToImmutableAndFree();
}
private BoundPropertySubpatternMember LookupMembersForPropertyPattern(TypeSymbol inputType, ExpressionSyntax expr, BindingDiagnosticBag diagnostics, ref bool hasErrors)
{
BoundPropertySubpatternMember boundPropertySubpatternMember = null;
Symbol symbol = null;
if (!(expr is IdentifierNameSyntax memberName))
{
if (expr is MemberAccessExpressionSyntax { Name: IdentifierNameSyntax name } memberAccessExpressionSyntax && ((SyntaxNode?)(object)memberAccessExpressionSyntax).IsKind(SyntaxKind.SimpleMemberAccessExpression))
{
boundPropertySubpatternMember = LookupMembersForPropertyPattern(inputType, memberAccessExpressionSyntax.Expression, diagnostics, ref hasErrors);
symbol = BindPropertyPatternMember(boundPropertySubpatternMember.Type.StrippedType(), name, ref hasErrors, diagnostics);
}
else
{
Error(diagnostics, ErrorCode.ERR_InvalidNameInSubpattern, (CSharpSyntaxNode)expr);
hasErrors = true;
}
}
else
{
symbol = BindPropertyPatternMember(inputType, memberName, ref hasErrors, diagnostics);
}
TypeSymbol typeSymbol = ((symbol is FieldSymbol fieldSymbol) ? fieldSymbol.Type : ((!(symbol is PropertySymbol propertySymbol)) ? CreateErrorType() : propertySymbol.Type));
TypeSymbol type = typeSymbol;
return new BoundPropertySubpatternMember((SyntaxNode)(object)expr, boundPropertySubpatternMember, symbol, type, hasErrors);
}
private Symbol? BindPropertyPatternMember(TypeSymbol inputType, IdentifierNameSyntax memberName, ref bool hasErrors, BindingDiagnosticBag diagnostics)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
BoundImplicitReceiver boundImplicitReceiver = new BoundImplicitReceiver((SyntaxNode)(object)memberName, inputType);
SyntaxToken identifier = memberName.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
BoundExpression boundExpression = BindInstanceMemberAccess((SyntaxNode)(object)memberName, (SyntaxNode)(object)memberName, boundImplicitReceiver, valueText, 0, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), invoked: false, indexed: false, diagnostics);
if (boundExpression.Kind == BoundKind.PropertyGroup)
{
boundExpression = BindIndexedPropertyAccess((BoundPropertyGroup)boundExpression, mustHaveAllOptionalParameters: true, diagnostics);
}
hasErrors |= boundExpression.HasAnyErrors || boundImplicitReceiver.HasAnyErrors;
switch (boundExpression.Kind)
{
default:
if (!hasErrors)
{
switch (boundExpression.ResultKind)
{
case LookupResultKind.Empty:
Error(diagnostics, ErrorCode.ERR_NoSuchMember, (CSharpSyntaxNode)memberName, new object[2] { boundImplicitReceiver.Type, valueText });
break;
case LookupResultKind.Inaccessible:
boundExpression = CheckValue(boundExpression, BindValueKind.RValue, diagnostics);
break;
default:
Error(diagnostics, ErrorCode.ERR_PropertyLacksGet, (CSharpSyntaxNode)memberName, new object[1] { valueText });
break;
}
hasErrors = true;
}
break;
case BoundKind.FieldAccess:
case BoundKind.PropertyAccess:
break;
}
if (!hasErrors && !CheckValueKind((SyntaxNode)(object)memberName.Parent, boundExpression, BindValueKind.RValue, checkingReceiver: false, diagnostics))
{
hasErrors = true;
}
return boundExpression.ExpressionSymbol;
}
private BoundPattern BindTypePattern(TypePatternSyntax node, TypeSymbol inputType, bool hasErrors, BindingDiagnosticBag diagnostics)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Invalid comparison between Unknown and I4
MessageID.IDS_FeatureTypePattern.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)node);
BoundTypeExpression boundTypeExpression = BindTypeForPattern(node.Type, inputType, diagnostics, ref hasErrors);
bool isExplicitNotNullTest = (int)boundTypeExpression.Type.SpecialType == 1;
return new BoundTypePattern((SyntaxNode)(object)node, boundTypeExpression, isExplicitNotNullTest, inputType, boundTypeExpression.Type, hasErrors);
}
private BoundPattern BindRelationalPattern(RelationalPatternSyntax node, TypeSymbol inputType, bool hasErrors, BindingDiagnosticBag diagnostics)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureRelationalPattern.CheckFeatureAvailability(diagnostics, node.OperatorToken);
ConstantValue constantValueOpt;
bool wasExpression;
Conversion patternExpressionConversion;
BoundExpression boundExpression = BindExpressionForPattern(inputType, node.Expression, ref hasErrors, diagnostics, out constantValueOpt, out wasExpression, out patternExpressionConversion);
SkipParensAndNullSuppressions(node.Expression, diagnostics, ref hasErrors);
BinaryOperatorKind binaryOperatorKind = tokenKindToBinaryOperatorKind(node.OperatorToken.Kind());
if (binaryOperatorKind == BinaryOperatorKind.Equal)
{
SyntaxToken operatorToken = node.OperatorToken;
Location location = ((SyntaxToken)(ref operatorToken)).GetLocation();
object[] array = new object[1];
operatorToken = node.OperatorToken;
array[0] = ((SyntaxToken)(ref operatorToken)).Text;
diagnostics.Add(ErrorCode.ERR_InvalidExprTerm, location, array);
hasErrors = true;
}
BinaryOperatorKind binaryOperatorKind2 = RelationalOperatorType(boundExpression.Type.EnumUnderlyingTypeOrSelf());
switch (binaryOperatorKind2)
{
case BinaryOperatorKind.Float:
case BinaryOperatorKind.Double:
if (!hasErrors && constantValueOpt != (ConstantValue)null && !constantValueOpt.IsBad && double.IsNaN(constantValueOpt.DoubleValue))
{
diagnostics.Add(ErrorCode.ERR_RelationalPatternWithNaN, ((SyntaxNode)node.Expression).Location);
hasErrors = true;
}
break;
case BinaryOperatorKind.Error:
case BinaryOperatorKind.Bool:
case BinaryOperatorKind.String:
if (!hasErrors)
{
diagnostics.Add(ErrorCode.ERR_UnsupportedTypeForRelationalPattern, ((SyntaxNode)node).Location, boundExpression.Type.ToDisplayString());
hasErrors = true;
}
break;
}
if (constantValueOpt == null)
{
hasErrors = true;
constantValueOpt = ConstantValue.Bad;
}
if (!hasErrors && ShouldBlockINumberBaseConversion(patternExpressionConversion, inputType))
{
diagnostics.Add(ErrorCode.ERR_CannotMatchOnINumberBase, ((SyntaxNode)node).Location, inputType);
hasErrors = true;
}
return new BoundRelationalPattern((SyntaxNode)(object)node, binaryOperatorKind | binaryOperatorKind2, boundExpression, constantValueOpt, inputType, boundExpression.Type, hasErrors);
static BinaryOperatorKind tokenKindToBinaryOperatorKind(SyntaxKind kind)
{
return kind switch
{
SyntaxKind.LessThanEqualsToken => BinaryOperatorKind.LessThanOrEqual,
SyntaxKind.LessThanToken => BinaryOperatorKind.LessThan,
SyntaxKind.GreaterThanToken => BinaryOperatorKind.GreaterThan,
SyntaxKind.GreaterThanEqualsToken => BinaryOperatorKind.GreaterThanOrEqual,
_ => BinaryOperatorKind.Equal,
};
}
}
internal static BinaryOperatorKind RelationalOperatorType(TypeSymbol type)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected I4, but got Unknown
SpecialType specialType = type.SpecialType;
switch (specialType - 7)
{
case 11:
return BinaryOperatorKind.Float;
case 12:
return BinaryOperatorKind.Double;
case 1:
return BinaryOperatorKind.Char;
case 2:
return BinaryOperatorKind.Int;
case 3:
return BinaryOperatorKind.Int;
case 5:
return BinaryOperatorKind.Int;
case 4:
return BinaryOperatorKind.Int;
case 6:
return BinaryOperatorKind.Int;
case 7:
return BinaryOperatorKind.UInt;
case 8:
return BinaryOperatorKind.Long;
case 9:
return BinaryOperatorKind.ULong;
case 10:
return BinaryOperatorKind.Decimal;
case 13:
return BinaryOperatorKind.String;
case 0:
return BinaryOperatorKind.Bool;
case 14:
if (type.IsNativeIntegerType)
{
return BinaryOperatorKind.NInt;
}
break;
case 15:
if (type.IsNativeIntegerType)
{
return BinaryOperatorKind.NUInt;
}
break;
}
return BinaryOperatorKind.Error;
}
private BoundPattern BindUnaryPattern(UnaryPatternSyntax node, TypeSymbol inputType, bool hasErrors, BindingDiagnosticBag diagnostics, bool underIsPattern)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureNotPattern.CheckFeatureAvailability(diagnostics, node.OperatorToken);
bool permitDesignations = underIsPattern;
BoundPattern negated = BindPattern(node.Pattern, inputType, permitDesignations, hasErrors, diagnostics, underIsPattern);
return new BoundNegatedPattern((SyntaxNode)(object)node, negated, inputType, inputType, hasErrors);
}
private BoundPattern BindBinaryPattern(BinaryPatternSyntax node, TypeSymbol inputType, bool permitDesignations, bool hasErrors, BindingDiagnosticBag diagnostics)
{
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
bool flag = node.Kind() == SyntaxKind.OrPattern;
if (flag)
{
MessageID.IDS_FeatureOrPattern.CheckFeatureAvailability(diagnostics, node.OperatorToken);
permitDesignations = false;
BoundPattern boundPattern = BindPattern(node.Left, inputType, permitDesignations, hasErrors, diagnostics);
BoundPattern boundPattern2 = BindPattern(node.Right, inputType, permitDesignations, hasErrors, diagnostics);
ArrayBuilder<TypeSymbol> instance = ArrayBuilder<TypeSymbol>.GetInstance(2);
collectCandidates(boundPattern, instance);
collectCandidates(boundPattern2, instance);
TypeSymbol narrowedType = leastSpecificType((SyntaxNode)(object)node, instance, diagnostics) ?? inputType;
instance.Free();
return new BoundBinaryPattern((SyntaxNode)(object)node, flag, boundPattern, boundPattern2, inputType, narrowedType, hasErrors);
}
MessageID.IDS_FeatureAndPattern.CheckFeatureAvailability(diagnostics, node.OperatorToken);
BoundPattern boundPattern3 = BindPattern(node.Left, inputType, permitDesignations, hasErrors, diagnostics);
BoundPattern boundPattern4 = BindPattern(node.Right, boundPattern3.NarrowedType, permitDesignations, hasErrors, diagnostics);
return new BoundBinaryPattern((SyntaxNode)(object)node, flag, boundPattern3, boundPattern4, inputType, boundPattern4.NarrowedType, hasErrors);
static void collectCandidates(BoundPattern pat, ArrayBuilder<TypeSymbol> candidates)
{
if (pat is BoundBinaryPattern { Disjunction: not false } boundBinaryPattern)
{
collectCandidates(boundBinaryPattern.Left, candidates);
collectCandidates(boundBinaryPattern.Right, candidates);
}
else
{
candidates.Add(pat.NarrowedType);
}
}
TypeSymbol? leastSpecificType(SyntaxNode val, ArrayBuilder<TypeSymbol> candidates, BindingDiagnosticBag bindingDiagnosticBag)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(bindingDiagnosticBag);
TypeSymbol typeSymbol = candidates[0];
int i = 1;
for (int count = candidates.Count; i < count; i++)
{
TypeSymbol possiblyLessSpecificCandidate = candidates[i];
typeSymbol = lessSpecificCandidate(typeSymbol, possiblyLessSpecificCandidate, ref useSiteInfo) ?? typeSymbol;
}
int j = 0;
for (int count2 = candidates.Count; j < count2; j++)
{
TypeSymbol bestSoFar = candidates[j];
if ((object)lessSpecificCandidate(bestSoFar, typeSymbol, ref useSiteInfo) == null)
{
typeSymbol = null;
break;
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag).Add(val, useSiteInfo);
return typeSymbol;
}
TypeSymbol? lessSpecificCandidate(TypeSymbol bestSoFar, TypeSymbol possiblyLessSpecificCandidate, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
if (bestSoFar.Equals(possiblyLessSpecificCandidate, (TypeCompareKind)63))
{
return bestSoFar.MergeEquivalentTypes(possiblyLessSpecificCandidate, (VarianceKind)1);
}
if (Conversions.HasImplicitReferenceConversion(bestSoFar, possiblyLessSpecificCandidate, ref useSiteInfo))
{
return possiblyLessSpecificCandidate;
}
if (Conversions.HasBoxingConversion(bestSoFar, possiblyLessSpecificCandidate, ref useSiteInfo))
{
return possiblyLessSpecificCandidate;
}
return null;
}
}
internal BoundExpression BindQuery(QueryExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureQueryExpression.CheckFeatureAvailability(diagnostics, node.FromClause.FromKeyword);
FromClauseSyntax fromClause = node.FromClause;
BoundExpression boundExpression = BindLeftOfPotentialColorColorMemberAccess(fromClause.Expression, diagnostics);
if (boundExpression.HasDynamicType())
{
diagnostics.Add(ErrorCode.ERR_BadDynamicQuery, ((SyntaxNode)fromClause.Expression).Location);
boundExpression = BadExpression((SyntaxNode)(object)fromClause.Expression, boundExpression);
}
else
{
boundExpression = BindToNaturalType(boundExpression, diagnostics);
}
(QueryTranslationState, RangeVariableSymbol) tuple = MakeInitialQueryTranslationState(node, diagnostics);
QueryTranslationState item = tuple.Item1;
RangeVariableSymbol item2 = tuple.Item2;
item.fromExpression = MakeMemberAccessValue(boundExpression, diagnostics);
BoundExpression castInvocation = null;
if (fromClause.Type != null)
{
TypeWithAnnotations typeArg = BindTypeArgument(fromClause.Type, diagnostics);
castInvocation = (item.fromExpression = MakeQueryInvocation(fromClause, item.fromExpression, "Cast", fromClause.Type, typeArg, diagnostics));
}
item.fromExpression = MakeQueryClause(fromClause, item.fromExpression, item2, null, castInvocation);
BoundExpression boundExpression2 = BindQueryInternal1(item, diagnostics);
for (QueryContinuationSyntax continuation = node.Body.Continuation; continuation != null; continuation = continuation.Body.Continuation)
{
item2 = PrepareQueryTranslationStateForContinuation(item, continuation, diagnostics);
item.fromExpression = boundExpression2;
boundExpression2 = BindQueryInternal1(item, diagnostics);
boundExpression2 = MakeQueryClause(continuation.Body, boundExpression2, item2);
boundExpression2 = MakeQueryClause(continuation, boundExpression2, item2);
}
item.Free();
return MakeQueryClause(node, boundExpression2);
}
private (QueryTranslationState, RangeVariableSymbol) MakeInitialQueryTranslationState(QueryExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
FromClauseSyntax fromClause = node.FromClause;
QueryTranslationState queryTranslationState = new QueryTranslationState();
RangeVariableSymbol item = (queryTranslationState.rangeVariable = queryTranslationState.AddRangeVariable(this, fromClause.Identifier, diagnostics));
for (int num = node.Body.Clauses.Count - 1; num >= 0; num--)
{
queryTranslationState.clauses.Push(node.Body.Clauses[num]);
}
queryTranslationState.selectOrGroup = node.Body.SelectOrGroup;
return (queryTranslationState, item);
}
private RangeVariableSymbol PrepareQueryTranslationStateForContinuation(QueryTranslationState state, QueryContinuationSyntax continuation, BindingDiagnosticBag diagnostics)
{
//IL_000a: 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_0029: Unknown result type (might be due to invalid IL or missing references)
state.Clear();
RangeVariableSymbol result = (state.rangeVariable = state.AddRangeVariable(this, continuation.Identifier, diagnostics));
SyntaxList<QueryClauseSyntax> clauses = continuation.Body.Clauses;
for (int num = clauses.Count - 1; num >= 0; num--)
{
state.clauses.Push(clauses[num]);
}
state.selectOrGroup = continuation.Body.SelectOrGroup;
return result;
}
private static string GetFirstInvokedMethodName(QueryExpressionSyntax query, out SyntaxNode correspondingAccessNode)
{
//IL_0021: 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)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
if (query.FromClause.Type != null)
{
correspondingAccessNode = (SyntaxNode)(object)query.FromClause;
return "Cast";
}
QueryClauseSyntax queryClauseSyntax = query.Body.Clauses.FirstOrDefault();
if (queryClauseSyntax != null)
{
correspondingAccessNode = (SyntaxNode)(object)queryClauseSyntax;
switch (queryClauseSyntax.Kind())
{
case SyntaxKind.FromClause:
return "SelectMany";
case SyntaxKind.LetClause:
return "Select";
case SyntaxKind.WhereClause:
return "Where";
case SyntaxKind.JoinClause:
if (((JoinClauseSyntax)queryClauseSyntax).Into != null)
{
return "GroupJoin";
}
return "Join";
case SyntaxKind.OrderByClause:
if (!((SyntaxNode?)(object)((OrderByClauseSyntax)queryClauseSyntax).Orderings.First()).IsKind(SyntaxKind.DescendingOrdering))
{
return "OrderBy";
}
return "OrderByDescending";
default:
throw ExceptionUtilities.UnexpectedValue((object)queryClauseSyntax.Kind());
}
}
correspondingAccessNode = (SyntaxNode)(object)query.Body.SelectOrGroup;
return query.Body.SelectOrGroup.Kind() switch
{
SyntaxKind.SelectClause => "Select",
SyntaxKind.GroupClause => "GroupBy",
_ => throw ExceptionUtilities.UnexpectedValue((object)query.Body.SelectOrGroup.Kind()),
};
}
private BoundExpression BindQueryInternal1(QueryTranslationState state, BindingDiagnosticBag diagnostics)
{
if (!IsDegenerateQuery(state))
{
return BindQueryInternal2(state, diagnostics);
}
return FinalTranslation(state, diagnostics);
}
private static bool IsDegenerateQuery(QueryTranslationState state)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
if (!EnumerableExtensions.IsEmpty<QueryClauseSyntax>((IReadOnlyCollection<QueryClauseSyntax>)state.clauses))
{
return false;
}
if (!(state.selectOrGroup is SelectClauseSyntax selectClauseSyntax))
{
return false;
}
if (selectClauseSyntax.Expression is IdentifierNameSyntax identifierNameSyntax)
{
string name = state.rangeVariable.Name;
SyntaxToken identifier = identifierNameSyntax.Identifier;
return name == ((SyntaxToken)(ref identifier)).ValueText;
}
return false;
}
private BoundExpression BindQueryInternal2(QueryTranslationState state, BindingDiagnosticBag diagnostics)
{
while (!EnumerableExtensions.IsEmpty<QueryClauseSyntax>((IReadOnlyCollection<QueryClauseSyntax>)state.clauses))
{
ReduceQuery(state, diagnostics);
}
if (state.selectOrGroup == null)
{
return state.fromExpression;
}
if (IsDegenerateQuery(state))
{
BoundExpression fromExpression = state.fromExpression;
BoundExpression boundExpression = FinalTranslation(state, BindingDiagnosticBag.Discarded);
if (boundExpression.HasAnyErrors && !fromExpression.HasAnyErrors)
{
boundExpression = null;
}
return MakeQueryClause(state.selectOrGroup, fromExpression, null, null, null, boundExpression);
}
return FinalTranslation(state, diagnostics);
}
private BoundExpression FinalTranslation(QueryTranslationState state, BindingDiagnosticBag diagnostics)
{
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
GroupClauseSyntax groupClauseSyntax;
BindingDiagnosticBag instance;
BoundCall result;
BoundExpression boundExpression;
switch (state.selectOrGroup.Kind())
{
case SyntaxKind.SelectClause:
{
SelectClauseSyntax selectClauseSyntax = (SelectClauseSyntax)state.selectOrGroup;
RangeVariableSymbol rangeVariable2 = state.rangeVariable;
BoundExpression fromExpression2 = state.fromExpression;
ExpressionSyntax expression = selectClauseSyntax.Expression;
UnboundLambda arg = MakeQueryUnboundLambda(state.RangeVariableMap(), rangeVariable2, expression, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
BoundCall boundCall = MakeQueryInvocation(state.selectOrGroup, fromExpression2, "Select", arg, diagnostics);
return MakeQueryClause(selectClauseSyntax, boundCall, null, boundCall);
}
case SyntaxKind.GroupClause:
{
groupClauseSyntax = (GroupClauseSyntax)state.selectOrGroup;
RangeVariableSymbol rangeVariable = state.rangeVariable;
BoundExpression fromExpression = state.fromExpression;
ExpressionSyntax groupExpression = groupClauseSyntax.GroupExpression;
ExpressionSyntax byExpression = groupClauseSyntax.ByExpression;
IdentifierNameSyntax identifierNameSyntax = groupExpression as IdentifierNameSyntax;
UnboundLambda unboundLambda = MakeQueryUnboundLambda(state.RangeVariableMap(), rangeVariable, byExpression, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
instance = BindingDiagnosticBag.GetInstance(diagnostics);
BoundExpression item = MakeQueryUnboundLambda(state.RangeVariableMap(), rangeVariable, groupExpression, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
result = MakeQueryInvocation(state.selectOrGroup, fromExpression, "GroupBy", ImmutableArray.Create(unboundLambda, item), instance);
result = ReverseLastTwoParameterOrder(result);
boundExpression = null;
if (identifierNameSyntax != null)
{
SyntaxToken identifier = identifierNameSyntax.Identifier;
if (((SyntaxToken)(ref identifier)).ValueText == rangeVariable.Name)
{
boundExpression = result;
result = MakeQueryInvocation(state.selectOrGroup, fromExpression, "GroupBy", unboundLambda, diagnostics);
if (boundExpression.HasAnyErrors && !result.HasAnyErrors)
{
boundExpression = null;
}
goto IL_017a;
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
goto IL_017a;
}
default:
{
return new BoundBadExpression((SyntaxNode)(object)state.selectOrGroup, LookupResultKind.OverloadResolutionFailure, ImmutableArray<Symbol>.Empty, ImmutableArray.Create(state.fromExpression), state.fromExpression.Type);
}
IL_017a:
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
return MakeQueryClause(groupClauseSyntax, result, null, result, null, boundExpression);
}
}
private static BoundCall ReverseLastTwoParameterOrder(BoundCall result)
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
int length = result.Arguments.Length;
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance();
instance.AddRange(result.Arguments);
BoundExpression boundExpression = instance[length - 1];
instance[length - 1] = instance[length - 2];
instance[length - 2] = boundExpression;
ArrayBuilder<int> instance2 = ArrayBuilder<int>.GetInstance();
instance2.AddRange(Enumerable.Range(0, length));
instance2[length - 1] = length - 2;
instance2[length - 2] = length - 1;
BitVector defaultArguments = result.DefaultArguments;
BitVector defaultArguments2 = ((BitVector)(ref defaultArguments)).Clone();
int num = length - 1;
int num2 = length - 2;
bool flag = ((BitVector)(ref defaultArguments2))[length - 2];
bool flag2 = ((BitVector)(ref defaultArguments2))[length - 1];
((BitVector)(ref defaultArguments2))[num] = flag;
((BitVector)(ref defaultArguments2))[num2] = flag2;
return result.Update(result.ReceiverOpt, result.InitialBindingReceiverIsSubjectToCloning, result.Method, instance.ToImmutableAndFree(), default(ImmutableArray<string>), default(ImmutableArray<RefKind>), result.IsDelegateCall, result.Expanded, result.InvokedAsExtensionMethod, instance2.ToImmutableAndFree(), defaultArguments2, result.ResultKind, result.OriginalMethodsOpt, result.Type);
}
private void ReduceQuery(QueryTranslationState state, BindingDiagnosticBag diagnostics)
{
QueryClauseSyntax queryClauseSyntax = state.clauses.Pop();
switch (queryClauseSyntax.Kind())
{
case SyntaxKind.WhereClause:
ReduceWhere((WhereClauseSyntax)queryClauseSyntax, state, diagnostics);
break;
case SyntaxKind.JoinClause:
ReduceJoin((JoinClauseSyntax)queryClauseSyntax, state, diagnostics);
break;
case SyntaxKind.OrderByClause:
ReduceOrderBy((OrderByClauseSyntax)queryClauseSyntax, state, diagnostics);
break;
case SyntaxKind.FromClause:
ReduceFrom((FromClauseSyntax)queryClauseSyntax, state, diagnostics);
break;
case SyntaxKind.LetClause:
ReduceLet((LetClauseSyntax)queryClauseSyntax, state, diagnostics);
break;
default:
throw ExceptionUtilities.UnexpectedValue((object)queryClauseSyntax.Kind());
}
}
private void ReduceWhere(WhereClauseSyntax where, QueryTranslationState state, BindingDiagnosticBag diagnostics)
{
UnboundLambda arg = MakeQueryUnboundLambda(state.RangeVariableMap(), state.rangeVariable, where.Condition, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
BoundCall boundCall = MakeQueryInvocation(where, state.fromExpression, "Where", arg, diagnostics);
state.fromExpression = MakeQueryClause(where, boundCall, null, boundCall);
}
private void ReduceJoin(JoinClauseSyntax join, QueryTranslationState state, BindingDiagnosticBag diagnostics)
{
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
BoundExpression boundExpression = BindRValueWithoutTargetType(join.InExpression, diagnostics);
if (boundExpression.HasDynamicType())
{
diagnostics.Add(ErrorCode.ERR_BadDynamicQuery, ((SyntaxNode)join.InExpression).Location);
boundExpression = BadExpression((SyntaxNode)(object)join.InExpression, boundExpression);
}
BoundExpression boundExpression2 = null;
if (join.Type != null)
{
TypeWithAnnotations typeArg = BindTypeArgument(join.Type, diagnostics);
boundExpression2 = MakeQueryInvocation(join, boundExpression, "Cast", join.Type, typeArg, diagnostics);
boundExpression = boundExpression2;
}
UnboundLambda item = MakeQueryUnboundLambda(state.RangeVariableMap(), state.rangeVariable, join.LeftExpression, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
RangeVariableSymbol rangeVariable = state.rangeVariable;
RangeVariableSymbol rangeVariableSymbol = state.AddRangeVariable(this, join.Identifier, diagnostics);
UnboundLambda item2 = MakeQueryUnboundLambda(QueryTranslationState.RangeVariableMap(rangeVariableSymbol), rangeVariableSymbol, join.RightExpression, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
if (EnumerableExtensions.IsEmpty<QueryClauseSyntax>((IReadOnlyCollection<QueryClauseSyntax>)state.clauses) && state.selectOrGroup.Kind() == SyntaxKind.SelectClause)
{
SelectClauseSyntax selectClauseSyntax = (SelectClauseSyntax)state.selectOrGroup;
BoundCall boundCall;
if (join.Into == null)
{
UnboundLambda item3 = MakeQueryUnboundLambda(state.RangeVariableMap(), ImmutableArray.Create(rangeVariable, rangeVariableSymbol), selectClauseSyntax.Expression, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
boundCall = MakeQueryInvocation(join, state.fromExpression, "Join", ImmutableArray.Create(boundExpression, item, item2, item3), diagnostics);
}
else
{
state.allRangeVariables[rangeVariableSymbol].Free();
state.allRangeVariables.Remove(rangeVariableSymbol);
RangeVariableSymbol rangeVariableSymbol2 = state.AddRangeVariable(this, join.Into.Identifier, diagnostics);
UnboundLambda item4 = MakeQueryUnboundLambda(state.RangeVariableMap(), ImmutableArray.Create(rangeVariable, rangeVariableSymbol2), selectClauseSyntax.Expression, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
boundCall = MakeQueryInvocation(join, state.fromExpression, "GroupJoin", ImmutableArray.Create(boundExpression, item, item2, item4), diagnostics);
ImmutableArray<BoundExpression> arguments = boundCall.Arguments;
arguments = arguments.SetItem(arguments.Length - 1, MakeQueryClause(join.Into, arguments[arguments.Length - 1], rangeVariableSymbol2));
boundCall = boundCall.Update(boundCall.ReceiverOpt, boundCall.InitialBindingReceiverIsSubjectToCloning, boundCall.Method, arguments);
}
state.Clear();
state.fromExpression = MakeQueryClause(join, boundCall, rangeVariableSymbol, boundCall, boundExpression2);
state.fromExpression = MakeQueryClause(selectClauseSyntax, state.fromExpression);
}
else
{
BoundCall boundCall2;
if (join.Into == null)
{
UnboundLambda item5 = MakePairLambda(join, state, rangeVariable, rangeVariableSymbol, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
boundCall2 = MakeQueryInvocation(join, state.fromExpression, "Join", ImmutableArray.Create(boundExpression, item, item2, item5), diagnostics);
}
else
{
state.allRangeVariables[rangeVariableSymbol].Free();
state.allRangeVariables.Remove(rangeVariableSymbol);
RangeVariableSymbol rangeVariableSymbol3 = state.AddRangeVariable(this, join.Into.Identifier, diagnostics);
UnboundLambda item6 = MakePairLambda(join, state, rangeVariable, rangeVariableSymbol3, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
boundCall2 = MakeQueryInvocation(join, state.fromExpression, "GroupJoin", ImmutableArray.Create(boundExpression, item, item2, item6), diagnostics);
ImmutableArray<BoundExpression> arguments2 = boundCall2.Arguments;
arguments2 = arguments2.SetItem(arguments2.Length - 1, MakeQueryClause(join.Into, arguments2[arguments2.Length - 1], rangeVariableSymbol3));
boundCall2 = boundCall2.Update(boundCall2.ReceiverOpt, boundCall2.InitialBindingReceiverIsSubjectToCloning, boundCall2.Method, arguments2);
}
state.fromExpression = MakeQueryClause(join, boundCall2, rangeVariableSymbol, boundCall2, boundExpression2);
}
}
private void ReduceOrderBy(OrderByClauseSyntax orderby, QueryTranslationState state, BindingDiagnosticBag diagnostics)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
bool flag = true;
Enumerator<OrderingSyntax> enumerator = orderby.Orderings.GetEnumerator();
while (enumerator.MoveNext())
{
OrderingSyntax current = enumerator.Current;
string methodName = (flag ? "OrderBy" : "ThenBy") + (((SyntaxNode?)(object)current).IsKind(SyntaxKind.DescendingOrdering) ? "Descending" : "");
UnboundLambda arg = MakeQueryUnboundLambda(state.RangeVariableMap(), state.rangeVariable, current.Expression, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
BoundCall boundCall = MakeQueryInvocation(current, state.fromExpression, methodName, arg, diagnostics);
state.fromExpression = MakeQueryClause(current, boundCall, null, boundCall);
flag = false;
}
state.fromExpression = MakeQueryClause(orderby, state.fromExpression);
}
private void ReduceFrom(FromClauseSyntax from, QueryTranslationState state, BindingDiagnosticBag diagnostics)
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
RangeVariableSymbol rangeVariable = state.rangeVariable;
BoundExpression item = ((from.Type != null) ? MakeQueryUnboundLambdaWithCast(state.RangeVariableMap(), rangeVariable, from.Expression, from.Type, BindTypeArgument(from.Type, diagnostics), ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies) : MakeQueryUnboundLambda(state.RangeVariableMap(), rangeVariable, from.Expression, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies));
RangeVariableSymbol rangeVariableSymbol = state.AddRangeVariable(this, from.Identifier, diagnostics);
if (EnumerableExtensions.IsEmpty<QueryClauseSyntax>((IReadOnlyCollection<QueryClauseSyntax>)state.clauses) && ((SyntaxNode?)(object)state.selectOrGroup).IsKind(SyntaxKind.SelectClause))
{
SelectClauseSyntax selectClauseSyntax = (SelectClauseSyntax)state.selectOrGroup;
UnboundLambda item2 = MakeQueryUnboundLambda(state.RangeVariableMap(), ImmutableArray.Create(rangeVariable, rangeVariableSymbol), selectClauseSyntax.Expression, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
BoundCall boundCall = MakeQueryInvocation(from, state.fromExpression, "SelectMany", ImmutableArray.Create(item, item2), diagnostics);
BoundExpression castInvocation = ((from.Type != null) ? ExtractCastInvocation(boundCall) : null);
ImmutableArray<BoundExpression> arguments = boundCall.Arguments;
boundCall = boundCall.Update(boundCall.ReceiverOpt, boundCall.InitialBindingReceiverIsSubjectToCloning, boundCall.Method, arguments.SetItem(arguments.Length - 2, MakeQueryClause(from, arguments[arguments.Length - 2], rangeVariableSymbol, boundCall, castInvocation)));
state.Clear();
state.fromExpression = MakeQueryClause(from, boundCall, rangeVariableSymbol, boundCall);
state.fromExpression = MakeQueryClause(selectClauseSyntax, state.fromExpression);
}
else
{
UnboundLambda item3 = MakePairLambda(from, state, rangeVariable, rangeVariableSymbol, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
BoundCall boundCall2 = MakeQueryInvocation(from, state.fromExpression, "SelectMany", ImmutableArray.Create(item, item3), diagnostics);
BoundExpression castInvocation2 = ((from.Type != null) ? ExtractCastInvocation(boundCall2) : null);
state.fromExpression = MakeQueryClause(from, boundCall2, rangeVariableSymbol, boundCall2, castInvocation2);
}
}
private static BoundExpression? ExtractCastInvocation(BoundCall invocation)
{
int index = (invocation.InvokedAsExtensionMethod ? 1 : 0);
BoundLambda boundLambda = ((invocation.Arguments[index] is BoundConversion boundConversion) ? (boundConversion.Operand as BoundLambda) : null);
BoundReturnStatement boundReturnStatement = ((boundLambda != null) ? (boundLambda.Body.Statements[0] as BoundReturnStatement) : null);
if (boundReturnStatement == null)
{
return null;
}
return boundReturnStatement.ExpressionOpt as BoundCall;
}
private UnboundLambda MakePairLambda(CSharpSyntaxNode node, QueryTranslationState state, RangeVariableSymbol x1, RangeVariableSymbol x2, bool withDependencies)
{
LambdaBodyFactory bodyFactory = delegate(LambdaSymbol lambdaSymbol, Binder lambdaBodyBinder, BindingDiagnosticBag d)
{
BoundParameter field1Value = new BoundParameter((SyntaxNode)(object)node, lambdaSymbol.Parameters[0])
{
WasCompilerGenerated = true
};
BoundParameter field2Value = new BoundParameter((SyntaxNode)(object)node, lambdaSymbol.Parameters[1])
{
WasCompilerGenerated = true
};
BoundExpression expression = MakePair(node, x1.Name, field1Value, x2.Name, field2Value, state, d);
return lambdaBodyBinder.CreateBlockFromExpression(node, ImmutableArray<LocalSymbol>.Empty, (RefKind)0, expression, null, d);
};
UnboundLambda result = MakeQueryUnboundLambda(state.RangeVariableMap(), ImmutableArray.Create(x1, x2), node, bodyFactory, withDependencies);
state.rangeVariable = state.TransparentRangeVariable(this);
state.AddTransparentIdentifier(x1.Name);
ArrayBuilder<string> obj = state.allRangeVariables[x2];
obj[obj.Count - 1] = x2.Name;
return result;
}
private void ReduceLet(LetClauseSyntax let, QueryTranslationState state, BindingDiagnosticBag diagnostics)
{
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
RangeVariableSymbol x = state.rangeVariable;
LambdaBodyFactory bodyFactory = delegate(LambdaSymbol lambdaSymbol, Binder lambdaBodyBinder, BindingDiagnosticBag d)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
BoundParameter field1Value = new BoundParameter((SyntaxNode)(object)let, lambdaSymbol.Parameters[0])
{
WasCompilerGenerated = true
};
lambdaBodyBinder = lambdaBodyBinder.GetRequiredBinder((SyntaxNode)(object)let.Expression);
BoundExpression boundExpression = lambdaBodyBinder.BindRValueWithoutTargetType(let.Expression, d);
SyntaxTree syntaxTree = let.SyntaxTree;
SyntaxToken identifier2 = let.Identifier;
int spanStart = ((SyntaxToken)(ref identifier2)).SpanStart;
TextSpan span = ((SyntaxNode)let.Expression).Span;
int end = ((TextSpan)(ref span)).End;
identifier2 = let.Identifier;
SourceLocation location = new SourceLocation(syntaxTree, new TextSpan(spanStart, end - ((SyntaxToken)(ref identifier2)).SpanStart));
if (!boundExpression.HasAnyErrors && !boundExpression.HasExpressionType())
{
Error(d, ErrorCode.ERR_QueryRangeVariableAssignedBadValue, (Location)(object)location, boundExpression.Display);
boundExpression = new BoundBadExpression(boundExpression.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create(boundExpression), CreateErrorType());
}
else if (!boundExpression.HasAnyErrors && boundExpression.Type.IsVoidType())
{
Error(d, ErrorCode.ERR_QueryRangeVariableAssignedBadValue, (Location)(object)location, boundExpression.Type);
boundExpression = new BoundBadExpression(boundExpression.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create(boundExpression), boundExpression.Type);
}
Binder binder = this;
LetClauseSyntax node = let;
string name = x.Name;
identifier2 = let.Identifier;
BoundExpression result = binder.MakePair(node, name, field1Value, ((SyntaxToken)(ref identifier2)).ValueText, boundExpression, state, d);
return lambdaBodyBinder.CreateLambdaBlockForQueryClause(let.Expression, result, d);
};
UnboundLambda arg = MakeQueryUnboundLambda(state.RangeVariableMap(), ImmutableArray.Create(x), let.Expression, bodyFactory, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
state.rangeVariable = state.TransparentRangeVariable(this);
state.AddTransparentIdentifier(x.Name);
RangeVariableSymbol rangeVariableSymbol = state.AddRangeVariable(this, let.Identifier, diagnostics);
ArrayBuilder<string> obj = state.allRangeVariables[rangeVariableSymbol];
SyntaxToken identifier = let.Identifier;
obj.Add(((SyntaxToken)(ref identifier)).ValueText);
BoundCall boundCall = MakeQueryInvocation(let, state.fromExpression, "Select", arg, diagnostics);
state.fromExpression = MakeQueryClause(let, boundCall, rangeVariableSymbol, boundCall);
}
private BoundBlock CreateLambdaBlockForQueryClause(ExpressionSyntax expression, BoundExpression result, BindingDiagnosticBag diagnostics)
{
ImmutableArray<LocalSymbol> declaredLocalsForScope = GetDeclaredLocalsForScope((SyntaxNode)(object)expression);
if (declaredLocalsForScope.Any())
{
CheckFeatureAvailability((SyntaxNode)(object)expression, MessageID.IDS_FeatureExpressionVariablesInQueriesAndInitializers, diagnostics, declaredLocalsForScope[0].GetFirstLocation());
}
return CreateBlockFromExpression(expression, declaredLocalsForScope, (RefKind)0, result, expression, diagnostics);
}
private BoundQueryClause MakeQueryClause(CSharpSyntaxNode syntax, BoundExpression expression, RangeVariableSymbol? definedSymbol = null, BoundExpression? queryInvocation = null, BoundExpression? castInvocation = null, BoundExpression? unoptimizedForm = null)
{
if (unoptimizedForm != null && unoptimizedForm.HasAnyErrors && !expression.HasAnyErrors)
{
unoptimizedForm = null;
}
return new BoundQueryClause((SyntaxNode)(object)syntax, expression, definedSymbol, queryInvocation, castInvocation, this, unoptimizedForm, TypeOrError(expression));
}
private BoundExpression MakePair(CSharpSyntaxNode node, string field1Name, BoundExpression field1Value, string field2Name, BoundExpression field2Value, QueryTranslationState state, BindingDiagnosticBag diagnostics)
{
if (field1Name == field2Name)
{
field2Name = state.TransparentRangeVariableName();
field2Value = new BoundBadExpression(field2Value.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create(field2Value), field2Value.Type, hasErrors: true);
}
AnonymousTypeDescriptor typeDescr = new AnonymousTypeDescriptor(ImmutableArray.Create(createField(field1Name, field1Value), createField(field2Name, field2Value)), ((SyntaxNode)node).Location);
NamedTypeSymbol toCreate = Compilation.AnonymousTypeManager.ConstructAnonymousTypeSymbol(typeDescr);
return MakeConstruction(node, toCreate, ImmutableArray.Create(field1Value, field2Value), diagnostics);
AnonymousTypeField createField(string fieldName, BoundExpression fieldValue)
{
return new AnonymousTypeField(fieldName, fieldValue.Syntax.Location, TypeWithAnnotations.Create(TypeOrError(fieldValue)), (RefKind)0, (ScopedKind)0);
}
}
private TypeSymbol TypeOrError(BoundExpression e)
{
return e.Type ?? CreateErrorType();
}
private UnboundLambda MakeQueryUnboundLambda(RangeVariableMap qvm, RangeVariableSymbol parameter, ExpressionSyntax expression, bool withDependencies)
{
return MakeQueryUnboundLambda(qvm, ImmutableArray.Create(parameter), expression, withDependencies);
}
private UnboundLambda MakeQueryUnboundLambda(RangeVariableMap qvm, ImmutableArray<RangeVariableSymbol> parameters, ExpressionSyntax expression, bool withDependencies)
{
return MakeQueryUnboundLambda(expression, new QueryUnboundLambdaState(this, qvm, parameters, delegate(LambdaSymbol lambdaSymbol, Binder lambdaBodyBinder, BindingDiagnosticBag diagnostics)
{
lambdaBodyBinder = lambdaBodyBinder.GetRequiredBinder((SyntaxNode)(object)expression);
BoundExpression result = lambdaBodyBinder.BindValue(expression, diagnostics, BindValueKind.RValue);
return lambdaBodyBinder.CreateLambdaBlockForQueryClause(expression, result, diagnostics);
}), withDependencies);
}
private UnboundLambda MakeQueryUnboundLambdaWithCast(RangeVariableMap qvm, RangeVariableSymbol parameter, ExpressionSyntax expression, TypeSyntax castTypeSyntax, TypeWithAnnotations castType, bool withDependencies)
{
return MakeQueryUnboundLambda(expression, new QueryUnboundLambdaState(this, qvm, ImmutableArray.Create(parameter), delegate(LambdaSymbol lambdaSymbol, Binder lambdaBodyBinder, BindingDiagnosticBag diagnostics)
{
lambdaBodyBinder = lambdaBodyBinder.GetRequiredBinder((SyntaxNode)(object)expression);
BoundExpression receiver = lambdaBodyBinder.BindValue(expression, diagnostics, BindValueKind.RValue);
receiver = lambdaBodyBinder.MakeQueryInvocation(expression, receiver, "Cast", castTypeSyntax, castType, diagnostics);
return lambdaBodyBinder.CreateLambdaBlockForQueryClause(expression, receiver, diagnostics);
}), withDependencies);
}
private UnboundLambda MakeQueryUnboundLambda(RangeVariableMap qvm, ImmutableArray<RangeVariableSymbol> parameters, CSharpSyntaxNode node, LambdaBodyFactory bodyFactory, bool withDependencies)
{
return MakeQueryUnboundLambda(node, new QueryUnboundLambdaState(this, qvm, parameters, bodyFactory), withDependencies);
}
private static UnboundLambda MakeQueryUnboundLambda(CSharpSyntaxNode node, QueryUnboundLambdaState state, bool withDependencies)
{
UnboundLambda unboundLambda = new UnboundLambda((SyntaxNode)(object)node, state, null, withDependencies, hasErrors: false)
{
WasCompilerGenerated = true
};
state.SetUnboundLambda(unboundLambda);
return unboundLambda;
}
protected BoundCall MakeQueryInvocation(CSharpSyntaxNode node, BoundExpression receiver, string methodName, BoundExpression arg, BindingDiagnosticBag diagnostics)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
return MakeQueryInvocation(node, receiver, methodName, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), ImmutableArray.Create(arg), diagnostics);
}
protected BoundCall MakeQueryInvocation(CSharpSyntaxNode node, BoundExpression receiver, string methodName, ImmutableArray<BoundExpression> args, BindingDiagnosticBag diagnostics)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
return MakeQueryInvocation(node, receiver, methodName, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), args, diagnostics);
}
protected BoundCall MakeQueryInvocation(CSharpSyntaxNode node, BoundExpression receiver, string methodName, TypeSyntax typeArgSyntax, TypeWithAnnotations typeArg, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
return MakeQueryInvocation(node, receiver, methodName, new SeparatedSyntaxList<TypeSyntax>(new SyntaxNodeOrTokenList((SyntaxNode)(object)typeArgSyntax, 0)), ImmutableArray.Create(typeArg), ImmutableArray<BoundExpression>.Empty, diagnostics);
}
protected BoundCall MakeQueryInvocation(CSharpSyntaxNode node, BoundExpression receiver, string methodName, SeparatedSyntaxList<TypeSyntax> typeArgsSyntax, ImmutableArray<TypeWithAnnotations> typeArgs, ImmutableArray<BoundExpression> args, BindingDiagnosticBag diagnostics)
{
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Invalid comparison between Unknown and I4
//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
BoundExpression boundExpression = receiver;
while (boundExpression.Kind == BoundKind.QueryClause)
{
boundExpression = ((BoundQueryClause)boundExpression).Value;
}
if ((object)boundExpression.Type == null)
{
if (!boundExpression.HasAnyErrors && !((SyntaxNode)node).HasErrors)
{
if (boundExpression.IsLiteralNull())
{
diagnostics.Add(ErrorCode.ERR_NullNotValid, ((SyntaxNode)node).Location);
}
else if (boundExpression.IsLiteralDefault())
{
diagnostics.Add(ErrorCode.ERR_DefaultLiteralNotValid, ((SyntaxNode)node).Location);
}
else if (boundExpression.IsImplicitObjectCreation())
{
diagnostics.Add(ErrorCode.ERR_ImplicitObjectCreationNotValid, ((SyntaxNode)node).Location);
}
else if (boundExpression.Kind == BoundKind.NamespaceExpression)
{
diagnostics.Add(ErrorCode.ERR_BadSKunknown, boundExpression.Syntax.Location, ((BoundNamespaceExpression)boundExpression).NamespaceSymbol, MessageID.IDS_SK_NAMESPACE.Localize());
}
else if (boundExpression.Kind == BoundKind.Lambda || boundExpression.Kind == BoundKind.UnboundLambda)
{
diagnostics.Add(ErrorCode.ERR_QueryNoProvider, ((SyntaxNode)node).Location, MessageID.IDS_AnonMethod.Localize(), methodName);
}
else if (boundExpression.Kind == BoundKind.MethodGroup)
{
BoundMethodGroup node2 = (BoundMethodGroup)boundExpression;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
MethodGroupResolution methodGroupResolution = ResolveMethodGroup(node2, null, isMethodGroupConversion: false, ref useSiteInfo, inferWithDynamic: false, (RefKind)0, null, isFunctionPointerResolution: false, default(CallingConventionInfo));
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(methodGroupResolution.Diagnostics, false);
if (methodGroupResolution.HasAnyErrors)
{
receiver = BindMemberAccessBadResult(node2);
}
else
{
diagnostics.Add(ErrorCode.ERR_QueryNoProvider, ((SyntaxNode)node).Location, MessageID.IDS_SK_METHOD.Localize(), methodName);
}
methodGroupResolution.Free();
}
}
receiver = new BoundBadExpression(receiver.Syntax, LookupResultKind.NotAValue, ImmutableArray<Symbol>.Empty, ImmutableArray.Create(receiver), CreateErrorType());
}
else if (boundExpression.Kind == BoundKind.TypeExpression)
{
if ((int)boundExpression.Type.TypeKind == 11)
{
Error(diagnostics, ErrorCode.ERR_BadSKunknown, SyntaxNodeOrToken.op_Implicit(boundExpression.Syntax), boundExpression.Type, MessageID.IDS_SK_TYVAR.Localize());
}
}
else if (boundExpression.Kind != BoundKind.TypeOrValueExpression)
{
if (receiver.Type.IsVoidType())
{
if (!receiver.HasAnyErrors && !((SyntaxNode)node).HasErrors)
{
diagnostics.Add(ErrorCode.ERR_QueryNoProvider, ((SyntaxNode)node).Location, "void", methodName);
}
receiver = new BoundBadExpression(receiver.Syntax, LookupResultKind.NotAValue, ImmutableArray<Symbol>.Empty, ImmutableArray.Create(receiver), CreateErrorType());
}
else
{
BoundExpression boundExpression2 = CheckValue(boundExpression, BindValueKind.RValue, diagnostics);
if (boundExpression2 != boundExpression)
{
receiver = updateUltimateReceiver(receiver, boundExpression, boundExpression2);
}
}
}
return (BoundCall)MakeInvocationExpression((SyntaxNode)(object)node, receiver, methodName, args, diagnostics, typeArgsSyntax, typeArgs, default(ImmutableArray<(string, Location)?>), node, allowFieldsAndProperties: true);
static BoundExpression updateUltimateReceiver(BoundExpression boundExpression3, BoundExpression originalUltimateReceiver, BoundExpression replacementUltimateReceiver)
{
if (boundExpression3 is BoundQueryClause boundQueryClause)
{
return boundQueryClause.Update(updateUltimateReceiver(boundQueryClause.Value, originalUltimateReceiver, replacementUltimateReceiver), boundQueryClause.DefinedSymbol, boundQueryClause.Operation, boundQueryClause.Cast, boundQueryClause.Binder, boundQueryClause.UnoptimizedForm, boundQueryClause.Type);
}
return replacementUltimateReceiver;
}
}
protected BoundExpression MakeConstruction(CSharpSyntaxNode node, NamedTypeSymbol toCreate, ImmutableArray<BoundExpression> args, BindingDiagnosticBag diagnostics)
{
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
instance.Arguments.AddRange(args);
BoundExpression boundExpression = BindClassCreationExpression((SyntaxNode)(object)node, toCreate.Name, (SyntaxNode)(object)node, toCreate, instance, diagnostics);
boundExpression.WasCompilerGenerated = true;
instance.Free();
return boundExpression;
}
internal void ReportQueryLookupFailed(SyntaxNode queryClause, BoundExpression instanceArgument, string name, ImmutableArray<Symbol> symbols, BindingDiagnosticBag diagnostics)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Expected O, but got Unknown
FromClauseSyntax fromClauseSyntax = null;
SyntaxNode val = queryClause;
QueryExpressionSyntax queryExpressionSyntax;
while (true)
{
queryExpressionSyntax = val as QueryExpressionSyntax;
if (queryExpressionSyntax != null)
{
break;
}
val = val.Parent;
}
fromClauseSyntax = queryExpressionSyntax.FromClause;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
if (instanceArgument.Type.IsDynamic())
{
diagnostics.Add((DiagnosticInfo?)(object)new DiagnosticInfoWithSymbols(ErrorCode.ERR_BadDynamicQuery, Array.Empty<object>(), symbols), (Location)new SourceLocation(queryClause));
}
else if (ImplementsStandardQueryInterface(instanceArgument.Type, name, ref useSiteInfo))
{
diagnostics.Add((DiagnosticInfo?)(object)new DiagnosticInfoWithSymbols(ErrorCode.ERR_QueryNoProviderStandard, new object[2] { instanceArgument.Type, name }, symbols), (Location)new SourceLocation((SyntaxNode)(object)((fromClauseSyntax != null) ? fromClauseSyntax.Expression : ((ExpressionSyntax)(object)queryClause))));
}
else if (fromClauseSyntax != null && fromClauseSyntax.Type == null && HasCastToQueryProvider(instanceArgument.Type, ref useSiteInfo))
{
object[] obj = new object[3] { instanceArgument.Type, name, null };
SyntaxToken identifier = fromClauseSyntax.Identifier;
obj[2] = ((SyntaxToken)(ref identifier)).ValueText;
diagnostics.Add((DiagnosticInfo?)(object)new DiagnosticInfoWithSymbols(ErrorCode.ERR_QueryNoProviderCastable, obj, symbols), (Location)new SourceLocation((SyntaxNode)(object)fromClauseSyntax.Expression));
}
else
{
diagnostics.Add((DiagnosticInfo?)(object)new DiagnosticInfoWithSymbols(ErrorCode.ERR_QueryNoProvider, new object[2] { instanceArgument.Type, name }, symbols), (Location)new SourceLocation((SyntaxNode)(object)((fromClauseSyntax != null) ? fromClauseSyntax.Expression : ((ExpressionSyntax)(object)queryClause))));
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(queryClause, useSiteInfo);
}
private bool ImplementsStandardQueryInterface(TypeSymbol instanceType, string name, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)instanceType.TypeKind == 1 || (name == "Cast" && HasCastToQueryProvider(instanceType, ref useSiteInfo)))
{
return true;
}
bool nonUnique = false;
TypeSymbol originalDefinition = instanceType.OriginalDefinition;
NamedTypeSymbol specialType = Compilation.GetSpecialType((SpecialType)25);
NamedTypeSymbol wellKnownType = Compilation.GetWellKnownType((WellKnownType)223);
bool flag = TypeSymbol.Equals(originalDefinition, specialType, (TypeCompareKind)0) || HasUniqueInterface(instanceType, specialType, ref nonUnique, ref useSiteInfo);
bool flag2 = TypeSymbol.Equals(originalDefinition, wellKnownType, (TypeCompareKind)0) || HasUniqueInterface(instanceType, wellKnownType, ref nonUnique, ref useSiteInfo);
if (flag != flag2)
{
return !nonUnique;
}
return false;
}
private static bool HasUniqueInterface(TypeSymbol instanceType, NamedTypeSymbol interfaceType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
bool nonUnique = false;
return HasUniqueInterface(instanceType, interfaceType, ref nonUnique, ref useSiteInfo);
}
private static bool HasUniqueInterface(TypeSymbol instanceType, NamedTypeSymbol interfaceType, ref bool nonUnique, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
TypeSymbol typeSymbol = null;
ImmutableArray<NamedTypeSymbol>.Enumerator enumerator = instanceType.AllInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteInfo).GetEnumerator();
while (enumerator.MoveNext())
{
NamedTypeSymbol current = enumerator.Current;
if (TypeSymbol.Equals(current.OriginalDefinition, interfaceType, (TypeCompareKind)0))
{
if ((object)typeSymbol == null)
{
typeSymbol = current;
}
else if (!TypeSymbol.Equals(typeSymbol, current, (TypeCompareKind)0))
{
nonUnique = true;
return false;
}
}
}
return (object)typeSymbol != null;
}
private bool HasCastToQueryProvider(TypeSymbol instanceType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
TypeSymbol originalDefinition = instanceType.OriginalDefinition;
NamedTypeSymbol specialType = Compilation.GetSpecialType((SpecialType)24);
NamedTypeSymbol wellKnownType = Compilation.GetWellKnownType((WellKnownType)222);
bool flag = TypeSymbol.Equals(originalDefinition, specialType, (TypeCompareKind)0) || HasUniqueInterface(instanceType, specialType, ref useSiteInfo);
bool flag2 = TypeSymbol.Equals(originalDefinition, wellKnownType, (TypeCompareKind)0) || HasUniqueInterface(instanceType, wellKnownType, ref useSiteInfo);
return flag != flag2;
}
private static bool IsJoinRangeVariableInLeftKey(SimpleNameSyntax node)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
for (CSharpSyntaxNode parent = node.Parent; parent != null; parent = parent.Parent)
{
if (parent.Kind() == SyntaxKind.JoinClause)
{
JoinClauseSyntax joinClauseSyntax = (JoinClauseSyntax)parent;
TextSpan span = ((SyntaxNode)joinClauseSyntax.LeftExpression).Span;
if (((TextSpan)(ref span)).Contains(((SyntaxNode)node).Span))
{
SyntaxToken identifier = joinClauseSyntax.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
identifier = node.Identifier;
if (valueText == ((SyntaxToken)(ref identifier)).ValueText)
{
return true;
}
}
}
}
return false;
}
private static bool IsInJoinRightKey(SimpleNameSyntax node)
{
//IL_0021: 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)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
for (CSharpSyntaxNode parent = node.Parent; parent != null; parent = parent.Parent)
{
if (parent.Kind() == SyntaxKind.JoinClause)
{
TextSpan span = ((SyntaxNode)((JoinClauseSyntax)parent).RightExpression).Span;
if (((TextSpan)(ref span)).Contains(((SyntaxNode)node).Span))
{
return true;
}
}
}
return false;
}
internal static void ReportQueryInferenceFailed(CSharpSyntaxNode queryClause, string methodName, BoundExpression receiver, AnalyzedArguments arguments, ImmutableArray<Symbol> symbols, BindingDiagnosticBag diagnostics)
{
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
string text = null;
bool flag = false;
switch (queryClause.Kind())
{
case SyntaxKind.JoinClause:
text = SyntaxFacts.GetText(SyntaxKind.JoinKeyword);
flag = true;
break;
case SyntaxKind.LetClause:
text = SyntaxFacts.GetText(SyntaxKind.LetKeyword);
break;
case SyntaxKind.SelectClause:
text = SyntaxFacts.GetText(SyntaxKind.SelectKeyword);
break;
case SyntaxKind.WhereClause:
text = SyntaxFacts.GetText(SyntaxKind.WhereKeyword);
break;
case SyntaxKind.OrderByClause:
case SyntaxKind.AscendingOrdering:
case SyntaxKind.DescendingOrdering:
text = SyntaxFacts.GetText(SyntaxKind.OrderByKeyword);
flag = true;
break;
case SyntaxKind.QueryContinuation:
text = SyntaxFacts.GetText(SyntaxKind.IntoKeyword);
break;
case SyntaxKind.GroupClause:
text = SyntaxFacts.GetText(SyntaxKind.GroupKeyword) + " " + SyntaxFacts.GetText(SyntaxKind.ByKeyword);
flag = true;
break;
case SyntaxKind.FromClause:
if (ReportQueryInferenceFailedSelectMany((FromClauseSyntax)queryClause, methodName, receiver, arguments, symbols, diagnostics))
{
return;
}
text = SyntaxFacts.GetText(SyntaxKind.FromKeyword);
break;
default:
throw ExceptionUtilities.UnexpectedValue((object)queryClause.Kind());
}
DiagnosticInfoWithSymbols info = new DiagnosticInfoWithSymbols(flag ? ErrorCode.ERR_QueryTypeInferenceFailedMulti : ErrorCode.ERR_QueryTypeInferenceFailed, new object[2] { text, methodName }, symbols);
SyntaxToken firstToken = queryClause.GetFirstToken();
diagnostics.Add((DiagnosticInfo?)(object)info, ((SyntaxToken)(ref firstToken)).GetLocation());
}
private static bool ReportQueryInferenceFailedSelectMany(FromClauseSyntax fromClause, string methodName, BoundExpression receiver, AnalyzedArguments arguments, ImmutableArray<Symbol> symbols, BindingDiagnosticBag diagnostics)
{
BoundExpression boundExpression = arguments.Argument(arguments.IsExtensionMethodInvocation ? 1 : 0);
TypeSymbol typeSymbol = null;
if (boundExpression.Kind == BoundKind.UnboundLambda)
{
foreach (TypeSymbol item in ((UnboundLambda)boundExpression).Data.InferredReturnTypes())
{
if (!item.IsErrorType())
{
typeSymbol = item;
break;
}
}
}
if ((object)typeSymbol == null || typeSymbol.IsErrorType())
{
return false;
}
TypeSymbol typeSymbol2 = receiver?.Type;
diagnostics.Add((DiagnosticInfo?)(object)new DiagnosticInfoWithSymbols(ErrorCode.ERR_QueryTypeInferenceFailedSelectMany, new object[3] { typeSymbol, typeSymbol2, methodName }, symbols), ((SyntaxNode)fromClause.Expression).Location);
return true;
}
public virtual BoundStatement BindStatement(StatementSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_0017: Unknown result type (might be due to invalid IL or missing references)
if (node.AttributeLists.Count > 0)
{
AttributeListSyntax syntax = node.AttributeLists[0];
if (node.Kind() == SyntaxKind.LocalFunctionStatement)
{
CheckFeatureAvailability((SyntaxNode)(object)syntax, MessageID.IDS_FeatureLocalFunctionAttributes, diagnostics);
}
else if (node.Kind() != SyntaxKind.Block)
{
Error(diagnostics, ErrorCode.ERR_AttributesNotAllowed, (CSharpSyntaxNode)syntax);
}
}
switch (node.Kind())
{
case SyntaxKind.Block:
return BindBlock((BlockSyntax)node, diagnostics);
case SyntaxKind.LocalDeclarationStatement:
return BindLocalDeclarationStatement((LocalDeclarationStatementSyntax)node, diagnostics);
case SyntaxKind.LocalFunctionStatement:
return BindLocalFunctionStatement((LocalFunctionStatementSyntax)node, diagnostics);
case SyntaxKind.ExpressionStatement:
return BindExpressionStatement((ExpressionStatementSyntax)node, diagnostics);
case SyntaxKind.IfStatement:
return BindIfStatement((IfStatementSyntax)node, diagnostics);
case SyntaxKind.SwitchStatement:
return BindSwitchStatement((SwitchStatementSyntax)node, diagnostics);
case SyntaxKind.DoStatement:
return BindDo((DoStatementSyntax)node, diagnostics);
case SyntaxKind.WhileStatement:
return BindWhile((WhileStatementSyntax)node, diagnostics);
case SyntaxKind.ForStatement:
return BindFor((ForStatementSyntax)node, diagnostics);
case SyntaxKind.ForEachStatement:
case SyntaxKind.ForEachVariableStatement:
return BindForEach((CommonForEachStatementSyntax)node, diagnostics);
case SyntaxKind.BreakStatement:
return BindBreak((BreakStatementSyntax)node, diagnostics);
case SyntaxKind.ContinueStatement:
return BindContinue((ContinueStatementSyntax)node, diagnostics);
case SyntaxKind.ReturnStatement:
return BindReturn((ReturnStatementSyntax)node, diagnostics);
case SyntaxKind.FixedStatement:
return BindFixedStatement((FixedStatementSyntax)node, diagnostics);
case SyntaxKind.LabeledStatement:
return BindLabeled((LabeledStatementSyntax)node, diagnostics);
case SyntaxKind.GotoStatement:
case SyntaxKind.GotoCaseStatement:
case SyntaxKind.GotoDefaultStatement:
return BindGoto((GotoStatementSyntax)node, diagnostics);
case SyntaxKind.TryStatement:
return BindTryStatement((TryStatementSyntax)node, diagnostics);
case SyntaxKind.EmptyStatement:
return BindEmpty((EmptyStatementSyntax)node);
case SyntaxKind.ThrowStatement:
return BindThrow((ThrowStatementSyntax)node, diagnostics);
case SyntaxKind.UnsafeStatement:
return BindUnsafeStatement((UnsafeStatementSyntax)node, diagnostics);
case SyntaxKind.CheckedStatement:
case SyntaxKind.UncheckedStatement:
return BindCheckedStatement((CheckedStatementSyntax)node, diagnostics);
case SyntaxKind.UsingStatement:
return BindUsingStatement((UsingStatementSyntax)node, diagnostics);
case SyntaxKind.YieldBreakStatement:
return BindYieldBreakStatement((YieldStatementSyntax)node, diagnostics);
case SyntaxKind.YieldReturnStatement:
return BindYieldReturnStatement((YieldStatementSyntax)node, diagnostics);
case SyntaxKind.LockStatement:
return BindLockStatement((LockStatementSyntax)node, diagnostics);
default:
return new BoundBadStatement((SyntaxNode)(object)node, ImmutableArray<BoundNode>.Empty, hasErrors: true);
}
}
private BoundStatement BindCheckedStatement(CheckedStatementSyntax node, BindingDiagnosticBag diagnostics)
{
return BindEmbeddedBlock(node.Block, diagnostics);
}
private BoundStatement BindUnsafeStatement(UnsafeStatementSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
GetBinder((SyntaxNode)(object)node);
if (!Compilation.Options.AllowUnsafe)
{
Error(diagnostics, ErrorCode.ERR_IllegalUnsafe, node.UnsafeKeyword);
}
else if (IsIndirectlyInIterator)
{
Error(diagnostics, ErrorCode.ERR_IllegalInnerUnsafe, node.UnsafeKeyword);
}
return BindEmbeddedBlock(node.Block, diagnostics);
}
private BoundStatement BindFixedStatement(FixedStatementSyntax node, BindingDiagnosticBag diagnostics)
{
Binder? binder = GetBinder((SyntaxNode)(object)node);
binder.ReportUnsafeIfNotAllowed((SyntaxNode)(object)node, diagnostics);
return binder.BindFixedStatementParts(node, diagnostics);
}
private BoundStatement BindFixedStatementParts(FixedStatementSyntax node, BindingDiagnosticBag diagnostics)
{
VariableDeclarationSyntax declaration = node.Declaration;
BindForOrUsingOrFixedDeclarations(declaration, LocalDeclarationKind.FixedVariable, diagnostics, out var declarations);
BoundMultipleLocalDeclarations declarations2 = new BoundMultipleLocalDeclarations((SyntaxNode)(object)declaration, declarations);
BoundStatement body = BindPossibleEmbeddedStatement(node.Statement, diagnostics);
return new BoundFixedStatement((SyntaxNode)(object)node, GetDeclaredLocalsForScope((SyntaxNode)(object)node), declarations2, body);
}
private void CheckRequiredLangVersionForIteratorMethods(YieldStatementSyntax statement, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureIterators.CheckFeatureAvailability(diagnostics, statement.YieldKeyword);
MethodSymbol methodSymbol = (MethodSymbol)ContainingMemberOrLambda;
if (methodSymbol.IsAsync)
{
MessageID.IDS_FeatureAsyncStreams.CheckFeatureAvailability(diagnostics, (Compilation)(object)methodSymbol.DeclaringCompilation, methodSymbol.GetFirstLocation());
}
}
protected virtual void ValidateYield(YieldStatementSyntax node, BindingDiagnosticBag diagnostics)
{
Next?.ValidateYield(node, diagnostics);
}
private BoundStatement BindYieldReturnStatement(YieldStatementSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
ValidateYield(node, diagnostics);
TypeSymbol type = GetIteratorElementType().Type;
BoundExpression boundExpression = ((node.Expression == null) ? BadExpression((SyntaxNode)(object)node).MakeCompilerGenerated() : BindValue(node.Expression, diagnostics, BindValueKind.RValue));
boundExpression = (boundExpression.HasAnyErrors ? BindToTypeForErrorRecovery(boundExpression) : GenerateConversionForAssignment(type, boundExpression, diagnostics));
if (Flags.Includes(BinderFlags.InFinallyBlock))
{
Error(diagnostics, ErrorCode.ERR_BadYieldInFinally, node.YieldKeyword);
}
else if (Flags.Includes(BinderFlags.InTryBlockOfTryCatch))
{
Error(diagnostics, ErrorCode.ERR_BadYieldInTryOfCatch, node.YieldKeyword);
}
else if (Flags.Includes(BinderFlags.InCatchBlock))
{
Error(diagnostics, ErrorCode.ERR_BadYieldInCatch, node.YieldKeyword);
}
else if (BindingTopLevelScriptCode)
{
Error(diagnostics, ErrorCode.ERR_YieldNotAllowedInScript, node.YieldKeyword);
}
CheckRequiredLangVersionForIteratorMethods(node, diagnostics);
return new BoundYieldReturnStatement((SyntaxNode)(object)node, boundExpression);
}
private BoundStatement BindYieldBreakStatement(YieldStatementSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (Flags.Includes(BinderFlags.InFinallyBlock))
{
Error(diagnostics, ErrorCode.ERR_BadYieldInFinally, node.YieldKeyword);
}
else if (BindingTopLevelScriptCode)
{
Error(diagnostics, ErrorCode.ERR_YieldNotAllowedInScript, node.YieldKeyword);
}
ValidateYield(node, diagnostics);
CheckRequiredLangVersionForIteratorMethods(node, diagnostics);
return new BoundYieldBreakStatement((SyntaxNode)(object)node);
}
private BoundStatement BindLockStatement(LockStatementSyntax node, BindingDiagnosticBag diagnostics)
{
Binder binder = GetBinder((SyntaxNode)(object)node);
return binder.BindLockStatementParts(diagnostics, binder);
}
internal virtual BoundStatement BindLockStatementParts(BindingDiagnosticBag diagnostics, Binder originalBinder)
{
return Next.BindLockStatementParts(diagnostics, originalBinder);
}
private BoundStatement BindUsingStatement(UsingStatementSyntax node, BindingDiagnosticBag diagnostics)
{
Binder binder = GetBinder((SyntaxNode)(object)node);
return binder.BindUsingStatementParts(diagnostics, binder);
}
internal virtual BoundStatement BindUsingStatementParts(BindingDiagnosticBag diagnostics, Binder originalBinder)
{
return Next.BindUsingStatementParts(diagnostics, originalBinder);
}
internal BoundStatement BindPossibleEmbeddedStatement(StatementSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
switch (node.Kind())
{
case SyntaxKind.LocalDeclarationStatement:
diagnostics.Add(ErrorCode.ERR_BadEmbeddedStmt, node.GetLocation());
goto case SyntaxKind.ExpressionStatement;
case SyntaxKind.ExpressionStatement:
case SyntaxKind.ReturnStatement:
case SyntaxKind.YieldReturnStatement:
case SyntaxKind.ThrowStatement:
case SyntaxKind.LockStatement:
case SyntaxKind.IfStatement:
{
Binder binder = GetBinder((SyntaxNode)(object)node);
return binder.WrapWithVariablesIfAny(node, binder.BindStatement(node, diagnostics));
}
case SyntaxKind.LabeledStatement:
case SyntaxKind.LocalFunctionStatement:
{
diagnostics.Add(ErrorCode.ERR_BadEmbeddedStmt, node.GetLocation());
Binder binder = GetBinder((SyntaxNode)(object)node);
return binder.WrapWithVariablesAndLocalFunctionsIfAny(node, binder.BindStatement(node, diagnostics));
}
case SyntaxKind.SwitchStatement:
{
SwitchStatementSyntax switchStatementSyntax = (SwitchStatementSyntax)node;
Binder binder = GetBinder((SyntaxNode)(object)switchStatementSyntax.Expression);
return binder.WrapWithVariablesIfAny(switchStatementSyntax.Expression, binder.BindStatement(node, diagnostics));
}
case SyntaxKind.EmptyStatement:
{
EmptyStatementSyntax emptyStatementSyntax = (EmptyStatementSyntax)node;
SyntaxToken semicolonToken = emptyStatementSyntax.SemicolonToken;
if (((SyntaxToken)(ref semicolonToken)).IsMissing)
{
break;
}
SyntaxKind syntaxKind = node.Parent.Kind();
if (syntaxKind == SyntaxKind.WhileStatement || syntaxKind - 8811 <= SyntaxKind.List || syntaxKind == SyntaxKind.ForEachVariableStatement)
{
semicolonToken = emptyStatementSyntax.SemicolonToken;
if (((SyntaxToken)(ref semicolonToken)).GetNextToken(false, false, false, false).Kind() != SyntaxKind.OpenBraceToken)
{
break;
}
}
diagnostics.Add(ErrorCode.WRN_PossibleMistakenNullStatement, node.GetLocation());
break;
}
}
return BindStatement(node, diagnostics);
}
private BoundExpression BindThrownExpression(ExpressionSyntax exprSyntax, BindingDiagnosticBag diagnostics, ref bool hasErrors)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
BoundExpression boundExpression = BindValue(exprSyntax, diagnostics, BindValueKind.RValue);
if (Compilation.LanguageVersion < MessageID.IDS_FeatureSwitchExpression.RequiredVersion())
{
if (!boundExpression.IsLiteralNull())
{
boundExpression = BindToNaturalType(boundExpression, diagnostics);
TypeSymbol type = boundExpression.Type;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
if ((object)type == null || (!type.IsErrorType() && !Compilation.IsExceptionType(type.EffectiveType(ref useSiteInfo), ref useSiteInfo)))
{
diagnostics.Add(ErrorCode.ERR_BadExceptionType, ((SyntaxNode)exprSyntax).Location);
hasErrors = true;
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)exprSyntax, useSiteInfo);
}
else
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddDependencies(useSiteInfo);
}
}
}
else
{
boundExpression = GenerateConversionForAssignment(GetWellKnownType((WellKnownType)52, diagnostics, (SyntaxNode)(object)exprSyntax), boundExpression, diagnostics);
}
return boundExpression;
}
private BoundStatement BindThrow(ThrowStatementSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
BoundExpression expressionOpt = null;
bool hasErrors = false;
ExpressionSyntax expression = node.Expression;
SyntaxToken throwKeyword;
if (expression != null)
{
expressionOpt = BindThrownExpression(expression, diagnostics, ref hasErrors);
}
else if (!Flags.Includes(BinderFlags.InCatchBlock))
{
throwKeyword = node.ThrowKeyword;
diagnostics.Add(ErrorCode.ERR_BadEmptyThrow, ((SyntaxToken)(ref throwKeyword)).GetLocation());
hasErrors = true;
}
else if (Flags.Includes(BinderFlags.InNestedFinallyBlock))
{
throwKeyword = node.ThrowKeyword;
diagnostics.Add(ErrorCode.ERR_BadEmptyThrowInFinally, ((SyntaxToken)(ref throwKeyword)).GetLocation());
hasErrors = true;
}
return new BoundThrowStatement((SyntaxNode)(object)node, expressionOpt, hasErrors);
}
private static BoundStatement BindEmpty(EmptyStatementSyntax node)
{
return new BoundNoOpStatement((SyntaxNode)(object)node, NoOpStatementFlavor.Default);
}
private BoundLabeledStatement BindLabeled(LabeledStatementSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: 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_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
bool hasErrors = false;
LookupResult instance = LookupResult.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
SyntaxToken identifier = node.Identifier;
Binder binder = LookupSymbolsWithFallback(instance, ((SyntaxToken)(ref identifier)).ValueText, 0, ref useSiteInfo, null, LookupOptions.LabelsOnly);
LabelSymbol labelSymbol = ((instance.Symbols.Count > 0 && instance.IsMultiViable) ? ((LabelSymbol)instance.Symbols.First()) : new SourceLabelSymbol((MethodSymbol)ContainingMemberOrLambda, SyntaxNodeOrToken.op_Implicit(node.Identifier)));
SyntaxNodeOrToken identifierNodeOrToken = labelSymbol.IdentifierNodeOrToken;
if (((SyntaxNodeOrToken)(ref identifierNodeOrToken)).IsToken)
{
identifierNodeOrToken = labelSymbol.IdentifierNodeOrToken;
if (!(((SyntaxNodeOrToken)(ref identifierNodeOrToken)).AsToken() != node.Identifier))
{
goto IL_00d0;
}
}
SyntaxToken identifier2 = node.Identifier;
object[] array = new object[1];
identifier = node.Identifier;
array[0] = ((SyntaxToken)(ref identifier)).ValueText;
Error(diagnostics, ErrorCode.ERR_DuplicateLabel, identifier2, array);
hasErrors = true;
goto IL_00d0;
IL_00d0:
if (binder != null)
{
instance.Clear();
Binder? next = binder.Next;
identifier = node.Identifier;
next.LookupSymbolsWithFallback(instance, ((SyntaxToken)(ref identifier)).ValueText, 0, ref useSiteInfo, null, LookupOptions.LabelsOnly);
if (instance.IsMultiViable)
{
SyntaxToken identifier3 = node.Identifier;
object[] array2 = new object[1];
identifier = node.Identifier;
array2[0] = ((SyntaxToken)(ref identifier)).ValueText;
Error(diagnostics, ErrorCode.ERR_LabelShadow, identifier3, array2);
hasErrors = true;
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
instance.Free();
BoundStatement body = BindStatement(node.Statement, diagnostics);
return new BoundLabeledStatement((SyntaxNode)(object)node, labelSymbol, body, hasErrors);
}
private BoundStatement BindGoto(GotoStatementSyntax node, BindingDiagnosticBag diagnostics)
{
switch (node.Kind())
{
case SyntaxKind.GotoStatement:
{
BoundExpression boundExpression = BindLabel(node.Expression, diagnostics);
if (!(boundExpression is BoundLabel boundLabel))
{
return new BoundBadStatement((SyntaxNode)(object)node, ImmutableArray.Create((BoundNode)boundExpression), hasErrors: true);
}
LabelSymbol label = boundLabel.Label;
return new BoundGotoStatement((SyntaxNode)(object)node, label, null, boundLabel);
}
case SyntaxKind.GotoCaseStatement:
case SyntaxKind.GotoDefaultStatement:
{
SwitchBinder switchBinder = GetSwitchBinder(this);
if (switchBinder == null)
{
Error(diagnostics, ErrorCode.ERR_InvalidGotoCase, (CSharpSyntaxNode)node);
ImmutableArray<BoundNode> childBoundNodes = ((node.Expression == null) ? ImmutableArray<BoundNode>.Empty : ImmutableArray.Create((BoundNode)BindRValueWithoutTargetType(node.Expression, BindingDiagnosticBag.Discarded)));
return new BoundBadStatement((SyntaxNode)(object)node, childBoundNodes, hasErrors: true);
}
return switchBinder.BindGotoCaseOrDefault(node, this, diagnostics);
}
default:
throw ExceptionUtilities.UnexpectedValue((object)node.Kind());
}
}
private BoundStatement BindLocalFunctionStatement(LocalFunctionStatementSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_000f: 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)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureLocalFunctions.CheckFeatureAvailability(diagnostics, node.Identifier);
LocalFunctionSymbol localSymbol = LookupLocalFunction(node.Identifier);
bool flag = localSymbol.ScopeBinder.ValidateDeclarationNameConflictsInScope(localSymbol, diagnostics);
BoundBlock boundBlock = null;
BoundBlock boundBlock2 = null;
if (node.Body != null)
{
boundBlock = runAnalysis(BindEmbeddedBlock(node.Body, diagnostics), diagnostics);
if (node.ExpressionBody != null)
{
boundBlock2 = runAnalysis(BindExpressionBodyAsBlock(node.ExpressionBody, BindingDiagnosticBag.Discarded), BindingDiagnosticBag.Discarded);
}
}
else if (node.ExpressionBody != null)
{
boundBlock2 = runAnalysis(BindExpressionBodyAsBlock(node.ExpressionBody, diagnostics), diagnostics);
}
else if (!flag && (!localSymbol.IsExtern || !localSymbol.IsStatic))
{
flag = true;
diagnostics.Add(ErrorCode.ERR_LocalFunctionMissingBody, localSymbol.GetFirstLocation(), localSymbol);
}
if (!flag && (boundBlock != null || boundBlock2 != null) && localSymbol.IsExtern)
{
flag = true;
diagnostics.Add(ErrorCode.ERR_ExternHasBody, localSymbol.GetFirstLocation(), localSymbol);
}
localSymbol.GetDeclarationDiagnostics(diagnostics);
Symbol.CheckForBlockAndExpressionBody(node.Body, node.ExpressionBody, node, diagnostics);
SyntaxTokenList modifiers = node.Modifiers;
Enumerator enumerator = ((SyntaxTokenList)(ref modifiers)).GetEnumerator();
while (((Enumerator)(ref enumerator)).MoveNext())
{
SyntaxToken current = ((Enumerator)(ref enumerator)).Current;
if (current.IsKind(SyntaxKind.StaticKeyword))
{
MessageID.IDS_FeatureStaticLocalFunctions.CheckFeatureAvailability(diagnostics, current);
}
else if (current.IsKind(SyntaxKind.ExternKeyword))
{
MessageID.IDS_FeatureExternLocalFunctions.CheckFeatureAvailability(diagnostics, current);
}
}
return new BoundLocalFunctionStatement((SyntaxNode)(object)node, localSymbol, boundBlock, boundBlock2, flag);
BoundBlock runAnalysis(BoundBlock block, BindingDiagnosticBag blockDiagnostics)
{
if (block != null)
{
DiagnosticBag instance = DiagnosticBag.GetInstance();
bool num = ControlFlowPass.Analyze(localSymbol.DeclaringCompilation, localSymbol, block, instance);
instance.Free();
if (num)
{
if (ImplicitReturnIsOkay(localSymbol))
{
block = FlowAnalysisPass.AppendImplicitReturn(block, localSymbol);
}
else
{
blockDiagnostics.Add(ErrorCode.ERR_ReturnExpected, localSymbol.GetFirstLocation(), localSymbol);
}
}
}
return block;
}
}
private bool ImplicitReturnIsOkay(MethodSymbol method)
{
if (!method.ReturnsVoid && !method.IsIterator)
{
return method.IsAsyncEffectivelyReturningTask(Compilation);
}
return true;
}
public BoundStatement BindExpressionStatement(ExpressionStatementSyntax node, BindingDiagnosticBag diagnostics)
{
return BindExpressionStatement(node, node.Expression, node.AllowsAnyExpression, diagnostics);
}
private BoundExpressionStatement BindExpressionStatement(CSharpSyntaxNode node, ExpressionSyntax syntax, bool allowsAnyExpression, BindingDiagnosticBag diagnostics)
{
BoundExpression boundExpression = BindRValueWithoutTargetType(syntax, diagnostics);
ReportSuppressionIfNeeded(boundExpression, diagnostics);
BoundExpressionStatement result;
if (!allowsAnyExpression && !IsValidStatementExpression((SyntaxNode)(object)syntax, boundExpression))
{
if (!((SyntaxNode)node).HasErrors)
{
Error(diagnostics, ErrorCode.ERR_IllegalStatement, (CSharpSyntaxNode)syntax);
}
result = new BoundExpressionStatement((SyntaxNode)(object)node, boundExpression, hasErrors: true);
}
else
{
result = new BoundExpressionStatement((SyntaxNode)(object)node, boundExpression);
}
CheckForUnobservedAwaitable(boundExpression, diagnostics);
return result;
}
private void CheckForUnobservedAwaitable(BoundExpression expression, BindingDiagnosticBag diagnostics)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (CouldBeAwaited(expression))
{
Error(diagnostics, ErrorCode.WRN_UnobservedAwaitableExpression, SyntaxNodeOrToken.op_Implicit(expression.Syntax));
}
}
internal BoundStatement BindLocalDeclarationStatement(LocalDeclarationStatementSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
if (node.UsingKeyword != default(SyntaxToken))
{
return BindUsingDeclarationStatementParts(node, diagnostics);
}
return BindDeclarationStatementParts(node, diagnostics);
}
private BoundStatement BindUsingDeclarationStatementParts(LocalDeclarationStatementSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
return UsingStatementBinder.BindUsingStatementOrDeclarationFromParts((SyntaxNode)(object)node, node.UsingKeyword, node.AwaitKeyword, this, null, diagnostics);
}
private BoundStatement BindDeclarationStatementParts(LocalDeclarationStatementSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
TypeSyntax type = node.Declaration.Type;
bool isConst = node.IsConst;
if (type is ScopedTypeSyntax scopedTypeSyntax)
{
ModifierUtils.CheckScopedModifierAvailability(node, scopedTypeSyntax.ScopedKeyword, diagnostics);
type = scopedTypeSyntax.Type;
}
type = type.SkipRefInLocalOrReturn(diagnostics, out var _);
bool isVar;
AliasSymbol alias;
TypeWithAnnotations declTypeOpt = BindVariableTypeWithAnnotations(node.Declaration, diagnostics, type, ref isConst, out isVar, out alias);
LocalDeclarationKind kind = ((!isConst) ? LocalDeclarationKind.RegularVariable : LocalDeclarationKind.Constant);
SeparatedSyntaxList<VariableDeclaratorSyntax> variables = node.Declaration.Variables;
int count = variables.Count;
if (count == 1)
{
return BindVariableDeclaration(kind, isVar, variables[0], type, declTypeOpt, alias, diagnostics, includeBoundType: true, node);
}
BoundLocalDeclaration[] array = new BoundLocalDeclaration[count];
int num = 0;
Enumerator<VariableDeclaratorSyntax> enumerator = variables.GetEnumerator();
while (enumerator.MoveNext())
{
VariableDeclaratorSyntax current = enumerator.Current;
bool includeBoundType = num == 0;
array[num++] = BindVariableDeclaration(kind, isVar, current, type, declTypeOpt, alias, diagnostics, includeBoundType);
}
return new BoundMultipleLocalDeclarations((SyntaxNode)(object)node, ImmutableArrayExtensions.AsImmutableOrNull<BoundLocalDeclaration>(array));
}
internal MethodSymbol TryFindDisposePatternMethod(BoundExpression expr, SyntaxNode syntaxNode, bool hasAwait, BindingDiagnosticBag diagnostics)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
MethodSymbol result;
PatternLookupResult patternLookupResult = PerformPatternMethodLookup(expr, hasAwait ? "DisposeAsync" : "Dispose", syntaxNode, diagnostics, out result);
if ((object)result != null && result.IsExtensionMethod)
{
return null;
}
if ((!hasAwait && (object)result != null && !result.ReturnsVoid) || patternLookupResult == PatternLookupResult.NotAMethod)
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
if (IsAccessible(result, ref useSiteInfo))
{
diagnostics.Add(ErrorCode.WRN_PatternBadSignature, syntaxNode.Location, expr.Type, MessageID.IDS_Disposable.Localize(), result);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(syntaxNode, useSiteInfo);
return null;
}
return result;
}
private TypeWithAnnotations BindVariableTypeWithAnnotations(CSharpSyntaxNode declarationNode, BindingDiagnosticBag diagnostics, TypeSyntax typeSyntax, ref bool isConst, out bool isVar, out AliasSymbol alias)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
bool isScoped;
TypeWithAnnotations result = BindTypeOrVarKeyword(typeSyntax.SkipScoped(out isScoped).SkipRef(), diagnostics, out isVar, out alias);
if (isVar)
{
if (isConst)
{
Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableCannotBeConst, declarationNode);
isConst = false;
}
if (declarationNode.Parent.Kind() == SyntaxKind.LocalDeclarationStatement && ((VariableDeclarationSyntax)declarationNode).Variables.Count > 1 && !((SyntaxNode)declarationNode).HasErrors)
{
Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableMultipleDeclarator, declarationNode);
}
}
else
{
if (result.IsStatic)
{
Error(diagnostics, ErrorCode.ERR_VarDeclIsStaticClass, (CSharpSyntaxNode)typeSyntax, new object[1] { result.Type });
}
if (isConst && !result.Type.CanBeConst())
{
Error(diagnostics, ErrorCode.ERR_BadConstType, (CSharpSyntaxNode)typeSyntax, new object[1] { result.Type });
isConst = false;
}
}
return result;
}
internal BoundExpression BindInferredVariableInitializer(BindingDiagnosticBag diagnostics, RefKind refKind, EqualsValueClauseSyntax initializer, CSharpSyntaxNode errorSyntax)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
IsInitializerRefKindValid(initializer, initializer, refKind, diagnostics, out var valueKind, out var value);
return BindInferredVariableInitializer(diagnostics, value, valueKind, errorSyntax);
}
protected BoundExpression BindInferredVariableInitializer(BindingDiagnosticBag diagnostics, ExpressionSyntax initializer, BindValueKind valueKind, CSharpSyntaxNode errorSyntax)
{
if (initializer == null)
{
if (!((SyntaxNode)errorSyntax).HasErrors)
{
Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableWithNoInitializer, errorSyntax);
}
return null;
}
if (initializer.Kind() == SyntaxKind.ArrayInitializerExpression)
{
BoundArrayInitialization expr = BindUnexpectedArrayInitializer((InitializerExpressionSyntax)initializer, diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableAssignedArrayInitializer, errorSyntax);
return CheckValue(expr, valueKind, diagnostics);
}
BoundExpression boundExpression = BindValue(initializer, diagnostics, valueKind);
BoundKind kind = boundExpression.Kind;
bool flag = ((kind == BoundKind.MethodGroup || kind == BoundKind.UnboundLambda) ? true : false);
BoundExpression boundExpression2 = (flag ? BindToInferredDelegateType(boundExpression, diagnostics) : BindToNaturalType(boundExpression, diagnostics));
if (!boundExpression2.HasAnyErrors && !boundExpression2.HasExpressionType())
{
Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableAssignedBadValue, errorSyntax, boundExpression2.Display);
}
return boundExpression2;
}
private static bool IsInitializerRefKindValid(EqualsValueClauseSyntax initializer, CSharpSyntaxNode node, RefKind variableRefKind, BindingDiagnosticBag diagnostics, out BindValueKind valueKind, out ExpressionSyntax value)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Invalid comparison between Unknown and I4
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Invalid comparison between Unknown and I4
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Invalid comparison between Unknown and I4
RefKind refKind = (RefKind)0;
value = initializer?.Value.CheckAndUnwrapRefExpression(diagnostics, out refKind);
if ((int)variableRefKind == 0)
{
valueKind = BindValueKind.RValue;
if ((int)refKind == 1)
{
Error(diagnostics, ErrorCode.ERR_InitializeByValueVariableWithReference, node);
return false;
}
}
else
{
valueKind = (((int)variableRefKind == 3) ? BindValueKind.ReadonlyRef : BindValueKind.RefOrOut);
if (initializer == null)
{
Error(diagnostics, ErrorCode.ERR_ByReferenceVariableMustBeInitialized, node);
return false;
}
if ((int)refKind != 1)
{
Error(diagnostics, ErrorCode.ERR_InitializeByReferenceVariableWithValue, node);
return false;
}
}
return true;
}
protected BoundLocalDeclaration BindVariableDeclaration(LocalDeclarationKind kind, bool isVar, VariableDeclaratorSyntax declarator, TypeSyntax typeSyntax, TypeWithAnnotations declTypeOpt, AliasSymbol aliasOpt, BindingDiagnosticBag diagnostics, bool includeBoundType, CSharpSyntaxNode associatedSyntaxNode = null)
{
return BindVariableDeclaration(LocateDeclaredVariableSymbol(declarator, typeSyntax, kind), kind, isVar, declarator, typeSyntax, declTypeOpt, aliasOpt, diagnostics, includeBoundType, associatedSyntaxNode);
}
protected BoundLocalDeclaration BindVariableDeclaration(SourceLocalSymbol localSymbol, LocalDeclarationKind kind, bool isVar, VariableDeclaratorSyntax declarator, TypeSyntax typeSyntax, TypeWithAnnotations declTypeOpt, AliasSymbol aliasOpt, BindingDiagnosticBag diagnostics, bool includeBoundType, CSharpSyntaxNode associatedSyntaxNode = null)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Invalid comparison between Unknown and I4
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(withDiagnostics: true, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
associatedSyntaxNode = associatedSyntaxNode ?? declarator;
bool flag = localSymbol.ScopeBinder.ValidateDeclarationNameConflictsInScope(localSymbol, diagnostics);
bool flag2 = false;
if ((int)localSymbol.RefKind != 0)
{
CheckRefLocalInAsyncOrIteratorMethod(localSymbol.IdentifierToken, diagnostics);
}
EqualsValueClauseSyntax initializer = declarator.Initializer;
if (!IsInitializerRefKindValid(initializer, declarator, localSymbol.RefKind, diagnostics, out var valueKind, out var value))
{
flag2 = true;
}
BoundExpression initializerOpt;
if (isVar)
{
aliasOpt = null;
initializerOpt = BindInferredVariableInitializer(diagnostics, value, valueKind, declarator);
TypeSymbol typeSymbol = initializerOpt?.Type;
if ((object)typeSymbol != null)
{
declTypeOpt = TypeWithAnnotations.Create(typeSymbol);
if (declTypeOpt.IsVoidType())
{
Error(instance, ErrorCode.ERR_ImplicitlyTypedVariableAssignedBadValue, (CSharpSyntaxNode)declarator, new object[1] { declTypeOpt.Type });
declTypeOpt = TypeWithAnnotations.Create(CreateErrorType("var"));
flag2 = true;
}
if (!declTypeOpt.Type.IsErrorType() && declTypeOpt.IsStatic)
{
Error(instance, ErrorCode.ERR_VarDeclIsStaticClass, (CSharpSyntaxNode)typeSyntax, new object[1] { typeSymbol });
flag2 = true;
}
}
else
{
declTypeOpt = TypeWithAnnotations.Create(CreateErrorType("var"));
flag2 = true;
}
}
else if (initializer == null)
{
initializerOpt = null;
}
else
{
initializerOpt = BindPossibleArrayInitializer(value, declTypeOpt.Type, valueKind, diagnostics);
if (kind != LocalDeclarationKind.FixedVariable)
{
initializerOpt = GenerateConversionForAssignment(declTypeOpt.Type, initializerOpt, instance, ((int)localSymbol.RefKind != 0) ? ConversionForAssignmentFlags.RefAssignment : ConversionForAssignmentFlags.None);
}
}
if (kind == LocalDeclarationKind.FixedVariable)
{
if (isVar && !flag2)
{
Error(instance, ErrorCode.ERR_ImplicitlyTypedLocalCannotBeFixed, (CSharpSyntaxNode)declarator);
flag2 = true;
}
if (!declTypeOpt.Type.IsPointerType())
{
if (!flag2)
{
Error(instance, declTypeOpt.Type.IsFunctionPointer() ? ErrorCode.ERR_CannotUseFunctionPointerAsFixedLocal : ErrorCode.ERR_BadFixedInitType, (CSharpSyntaxNode)declarator);
flag2 = true;
}
}
else if (!IsValidFixedVariableInitializer(declTypeOpt.Type, ref initializerOpt, instance))
{
flag2 = true;
}
}
CheckRestrictedTypeInAsyncMethod(ContainingMemberOrLambda, declTypeOpt.Type, instance, (SyntaxNode)(object)typeSyntax);
if ((int)localSymbol.Scope == 2 && !declTypeOpt.Type.IsErrorTypeOrRefLikeType())
{
instance.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly, ((SyntaxNode)typeSyntax).Location);
}
localSymbol.SetTypeWithAnnotations(declTypeOpt);
ImmutableArray<BoundExpression> argumentsOpt = BindDeclaratorArguments(declarator, instance);
switch (kind)
{
case LocalDeclarationKind.FixedVariable:
case LocalDeclarationKind.UsingVariable:
if (initializerOpt == null)
{
Error(instance, ErrorCode.ERR_FixedMustInit, (CSharpSyntaxNode)declarator);
flag2 = true;
}
break;
case LocalDeclarationKind.Constant:
if (initializerOpt != null && !((BindingDiagnosticBag)instance).HasAnyResolvedErrors())
{
ImmutableBindingDiagnostic<AssemblySymbol> constantValueDiagnostics = localSymbol.GetConstantValueDiagnostics(initializerOpt);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(constantValueDiagnostics, true);
flag2 = ImmutableArrayExtensions.HasAnyErrors<Diagnostic>(constantValueDiagnostics.Diagnostics);
}
break;
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRangeAndFree((BindingDiagnosticBag<AssemblySymbol>)(object)instance);
BoundTypeExpression declaredTypeOpt = null;
if (includeBoundType)
{
ArrayBuilder<BoundExpression> instance2 = ArrayBuilder<BoundExpression>.GetInstance();
typeSyntax.VisitRankSpecifiers(delegate(ArrayRankSpecifierSyntax rankSpecifier, (Binder binder, ArrayBuilder<BoundExpression> invalidDimensions, BindingDiagnosticBag diagnostics) args)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
bool hasErrors = false;
Enumerator<ExpressionSyntax> enumerator = rankSpecifier.Sizes.GetEnumerator();
while (enumerator.MoveNext())
{
ExpressionSyntax current = enumerator.Current;
BoundExpression boundExpression = args.binder.BindArrayDimension(current, args.diagnostics, ref hasErrors);
if (boundExpression != null)
{
args.invalidDimensions.Add(boundExpression);
}
}
}, (this, instance2, diagnostics));
declaredTypeOpt = new BoundTypeExpression((SyntaxNode)(object)typeSyntax, aliasOpt, instance2.ToImmutableAndFree(), declTypeOpt);
}
return new BoundLocalDeclaration((SyntaxNode)(object)associatedSyntaxNode, localSymbol, declaredTypeOpt, (!flag2) ? initializerOpt : BindToTypeForErrorRecovery(initializerOpt)?.WithHasErrors(), argumentsOpt, isVar, flag2 || flag);
}
protected bool CheckRefLocalInAsyncOrIteratorMethod(SyntaxToken identifierToken, BindingDiagnosticBag diagnostics)
{
//IL_000e: 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)
if (IsInAsyncMethod())
{
Error(diagnostics, ErrorCode.ERR_BadAsyncLocalType, identifierToken);
return true;
}
if (IsDirectlyInIterator)
{
Error(diagnostics, ErrorCode.ERR_BadIteratorLocalType, identifierToken);
return true;
}
return false;
}
internal ImmutableArray<BoundExpression> BindDeclaratorArguments(VariableDeclaratorSyntax declarator, BindingDiagnosticBag diagnostics)
{
ImmutableArray<BoundExpression> result = default(ImmutableArray<BoundExpression>);
if (declarator.ArgumentList != null)
{
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
BindArgumentsAndNames(declarator.ArgumentList, diagnostics, instance);
result = BuildArgumentsForErrorRecovery(instance);
instance.Free();
}
return result;
}
private SourceLocalSymbol LocateDeclaredVariableSymbol(VariableDeclaratorSyntax declarator, TypeSyntax typeSyntax, LocalDeclarationKind outerKind)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
LocalDeclarationKind kind = ((outerKind != LocalDeclarationKind.UsingVariable) ? LocalDeclarationKind.RegularVariable : LocalDeclarationKind.UsingVariable);
return LocateDeclaredVariableSymbol(declarator.Identifier, typeSyntax, declarator.Initializer, kind);
}
private SourceLocalSymbol LocateDeclaredVariableSymbol(SyntaxToken identifier, TypeSyntax typeSyntax, EqualsValueClauseSyntax equalsValue, LocalDeclarationKind kind)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
SourceLocalSymbol sourceLocalSymbol = LookupLocal(identifier);
if ((object)sourceLocalSymbol == null)
{
sourceLocalSymbol = SourceLocalSymbol.MakeLocal(ContainingMemberOrLambda, this, allowRefKind: false, allowScoped: false, typeSyntax, identifier, kind, equalsValue);
}
return sourceLocalSymbol;
}
private bool IsValidFixedVariableInitializer(TypeSymbol declType, ref BoundExpression initializerOpt, BindingDiagnosticBag diagnostics)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Invalid comparison between Unknown and I4
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Invalid comparison between Unknown and I4
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
BoundExpression obj = initializerOpt;
if (obj == null || obj.HasAnyErrors)
{
return false;
}
TypeSymbol type = initializerOpt.Type;
SyntaxNode syntax = initializerOpt.Syntax;
if ((object)type == null)
{
Error(diagnostics, ErrorCode.ERR_ExprCannotBeFixed, SyntaxNodeOrToken.op_Implicit(syntax));
return false;
}
bool hasErrors = false;
MethodSymbol methodSymbol = null;
BoundKind kind = initializerOpt.Kind;
TypeSymbol typeSymbol;
if (kind != BoundKind.AddressOfOperator)
{
if (kind == BoundKind.FieldAccess)
{
BoundFieldAccess boundFieldAccess = (BoundFieldAccess)initializerOpt;
if (boundFieldAccess.FieldSymbol.IsFixedSizeBuffer)
{
typeSymbol = ((PointerTypeSymbol)boundFieldAccess.Type).PointedAtType;
goto IL_0166;
}
}
if (type.IsArray())
{
typeSymbol = ((ArrayTypeSymbol)type).ElementType;
}
else
{
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(diagnostics);
methodSymbol = GetFixedPatternMethodOpt(initializerOpt, instance);
if ((int)type.SpecialType == 20 && ((object)methodSymbol == null || (int)methodSymbol.ContainingType.SpecialType != 20))
{
methodSymbol = null;
typeSymbol = GetSpecialType((SpecialType)8, diagnostics, syntax);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
}
else
{
CSharpParseOptions obj2 = (CSharpParseOptions)(object)initializerOpt.SyntaxTree.Options;
if (obj2 == null || obj2.IsFeatureEnabled(MessageID.IDS_FeatureExtensibleFixedStatement))
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
if ((object)methodSymbol == null)
{
Error(diagnostics, ErrorCode.ERR_ExprCannotBeFixed, SyntaxNodeOrToken.op_Implicit(syntax));
return false;
}
typeSymbol = methodSymbol.ReturnType;
CheckFeatureAvailability(initializerOpt.Syntax, MessageID.IDS_FeatureExtensibleFixedStatement, diagnostics);
}
}
}
else
{
typeSymbol = ((BoundAddressOfOperator)initializerOpt).Operand.Type;
}
goto IL_0166;
IL_0166:
if (CheckManagedAddr(Compilation, typeSymbol, syntax.Location, diagnostics))
{
hasErrors = true;
}
initializerOpt = BindToNaturalType(initializerOpt, diagnostics, reportNoTargetType: false);
initializerOpt = GetFixedLocalCollectionInitializer(initializerOpt, typeSymbol, declType, methodSymbol, hasErrors, diagnostics);
return true;
}
private MethodSymbol GetFixedPatternMethodOpt(BoundExpression initializer, BindingDiagnosticBag additionalDiagnostics)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
if (initializer.Type.IsVoidType())
{
return null;
}
PerformPatternMethodLookup(initializer, "GetPinnableReference", initializer.Syntax, additionalDiagnostics, out var result);
if ((object)result == null)
{
return null;
}
if (HasOptionalOrVariableParameters(result) || result.ReturnsVoid || !result.RefKind.IsManagedReference() || (result.ParameterCount != 0 && (!result.IsStatic || result.ParameterCount != 1)))
{
additionalDiagnostics.Add(ErrorCode.WRN_PatternBadSignature, initializer.Syntax.Location, initializer.Type, "fixed", result);
return null;
}
return result;
}
private BoundExpression GetFixedLocalCollectionInitializer(BoundExpression initializer, TypeSymbol elementType, TypeSymbol declType, MethodSymbol patternMethodOpt, bool hasErrors, BindingDiagnosticBag diagnostics)
{
//IL_0021: 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)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
SyntaxNode syntax = initializer.Syntax;
TypeSymbol typeSymbol = new PointerTypeSymbol(TypeWithAnnotations.Create(elementType));
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyConversionFromType(typeSymbol, declType, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(syntax, useSiteInfo);
if (!conversion.IsValid || !conversion.IsImplicit)
{
GenerateImplicitConversionError(diagnostics, Compilation, syntax, conversion, typeSymbol, declType);
hasErrors = true;
}
BoundValuePlaceholder boundValuePlaceholder;
BoundExpression elementPointerConversion;
if (conversion.IsValid)
{
boundValuePlaceholder = new BoundValuePlaceholder(syntax, typeSymbol).MakeCompilerGenerated();
elementPointerConversion = CreateConversion(syntax, boundValuePlaceholder, conversion, isCast: false, null, declType, conversion.IsImplicit ? diagnostics : BindingDiagnosticBag.Discarded);
}
else
{
boundValuePlaceholder = null;
elementPointerConversion = null;
}
return new BoundFixedLocalCollectionInitializer(syntax, typeSymbol, boundValuePlaceholder, elementPointerConversion, initializer, patternMethodOpt, declType, hasErrors);
}
private BoundExpression BindAssignment(AssignmentExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Invalid comparison between Unknown and I4
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
node.Left.CheckDeconstructionCompatibleArgument(diagnostics);
if (node.Left.Kind() == SyntaxKind.TupleExpression || node.Left.Kind() == SyntaxKind.DeclarationExpression)
{
return BindDeconstruction(node, diagnostics);
}
RefKind refKind;
ExpressionSyntax node2 = node.Right.CheckAndUnwrapRefExpression(diagnostics, out refKind);
bool flag = (int)refKind == 1;
BindValueKind valueKind = (flag ? BindValueKind.RefAssignable : BindValueKind.Assignable);
if (flag)
{
MessageID.IDS_FeatureRefReassignment.CheckFeatureAvailability(diagnostics, node.Right.GetFirstToken());
}
BoundExpression boundExpression = BindValue(node.Left, diagnostics, valueKind);
ReportSuppressionIfNeeded(boundExpression, diagnostics);
BindValueKind valueKind2 = (flag ? GetRequiredRHSValueKindForRefAssignment(boundExpression) : BindValueKind.RValue);
BoundExpression boundExpression2 = BindValue(node2, diagnostics, valueKind2);
if (boundExpression.Kind == BoundKind.DiscardExpression)
{
boundExpression2 = BindToNaturalType(boundExpression2, diagnostics);
boundExpression = InferTypeForDiscardAssignment((BoundDiscardExpression)boundExpression, boundExpression2, diagnostics);
}
return BindAssignment((SyntaxNode)(object)node, boundExpression, boundExpression2, flag, diagnostics);
}
private static BindValueKind GetRequiredRHSValueKindForRefAssignment(BoundExpression boundLeft)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
BindValueKind bindValueKind = BindValueKind.RefersToLocation;
if (!boundLeft.HasErrors)
{
RefKind refKind = boundLeft.GetRefKind();
if (refKind - 1 <= 1)
{
bindValueKind |= BindValueKind.Assignable;
}
}
return bindValueKind;
}
private BoundExpression InferTypeForDiscardAssignment(BoundDiscardExpression op1, BoundExpression op2, BindingDiagnosticBag diagnostics)
{
TypeSymbol type = op2.Type;
if ((object)type == null)
{
return op1.FailInference(this, diagnostics);
}
if (type.IsVoidType())
{
diagnostics.Add(ErrorCode.ERR_VoidAssignment, op1.Syntax.Location);
}
return op1.SetInferredTypeWithAnnotations(TypeWithAnnotations.Create(type));
}
private BoundAssignmentOperator BindAssignment(SyntaxNode node, BoundExpression op1, BoundExpression op2, bool isRef, BindingDiagnosticBag diagnostics)
{
bool hasErrors = op1.HasAnyErrors || op2.HasAnyErrors;
if (!op1.HasAnyErrors)
{
BoundExpression boundExpression = GenerateConversionForAssignment(op1.Type, op2, diagnostics, isRef ? ConversionForAssignmentFlags.RefAssignment : ConversionForAssignmentFlags.None);
op2 = ((op1.Kind == BoundKind.DynamicIndexerAccess || op1.Kind == BoundKind.DynamicMemberAccess || op1.Kind == BoundKind.DynamicObjectInitializerMember) ? BindToNaturalType(op2, diagnostics) : boundExpression);
}
else
{
op2 = BindToTypeForErrorRecovery(op2);
}
TypeSymbol type = ((op1.Kind != BoundKind.EventAccess || !((BoundEventAccess)op1).EventSymbol.IsWindowsRuntimeEvent) ? op1.Type : GetSpecialType((SpecialType)6, diagnostics, node));
return new BoundAssignmentOperator(node, op1, op2, isRef, type, hasErrors);
}
internal static PropertySymbol GetPropertySymbol(BoundExpression expr, out BoundExpression receiver, out SyntaxNode propertySyntax)
{
if (expr == null)
{
receiver = null;
propertySyntax = null;
return null;
}
PropertySymbol result;
switch (expr.Kind)
{
case BoundKind.PropertyAccess:
{
BoundPropertyAccess boundPropertyAccess = (BoundPropertyAccess)expr;
receiver = boundPropertyAccess.ReceiverOpt;
result = boundPropertyAccess.PropertySymbol;
break;
}
case BoundKind.IndexerAccess:
{
BoundIndexerAccess boundIndexerAccess2 = (BoundIndexerAccess)expr;
receiver = boundIndexerAccess2.ReceiverOpt;
result = boundIndexerAccess2.Indexer;
break;
}
case BoundKind.ImplicitIndexerAccess:
{
BoundImplicitIndexerAccess boundImplicitIndexerAccess = (BoundImplicitIndexerAccess)expr;
BoundExpression indexerOrSliceAccess = boundImplicitIndexerAccess.IndexerOrSliceAccess;
if (!(indexerOrSliceAccess is BoundIndexerAccess boundIndexerAccess))
{
if (indexerOrSliceAccess is BoundCall || indexerOrSliceAccess is BoundArrayAccess)
{
receiver = null;
propertySyntax = null;
return null;
}
throw ExceptionUtilities.UnexpectedValue((object)boundImplicitIndexerAccess.IndexerOrSliceAccess.Kind);
}
result = boundIndexerAccess.Indexer;
receiver = boundImplicitIndexerAccess.Receiver;
break;
}
default:
receiver = null;
propertySyntax = null;
return null;
}
SyntaxNode syntax = expr.Syntax;
switch (syntax.Kind())
{
case SyntaxKind.SimpleMemberAccessExpression:
case SyntaxKind.PointerMemberAccessExpression:
propertySyntax = (SyntaxNode)(object)((MemberAccessExpressionSyntax)(object)syntax).Name;
break;
case SyntaxKind.IdentifierName:
propertySyntax = syntax;
break;
case SyntaxKind.ElementAccessExpression:
propertySyntax = (SyntaxNode)(object)((ElementAccessExpressionSyntax)(object)syntax).ArgumentList;
break;
default:
propertySyntax = syntax;
break;
}
return result;
}
internal static Symbol? GetIndexerOrImplicitIndexerSymbol(BoundExpression? e)
{
if (e != null)
{
if (!(e is BoundIndexerAccess boundIndexerAccess))
{
if (e is BoundImplicitIndexerAccess boundImplicitIndexerAccess)
{
BoundExpression indexerOrSliceAccess = boundImplicitIndexerAccess.IndexerOrSliceAccess;
if (indexerOrSliceAccess is BoundCall boundCall)
{
return boundCall.Method;
}
if (indexerOrSliceAccess is BoundIndexerAccess boundIndexerAccess2)
{
return boundIndexerAccess2.Indexer;
}
if (indexerOrSliceAccess is BoundArrayAccess)
{
return null;
}
}
else
{
if (e is BoundArrayAccess)
{
return null;
}
if (e is BoundDynamicIndexerAccess)
{
return null;
}
if (e is BoundBadExpression)
{
return null;
}
}
throw ExceptionUtilities.UnexpectedValue((object)e.Kind);
}
return boundIndexerAccess.Indexer;
}
return null;
}
private static SyntaxNode GetEventName(BoundEventAccess expr)
{
SyntaxNode syntax = expr.Syntax;
switch (syntax.Kind())
{
case SyntaxKind.SimpleMemberAccessExpression:
case SyntaxKind.PointerMemberAccessExpression:
return (SyntaxNode)(object)((MemberAccessExpressionSyntax)(object)syntax).Name;
case SyntaxKind.QualifiedName:
return (SyntaxNode)(object)((QualifiedNameSyntax)(object)syntax).Right;
case SyntaxKind.IdentifierName:
return syntax;
case SyntaxKind.MemberBindingExpression:
return (SyntaxNode)(object)((MemberBindingExpressionSyntax)(object)syntax).Name;
default:
throw ExceptionUtilities.UnexpectedValue((object)syntax.Kind());
}
}
private DiagnosticInfo GetBadEventUsageDiagnosticInfo(EventSymbol eventSymbol)
{
EventSymbol eventSymbol2 = (EventSymbol)eventSymbol.GetLeastOverriddenMember(ContainingType);
if (!eventSymbol2.HasAssociatedField)
{
return (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_BadEventUsageNoField, eventSymbol2);
}
return (DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_BadEventUsage, eventSymbol2, eventSymbol2.ContainingType);
}
internal static bool AccessingAutoPropertyFromConstructor(BoundPropertyAccess propertyAccess, Symbol fromMember)
{
return AccessingAutoPropertyFromConstructor(propertyAccess.ReceiverOpt, propertyAccess.PropertySymbol, fromMember);
}
private static bool AccessingAutoPropertyFromConstructor(BoundExpression receiver, PropertySymbol propertySymbol, Symbol fromMember)
{
if (!propertySymbol.IsDefinition && propertySymbol.ContainingType.Equals(propertySymbol.ContainingType.OriginalDefinition, (TypeCompareKind)8))
{
propertySymbol = propertySymbol.OriginalDefinition;
}
SourcePropertySymbolBase sourcePropertySymbolBase = propertySymbol as SourcePropertySymbolBase;
bool isStatic = propertySymbol.IsStatic;
if ((object)sourcePropertySymbolBase != null && sourcePropertySymbolBase.IsAutoPropertyWithGetAccessor && TypeSymbol.Equals(sourcePropertySymbolBase.ContainingType, fromMember.ContainingType, (TypeCompareKind)63) && IsConstructorOrField(fromMember, isStatic))
{
if (!isStatic)
{
return receiver.Kind == BoundKind.ThisReference;
}
return true;
}
return false;
}
private static bool IsConstructorOrField(Symbol member, bool isStatic)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if ((member as MethodSymbol)?.MethodKind != (MethodKind?)((!isStatic) ? 1 : 14))
{
FieldSymbol obj = member as FieldSymbol;
if ((object)obj == null)
{
return false;
}
return obj.IsStatic == isStatic;
}
return true;
}
private TypeSymbol GetAccessThroughType(BoundExpression receiver)
{
if (receiver == null)
{
return ContainingType;
}
if (receiver.Kind == BoundKind.BaseReference)
{
return null;
}
return receiver.Type;
}
private BoundExpression BindPossibleArrayInitializer(ExpressionSyntax node, TypeSymbol destinationType, BindValueKind valueKind, BindingDiagnosticBag diagnostics)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
if (node.Kind() != SyntaxKind.ArrayInitializerExpression)
{
return BindValue(node, diagnostics, valueKind);
}
BoundExpression expr = (((int)destinationType.Kind != 1) ? ((BoundExpression)BindUnexpectedArrayInitializer((InitializerExpressionSyntax)node, diagnostics, ErrorCode.ERR_ArrayInitToNonArrayType)) : ((BoundExpression)BindArrayCreationWithInitializer(diagnostics, null, (InitializerExpressionSyntax)node, (ArrayTypeSymbol)destinationType, ImmutableArray<BoundExpression>.Empty)));
return CheckValue(expr, valueKind, diagnostics);
}
protected virtual SourceLocalSymbol LookupLocal(SyntaxToken nameToken)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Next.LookupLocal(nameToken);
}
protected virtual LocalFunctionSymbol LookupLocalFunction(SyntaxToken nameToken)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Next.LookupLocalFunction(nameToken);
}
internal virtual BoundBlock BindEmbeddedBlock(BlockSyntax node, BindingDiagnosticBag diagnostics)
{
return BindBlock(node, diagnostics);
}
private BoundBlock BindBlock(BlockSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (node.AttributeLists.Count > 0)
{
Error(diagnostics, ErrorCode.ERR_AttributesNotAllowed, (CSharpSyntaxNode)node.AttributeLists[0]);
}
return GetBinder((SyntaxNode)(object)node).BindBlockParts(node, diagnostics);
}
private BoundBlock BindBlockParts(BlockSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
SyntaxList<StatementSyntax> statements = node.Statements;
int count = statements.Count;
ArrayBuilder<BoundStatement> instance = ArrayBuilder<BoundStatement>.GetInstance(count);
for (int i = 0; i < count; i++)
{
BoundStatement boundStatement = BindStatement(statements[i], diagnostics);
instance.Add(boundStatement);
}
return FinishBindBlockParts(node, instance.ToImmutableAndFree());
}
private BoundBlock FinishBindBlockParts(CSharpSyntaxNode node, ImmutableArray<BoundStatement> boundStatements)
{
ImmutableArray<LocalSymbol> declaredLocalsForScope = GetDeclaredLocalsForScope((SyntaxNode)(object)node);
ImmutableArray<LocalFunctionSymbol> declaredLocalFunctionsForScope = GetDeclaredLocalFunctionsForScope(node);
CSharpSyntaxNode? parent = node.Parent;
return new BoundBlock((SyntaxNode)(object)node, declaredLocalsForScope, declaredLocalFunctionsForScope, parent != null && parent.Kind() == SyntaxKind.UnsafeStatement, null, boundStatements);
}
internal BoundExpression GenerateConversionForAssignment(TypeSymbol targetType, BoundExpression expression, BindingDiagnosticBag diagnostics, ConversionForAssignmentFlags flags = ConversionForAssignmentFlags.None)
{
Conversion conversion;
return GenerateConversionForAssignment(targetType, expression, diagnostics, out conversion, flags);
}
internal BoundExpression GenerateConversionForAssignment(TypeSymbol targetType, BoundExpression expression, BindingDiagnosticBag diagnostics, out Conversion conversion, ConversionForAssignmentFlags flags = ConversionForAssignmentFlags.None)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
if (expression.HasAnyErrors && expression.Kind != BoundKind.UnboundLambda)
{
diagnostics = BindingDiagnosticBag.Discarded;
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
conversion = (((flags & ConversionForAssignmentFlags.IncrementAssignment) == 0) ? Conversions.ClassifyConversionFromExpression(expression, targetType, CheckOverflowAtRuntime, ref useSiteInfo) : Conversions.ClassifyConversionFromType(expression.Type, targetType, CheckOverflowAtRuntime, ref useSiteInfo));
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(expression.Syntax, useSiteInfo);
if ((flags & ConversionForAssignmentFlags.RefAssignment) != ConversionForAssignmentFlags.None)
{
if (conversion.Kind == ConversionKind.Identity)
{
return expression;
}
Error(diagnostics, ErrorCode.ERR_RefAssignmentMustHaveIdentityConversion, SyntaxNodeOrToken.op_Implicit(expression.Syntax), targetType);
}
else
{
if (conversion.IsValid)
{
bool num;
if ((flags & ConversionForAssignmentFlags.CompoundAssignment) != ConversionForAssignmentFlags.None)
{
if (!conversion.IsExplicit)
{
goto IL_00fa;
}
num = (flags & ConversionForAssignmentFlags.PredefinedOperator) == 0;
}
else
{
num = !conversion.IsImplicit;
}
if (!num)
{
goto IL_00fa;
}
}
if ((flags & ConversionForAssignmentFlags.DefaultParameter) == 0)
{
GenerateImplicitConversionError(diagnostics, expression.Syntax, conversion, expression, targetType);
}
diagnostics = BindingDiagnosticBag.Discarded;
}
goto IL_00fa;
IL_00fa:
return CreateConversion(expression.Syntax, expression, conversion, isCast: false, null, targetType, diagnostics);
}
private static Location GetAnonymousFunctionLocation(SyntaxNode node)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken val;
if (!(node is LambdaExpressionSyntax lambdaExpressionSyntax))
{
if (node is AnonymousMethodExpressionSyntax anonymousMethodExpressionSyntax)
{
val = anonymousMethodExpressionSyntax.DelegateKeyword;
return ((SyntaxToken)(ref val)).GetLocation();
}
return node.Location;
}
val = lambdaExpressionSyntax.ArrowToken;
return ((SyntaxToken)(ref val)).GetLocation();
}
internal void GenerateAnonymousFunctionConversionError(BindingDiagnosticBag diagnostics, SyntaxNode syntax, UnboundLambda anonymousFunction, TypeSymbol targetType)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_03de: 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_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_035a: Unknown result type (might be due to invalid IL or missing references)
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
//IL_032d: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
if (targetType.IsErrorType())
{
return;
}
LambdaConversionResult lambdaConversionResult = ConversionsBase.IsAnonymousFunctionCompatibleWithType(anonymousFunction, targetType, Compilation);
if (lambdaConversionResult == LambdaConversionResult.Success)
{
return;
}
LocalizableErrorArgument localizableErrorArgument = anonymousFunction.MessageID.Localize();
switch (lambdaConversionResult)
{
case LambdaConversionResult.BadTargetType:
{
if (ReportDelegateInvokeUseSiteDiagnostic(diagnostics, targetType, null, syntax))
{
return;
}
FunctionTypeSymbol functionType = anonymousFunction.FunctionType;
if ((object)functionType != null && (object)functionType.GetInternalDelegateType() == null)
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
if (Conversions.IsValidFunctionTypeConversionTarget(targetType, ref useSiteInfo))
{
conversionError(diagnostics, ErrorCode.ERR_CannotInferDelegateType, Array.Empty<object>());
BoundLambda boundLambda = anonymousFunction.BindForErrorRecovery();
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(boundLambda.Diagnostics, false);
return;
}
}
conversionError(diagnostics, ErrorCode.ERR_AnonMethToNonDel, new object[2] { localizableErrorArgument, targetType });
return;
}
case LambdaConversionResult.ExpressionTreeMustHaveDelegateTypeArgument:
conversionError(diagnostics, ErrorCode.ERR_ExpressionTreeMustHaveDelegate, new object[1] { ((NamedTypeSymbol)targetType).TypeArgumentsWithAnnotationsNoUseSiteDiagnostics[0].Type });
return;
case LambdaConversionResult.ExpressionTreeFromAnonymousMethod:
conversionError(diagnostics, ErrorCode.ERR_AnonymousMethodToExpressionTree, Array.Empty<object>());
return;
case LambdaConversionResult.MismatchedReturnType:
conversionError(diagnostics, ErrorCode.ERR_CantConvAnonMethReturnType, new object[2] { localizableErrorArgument, targetType });
return;
case LambdaConversionResult.MissingSignatureWithOutParameter:
conversionError(diagnostics, ErrorCode.ERR_CantConvAnonMethNoParams, new object[1] { targetType });
return;
}
NamedTypeSymbol delegateType = targetType.GetDelegateType();
if (lambdaConversionResult == LambdaConversionResult.BadParameterCount)
{
conversionError(diagnostics, ErrorCode.ERR_BadDelArgCount, new object[2] { delegateType, anonymousFunction.ParameterCount });
return;
}
if (anonymousFunction.HasExplicitlyTypedParameterList)
{
for (int i = 0; i < anonymousFunction.ParameterCount; i++)
{
if (anonymousFunction.ParameterType(i).IsErrorType())
{
return;
}
}
}
ImmutableArray<ParameterSymbol> immutableArray = delegateType.DelegateParameters();
switch (lambdaConversionResult)
{
case LambdaConversionResult.RefInImplicitlyTypedLambda:
{
for (int k = 0; k < anonymousFunction.ParameterCount; k++)
{
RefKind refKind2 = immutableArray[k].RefKind;
if ((int)refKind2 != 0)
{
Error(diagnostics, ErrorCode.ERR_BadParamRef, anonymousFunction.ParameterLocation(k), k + 1, RefKindExtensions.ToParameterDisplayString(refKind2));
}
}
break;
}
case LambdaConversionResult.StaticTypeInImplicitlyTypedLambda:
{
for (int l = 0; l < anonymousFunction.ParameterCount; l++)
{
if (immutableArray[l].TypeWithAnnotations.IsStatic)
{
Error(diagnostics, ErrorFacts.GetStaticClassParameterCode(useWarning: false), anonymousFunction.ParameterLocation(l), immutableArray[l].Type);
}
}
break;
}
case LambdaConversionResult.MismatchedParameterType:
{
conversionError(diagnostics, ErrorCode.ERR_CantConvAnonMethParams, new object[2] { localizableErrorArgument, targetType });
for (int j = 0; j < anonymousFunction.ParameterCount; j++)
{
TypeSymbol typeSymbol = anonymousFunction.ParameterType(j);
if (typeSymbol.IsErrorType())
{
continue;
}
Location location = anonymousFunction.ParameterLocation(j);
RefKind val = anonymousFunction.RefKind(j);
TypeSymbol type = immutableArray[j].Type;
RefKind refKind = immutableArray[j].RefKind;
if (!typeSymbol.Equals(type, (TypeCompareKind)63))
{
SymbolDistinguisher symbolDistinguisher = new SymbolDistinguisher(Compilation, typeSymbol, type);
Error(diagnostics, ErrorCode.ERR_BadParamType, location, j + 1, RefKindExtensions.ToParameterPrefix(val), symbolDistinguisher.First, RefKindExtensions.ToParameterPrefix(refKind), symbolDistinguisher.Second);
}
else if (val != refKind)
{
if ((int)refKind == 0)
{
Error(diagnostics, ErrorCode.ERR_BadParamExtraRef, location, j + 1, RefKindExtensions.ToParameterDisplayString(val));
}
else
{
Error(diagnostics, ErrorCode.ERR_BadParamRef, location, j + 1, RefKindExtensions.ToParameterDisplayString(refKind));
}
}
}
break;
}
case LambdaConversionResult.BindingFailed:
{
BoundLambda boundLambda2 = anonymousFunction.Bind(delegateType, isExpressionTree: false);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(boundLambda2.Diagnostics, false);
break;
}
default:
diagnostics.Add(ErrorCode.ERR_InternalError, syntax.Location);
break;
}
void conversionError(BindingDiagnosticBag diagnostics2, ErrorCode code, object[] args)
{
Error(diagnostics2, code, GetAnonymousFunctionLocation(syntax), args);
}
}
protected static void GenerateImplicitConversionError(BindingDiagnosticBag diagnostics, CSharpCompilation compilation, SyntaxNode syntax, Conversion conversion, TypeSymbol sourceType, TypeSymbol targetType, ConstantValue sourceConstantValueOpt = null)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Invalid comparison between Unknown and I4
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Invalid comparison between Unknown and I4
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Invalid comparison between Unknown and I4
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Invalid comparison between Unknown and I4
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
if (sourceType.ContainsErrorType() || targetType.ContainsErrorType())
{
return;
}
if (conversion.IsExplicit)
{
if ((int)sourceType.SpecialType == 19 && syntax.Kind() == SyntaxKind.NumericLiteralExpression && ((int)targetType.SpecialType == 18 || (int)targetType.SpecialType == 17))
{
Error(diagnostics, ErrorCode.ERR_LiteralDoubleCast, SyntaxNodeOrToken.op_Implicit(syntax), ((int)targetType.SpecialType == 18) ? "F" : "M", targetType);
}
else if (conversion.Kind == ConversionKind.ExplicitNumeric && sourceConstantValueOpt != (ConstantValue)null && sourceConstantValueOpt != ConstantValue.Bad && ConversionsBase.HasImplicitConstantExpressionConversion(new BoundLiteral(syntax, ConstantValue.Bad, sourceType), targetType))
{
Error(diagnostics, ErrorCode.ERR_ConstOutOfRange, SyntaxNodeOrToken.op_Implicit(syntax), sourceConstantValueOpt.Value, targetType);
}
else
{
SymbolDistinguisher symbolDistinguisher = new SymbolDistinguisher(compilation, sourceType, targetType);
Error(diagnostics, ErrorCode.ERR_NoImplicitConvCast, SyntaxNodeOrToken.op_Implicit(syntax), symbolDistinguisher.First, symbolDistinguisher.Second);
}
}
else if (conversion.ResultKind == LookupResultKind.OverloadResolutionFailure)
{
ImmutableArray<MethodSymbol> originalUserDefinedConversions = conversion.OriginalUserDefinedConversions;
if (originalUserDefinedConversions.Length > 1)
{
Error(diagnostics, ErrorCode.ERR_AmbigUDConv, SyntaxNodeOrToken.op_Implicit(syntax), originalUserDefinedConversions[0], originalUserDefinedConversions[1], sourceType, targetType);
}
else
{
SymbolDistinguisher symbolDistinguisher2 = new SymbolDistinguisher(compilation, sourceType, targetType);
Error(diagnostics, ErrorCode.ERR_NoImplicitConv, SyntaxNodeOrToken.op_Implicit(syntax), symbolDistinguisher2.First, symbolDistinguisher2.Second);
}
}
else if (TypeSymbol.Equals(sourceType, targetType, (TypeCompareKind)0))
{
Error(diagnostics, ErrorCode.ERR_NoImplicitConv, SyntaxNodeOrToken.op_Implicit(syntax), sourceType, targetType);
}
else
{
SymbolDistinguisher symbolDistinguisher3 = new SymbolDistinguisher(compilation, sourceType, targetType);
Error(diagnostics, ErrorCode.ERR_NoImplicitConv, SyntaxNodeOrToken.op_Implicit(syntax), symbolDistinguisher3.First, symbolDistinguisher3.Second);
}
}
protected void GenerateImplicitConversionError(BindingDiagnosticBag diagnostics, SyntaxNode syntax, Conversion conversion, BoundExpression operand, TypeSymbol targetType)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Invalid comparison between Unknown and I4
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_033d: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Invalid comparison between Unknown and I4
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
if ((int)targetType.TypeKind == 6)
{
return;
}
if (targetType.IsVoidType())
{
Error(diagnostics, ErrorCode.ERR_NoImplicitConv, SyntaxNodeOrToken.op_Implicit(syntax), operand.Display, targetType);
return;
}
switch (operand.Kind)
{
case BoundKind.BadExpression:
return;
case BoundKind.UnboundLambda:
GenerateAnonymousFunctionConversionError(diagnostics, syntax, (UnboundLambda)operand, targetType);
return;
case BoundKind.TupleLiteral:
{
BoundTupleLiteral boundTupleLiteral = (BoundTupleLiteral)operand;
ImmutableArray<TypeWithAnnotations> elementTypes = default(ImmutableArray<TypeWithAnnotations>);
if (targetType.TryGetElementTypesWithAnnotationsIfTupleType(out elementTypes) && elementTypes.Length == boundTupleLiteral.Arguments.Length)
{
GenerateImplicitConversionErrorsForTupleLiteralArguments(diagnostics, boundTupleLiteral.Arguments, elementTypes);
return;
}
if ((object)boundTupleLiteral.Type == null)
{
Error(diagnostics, ErrorCode.ERR_ConversionNotTupleCompatible, SyntaxNodeOrToken.op_Implicit(syntax), boundTupleLiteral.Arguments.Length, targetType);
return;
}
break;
}
case BoundKind.MethodGroup:
reportMethodGroupErrors((BoundMethodGroup)operand, fromAddressOf: false);
return;
case BoundKind.UnconvertedAddressOfOperator:
reportMethodGroupErrors(((BoundUnconvertedAddressOfOperator)operand).Operand, fromAddressOf: true);
return;
case BoundKind.Literal:
if (operand.IsLiteralNull())
{
if ((int)targetType.TypeKind == 11)
{
Error(diagnostics, ErrorCode.ERR_TypeVarCantBeNull, SyntaxNodeOrToken.op_Implicit(syntax), targetType);
return;
}
if (targetType.IsValueType)
{
Error(diagnostics, ErrorCode.ERR_ValueCantBeNull, SyntaxNodeOrToken.op_Implicit(syntax), targetType);
return;
}
}
break;
case BoundKind.StackAllocArrayCreation:
{
BoundStackAllocArrayCreation boundStackAllocArrayCreation = (BoundStackAllocArrayCreation)operand;
Error(diagnostics, ErrorCode.ERR_StackAllocConversionNotPossible, SyntaxNodeOrToken.op_Implicit(syntax), boundStackAllocArrayCreation.ElementType, targetType);
return;
}
case BoundKind.UnconvertedSwitchExpression:
{
BoundUnconvertedSwitchExpression obj = (BoundUnconvertedSwitchExpression)operand;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo2 = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
bool reportedError2 = false;
ImmutableArray<BoundSwitchExpressionArm>.Enumerator enumerator = obj.SwitchArms.GetEnumerator();
while (enumerator.MoveNext())
{
BoundSwitchExpressionArm current = enumerator.Current;
tryConversion(current.Value, ref reportedError2, ref useSiteInfo2);
}
return;
}
case BoundKind.UnconvertedCollectionExpression:
GenerateImplicitConversionErrorForCollectionExpression((BoundUnconvertedCollectionExpression)operand, targetType, diagnostics);
return;
case BoundKind.AddressOfOperator:
if (targetType.IsFunctionPointer())
{
Error(diagnostics, ErrorCode.ERR_InvalidAddrOp, SyntaxNodeOrToken.op_Implicit(((BoundAddressOfOperator)operand).Operand.Syntax));
return;
}
break;
case BoundKind.UnconvertedConditionalOperator:
{
BoundUnconvertedConditionalOperator boundUnconvertedConditionalOperator = (BoundUnconvertedConditionalOperator)operand;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
bool reportedError = false;
tryConversion(boundUnconvertedConditionalOperator.Consequence, ref reportedError, ref useSiteInfo);
tryConversion(boundUnconvertedConditionalOperator.Alternative, ref reportedError, ref useSiteInfo);
return;
}
}
TypeSymbol type = operand.Type;
if ((object)type != null)
{
GenerateImplicitConversionError(diagnostics, Compilation, syntax, conversion, type, targetType, operand.ConstantValueOpt);
}
void reportMethodGroupErrors(BoundMethodGroup methodGroup, bool fromAddressOf)
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Invalid comparison between Unknown and I4
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Invalid comparison between Unknown and I4
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
if (!Microsoft.CodeAnalysis.CSharp.Conversions.ReportDelegateOrFunctionPointerMethodGroupDiagnostics(this, methodGroup, targetType, diagnostics))
{
SyntaxNode val = syntax;
while (val.Kind() == SyntaxKind.ParenthesizedExpression)
{
val = (SyntaxNode)(object)((ParenthesizedExpressionSyntax)(object)val).Expression;
}
if (val.Kind() == SyntaxKind.SimpleMemberAccessExpression || val.Kind() == SyntaxKind.PointerMemberAccessExpression)
{
val = (SyntaxNode)(object)((MemberAccessExpressionSyntax)(object)val).Name;
}
Location location = val.Location;
if (!ReportDelegateInvokeUseSiteDiagnostic(diagnostics, targetType, location))
{
TypeKind typeKind = targetType.TypeKind;
ErrorCode code;
if ((int)typeKind == 3)
{
code = ((!fromAddressOf) ? ErrorCode.ERR_MethDelegateMismatch : ErrorCode.ERR_CannotConvertAddressOfToDelegate);
}
else if ((int)typeKind == 13)
{
if (!fromAddressOf)
{
Error(diagnostics, ErrorCode.ERR_MissingAddressOf, location);
return;
}
code = ErrorCode.ERR_MethFuncPtrMismatch;
}
else
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo3 = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
if (fromAddressOf)
{
code = ErrorCode.ERR_AddressOfToNonFunctionPointer;
}
else
{
if (Conversions.IsValidFunctionTypeConversionTarget(targetType, ref useSiteInfo3) && !targetType.IsNonGenericExpressionType() && syntax.IsFeatureEnabled(MessageID.IDS_FeatureInferredDelegateType))
{
Error(diagnostics, ErrorCode.ERR_CannotInferDelegateType, location);
return;
}
code = ErrorCode.ERR_MethGrpToNonDel;
}
}
Error(diagnostics, code, location, methodGroup.Name, targetType);
}
}
}
void tryConversion(BoundExpression expr, ref bool reference, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo3)
{
Conversion conversion2 = Conversions.ClassifyImplicitConversionFromExpression(expr, targetType, ref useSiteInfo3);
if (!conversion2.IsImplicit || !conversion2.IsValid)
{
GenerateImplicitConversionError(diagnostics, expr.Syntax, conversion2, expr, targetType);
reference = true;
}
}
}
private void GenerateImplicitConversionErrorsForTupleLiteralArguments(BindingDiagnosticBag diagnostics, ImmutableArray<BoundExpression> tupleArguments, ImmutableArray<TypeWithAnnotations> targetElementTypes)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
_ = tupleArguments.Length;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
for (int i = 0; i < targetElementTypes.Length; i++)
{
BoundExpression boundExpression = tupleArguments[i];
TypeSymbol type = targetElementTypes[i].Type;
Conversion conversion = Conversions.ClassifyImplicitConversionFromExpression(boundExpression, type, ref useSiteInfo);
if (!conversion.IsValid)
{
GenerateImplicitConversionError(diagnostics, boundExpression.Syntax, conversion, boundExpression, type);
}
}
}
private BoundStatement BindIfStatement(IfStatementSyntax node, BindingDiagnosticBag diagnostics)
{
BoundExpression condition = BindBooleanExpression(node.Condition, diagnostics);
BoundStatement consequence = BindPossibleEmbeddedStatement(node.Statement, diagnostics);
BoundStatement alternativeOpt = ((node.Else == null) ? null : BindPossibleEmbeddedStatement(node.Else.Statement, diagnostics));
return new BoundIfStatement((SyntaxNode)(object)node, condition, consequence, alternativeOpt);
}
internal BoundExpression BindBooleanExpression(ExpressionSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Invalid comparison between Unknown and I4
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
BoundExpression boundExpression = BindValue(node, diagnostics, BindValueKind.RValue);
NamedTypeSymbol specialType = GetSpecialType((SpecialType)7, diagnostics, (SyntaxNode)(object)node);
if (boundExpression.HasAnyErrors)
{
return BoundConversion.Synthesized((SyntaxNode)(object)node, BindToTypeForErrorRecovery(boundExpression), Conversion.NoConversion, @checked: false, explicitCastInCode: false, null, null, specialType, hasErrors: true);
}
if (boundExpression.HasDynamicType())
{
return new BoundUnaryOperator((SyntaxNode)(object)node, UnaryOperatorKind.DynamicTrue, BindToNaturalType(boundExpression, diagnostics), null, null, null, LookupResultKind.Viable, specialType)
{
WasCompilerGenerated = true
};
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyConversionFromExpression(boundExpression, specialType, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(boundExpression.Syntax, useSiteInfo);
if (conversion.IsImplicit)
{
if (conversion.Kind == ConversionKind.Identity && boundExpression.Kind == BoundKind.AssignmentOperator)
{
BoundAssignmentOperator boundAssignmentOperator = (BoundAssignmentOperator)boundExpression;
if (boundAssignmentOperator.Right.Kind == BoundKind.Literal && (int)boundAssignmentOperator.Right.ConstantValueOpt.Discriminator == 13)
{
Error(diagnostics, ErrorCode.WRN_IncorrectBooleanAssg, SyntaxNodeOrToken.op_Implicit(boundAssignmentOperator.Syntax));
}
}
return CreateConversion(boundExpression.Syntax, boundExpression, conversion, isCast: false, null, wasCompilerGenerated: true, specialType, diagnostics);
}
boundExpression = BindToNaturalType(boundExpression, diagnostics);
LookupResultKind resultKind;
ImmutableArray<MethodSymbol> originalUserDefinedOperators;
UnaryOperatorAnalysisResult unaryOperatorAnalysisResult = UnaryOperatorOverloadResolution(UnaryOperatorKind.True, boundExpression, node, diagnostics, out resultKind, out originalUserDefinedOperators);
if (!unaryOperatorAnalysisResult.HasValue)
{
GenerateImplicitConversionError(diagnostics, (SyntaxNode)(object)node, conversion, boundExpression, specialType);
return BoundConversion.Synthesized((SyntaxNode)(object)node, boundExpression, Conversion.NoConversion, @checked: false, explicitCastInCode: false, null, null, specialType, hasErrors: true);
}
UnaryOperatorSignature signature = unaryOperatorAnalysisResult.Signature;
BoundExpression operand = CreateConversion((SyntaxNode)(object)node, boundExpression, unaryOperatorAnalysisResult.Conversion, isCast: false, null, unaryOperatorAnalysisResult.Signature.OperandType, diagnostics);
CheckConstraintLanguageVersionAndRuntimeSupportForOperator((SyntaxNode)(object)node, signature.Method, isUnsignedRightShift: false, signature.ConstrainedToTypeOpt, diagnostics);
return new BoundUnaryOperator((SyntaxNode)(object)node, signature.Kind, operand, null, signature.Method, signature.ConstrainedToTypeOpt, resultKind, originalUserDefinedOperators, signature.ReturnType)
{
WasCompilerGenerated = true
};
}
private BoundStatement BindSwitchStatement(SwitchStatementSyntax node, BindingDiagnosticBag diagnostics)
{
Binder binder = GetBinder((SyntaxNode)(object)node);
return binder.BindSwitchStatementCore(node, binder, diagnostics);
}
internal virtual BoundStatement BindSwitchStatementCore(SwitchStatementSyntax node, Binder originalBinder, BindingDiagnosticBag diagnostics)
{
return Next.BindSwitchStatementCore(node, originalBinder, diagnostics);
}
internal virtual void BindPatternSwitchLabelForInference(CasePatternSwitchLabelSyntax node, BindingDiagnosticBag diagnostics)
{
Next.BindPatternSwitchLabelForInference(node, diagnostics);
}
private BoundStatement BindWhile(WhileStatementSyntax node, BindingDiagnosticBag diagnostics)
{
Binder binder = GetBinder((SyntaxNode)(object)node);
return binder.BindWhileParts(diagnostics, binder);
}
internal virtual BoundWhileStatement BindWhileParts(BindingDiagnosticBag diagnostics, Binder originalBinder)
{
return Next.BindWhileParts(diagnostics, originalBinder);
}
private BoundStatement BindDo(DoStatementSyntax node, BindingDiagnosticBag diagnostics)
{
Binder binder = GetBinder((SyntaxNode)(object)node);
return binder.BindDoParts(diagnostics, binder);
}
internal virtual BoundDoStatement BindDoParts(BindingDiagnosticBag diagnostics, Binder originalBinder)
{
return Next.BindDoParts(diagnostics, originalBinder);
}
internal BoundForStatement BindFor(ForStatementSyntax node, BindingDiagnosticBag diagnostics)
{
Binder binder = GetBinder((SyntaxNode)(object)node);
return binder.BindForParts(diagnostics, binder);
}
internal virtual BoundForStatement BindForParts(BindingDiagnosticBag diagnostics, Binder originalBinder)
{
return Next.BindForParts(diagnostics, originalBinder);
}
internal BoundStatement BindForOrUsingOrFixedDeclarations(VariableDeclarationSyntax nodeOpt, LocalDeclarationKind localKind, BindingDiagnosticBag diagnostics, out ImmutableArray<BoundLocalDeclaration> declarations)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
if (nodeOpt == null)
{
declarations = ImmutableArray<BoundLocalDeclaration>.Empty;
return null;
}
TypeSyntax typeSyntax = nodeOpt.Type;
if (typeSyntax is ScopedTypeSyntax scopedTypeSyntax)
{
ModifierUtils.CheckScopedModifierAvailability(typeSyntax, scopedTypeSyntax.ScopedKeyword, diagnostics);
typeSyntax = scopedTypeSyntax.Type;
}
if (localKind == LocalDeclarationKind.RegularVariable)
{
typeSyntax = typeSyntax.SkipRef();
}
bool isVar;
AliasSymbol alias;
TypeWithAnnotations declTypeOpt = BindTypeOrVarKeyword(typeSyntax, diagnostics, out isVar, out alias);
SeparatedSyntaxList<VariableDeclaratorSyntax> variables = nodeOpt.Variables;
int count = variables.Count;
if (isVar && count > 1)
{
Error(diagnostics, ErrorCode.ERR_ImplicitlyTypedVariableMultipleDeclarator, (CSharpSyntaxNode)nodeOpt);
}
BoundLocalDeclaration[] array = new BoundLocalDeclaration[count];
for (int i = 0; i < count; i++)
{
VariableDeclaratorSyntax declarator = variables[i];
bool includeBoundType = i == 0;
BoundLocalDeclaration boundLocalDeclaration = BindVariableDeclaration(localKind, isVar, declarator, typeSyntax, declTypeOpt, alias, diagnostics, includeBoundType);
array[i] = boundLocalDeclaration;
}
declarations = ImmutableArrayExtensions.AsImmutableOrNull<BoundLocalDeclaration>(array);
if (count != 1)
{
return new BoundMultipleLocalDeclarations((SyntaxNode)(object)nodeOpt, declarations);
}
return declarations[0];
}
internal BoundStatement BindStatementExpressionList(SeparatedSyntaxList<ExpressionSyntax> statements, BindingDiagnosticBag diagnostics)
{
int count = statements.Count;
switch (count)
{
case 0:
return null;
case 1:
{
ExpressionSyntax expressionSyntax2 = statements[0];
return BindExpressionStatement(expressionSyntax2, expressionSyntax2, allowsAnyExpression: false, diagnostics);
}
default:
{
ArrayBuilder<BoundStatement> instance = ArrayBuilder<BoundStatement>.GetInstance();
for (int i = 0; i < count; i++)
{
ExpressionSyntax expressionSyntax = statements[i];
BoundExpressionStatement boundExpressionStatement = BindExpressionStatement(expressionSyntax, expressionSyntax, allowsAnyExpression: false, diagnostics);
instance.Add((BoundStatement)boundExpressionStatement);
}
return BoundStatementList.Synthesized(statements.Node, instance.ToImmutableAndFree());
}
}
}
private BoundStatement BindForEach(CommonForEachStatementSyntax node, BindingDiagnosticBag diagnostics)
{
Binder binder = GetBinder((SyntaxNode)(object)node);
return GetBinder((SyntaxNode)(object)node.Expression).WrapWithVariablesIfAny(node.Expression, binder.BindForEachParts(diagnostics, binder));
}
internal virtual BoundStatement BindForEachParts(BindingDiagnosticBag diagnostics, Binder originalBinder)
{
return Next.BindForEachParts(diagnostics, originalBinder);
}
internal virtual BoundStatement BindForEachDeconstruction(BindingDiagnosticBag diagnostics, Binder originalBinder)
{
return Next.BindForEachDeconstruction(diagnostics, originalBinder);
}
private BoundStatement BindBreak(BreakStatementSyntax node, BindingDiagnosticBag diagnostics)
{
GeneratedLabelSymbol breakLabel = BreakLabel;
if ((object)breakLabel == null)
{
Error(diagnostics, ErrorCode.ERR_NoBreakOrCont, (CSharpSyntaxNode)node);
return new BoundBadStatement((SyntaxNode)(object)node, ImmutableArray<BoundNode>.Empty, hasErrors: true);
}
return new BoundBreakStatement((SyntaxNode)(object)node, breakLabel);
}
private BoundStatement BindContinue(ContinueStatementSyntax node, BindingDiagnosticBag diagnostics)
{
GeneratedLabelSymbol continueLabel = ContinueLabel;
if ((object)continueLabel == null)
{
Error(diagnostics, ErrorCode.ERR_NoBreakOrCont, (CSharpSyntaxNode)node);
return new BoundBadStatement((SyntaxNode)(object)node, ImmutableArray<BoundNode>.Empty, hasErrors: true);
}
return new BoundContinueStatement((SyntaxNode)(object)node, continueLabel);
}
private static SwitchBinder GetSwitchBinder(Binder binder)
{
SwitchBinder switchBinder = binder as SwitchBinder;
while (binder != null && switchBinder == null)
{
binder = binder.Next;
switchBinder = binder as SwitchBinder;
}
return switchBinder;
}
protected static bool IsInAsyncMethod(MethodSymbol method)
{
return method?.IsAsync ?? false;
}
protected bool IsInAsyncMethod()
{
return IsInAsyncMethod(ContainingMemberOrLambda as MethodSymbol);
}
protected bool IsEffectivelyTaskReturningAsyncMethod()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
Symbol containingMemberOrLambda = ContainingMemberOrLambda;
if ((object)containingMemberOrLambda != null && (int)containingMemberOrLambda.Kind == 9)
{
return ((MethodSymbol)containingMemberOrLambda).IsAsyncEffectivelyReturningTask(Compilation);
}
return false;
}
protected bool IsEffectivelyGenericTaskReturningAsyncMethod()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
Symbol containingMemberOrLambda = ContainingMemberOrLambda;
if ((object)containingMemberOrLambda != null && (int)containingMemberOrLambda.Kind == 9)
{
return ((MethodSymbol)containingMemberOrLambda).IsAsyncEffectivelyReturningGenericTask(Compilation);
}
return false;
}
protected bool IsIAsyncEnumerableOrIAsyncEnumeratorReturningAsyncMethod()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
Symbol containingMemberOrLambda = ContainingMemberOrLambda;
if ((object)containingMemberOrLambda != null && (int)containingMemberOrLambda.Kind == 9)
{
MethodSymbol method = (MethodSymbol)containingMemberOrLambda;
if (!method.IsAsyncReturningIAsyncEnumerable(Compilation))
{
return method.IsAsyncReturningIAsyncEnumerator(Compilation);
}
return true;
}
return false;
}
protected virtual TypeSymbol GetCurrentReturnType(out RefKind refKind)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected I4, but got Unknown
if (ContainingMemberOrLambda is MethodSymbol methodSymbol)
{
refKind = (RefKind)(int)methodSymbol.RefKind;
TypeSymbol returnType = methodSymbol.ReturnType;
if ((object)returnType == LambdaSymbol.ReturnTypeIsBeingInferred)
{
return null;
}
return returnType;
}
refKind = (RefKind)0;
return null;
}
private BoundStatement BindReturn(ReturnStatementSyntax syntax, BindingDiagnosticBag diagnostics)
{
//IL_0001: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Invalid comparison between Unknown and I4
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Invalid comparison between Unknown and I4
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: 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_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
RefKind refKind = (RefKind)0;
ExpressionSyntax expressionSyntax = syntax.Expression?.CheckAndUnwrapRefExpression(diagnostics, out refKind);
BoundExpression boundExpression = null;
if (expressionSyntax != null)
{
BindValueKind requiredReturnValueKind = GetRequiredReturnValueKind(refKind);
boundExpression = BindValue(expressionSyntax, diagnostics, requiredReturnValueKind);
}
else
{
SynthesizedInteractiveInitializerMethod synthesizedInteractiveInitializerMethod = ContainingMemberOrLambda as SynthesizedInteractiveInitializerMethod;
if (synthesizedInteractiveInitializerMethod != null)
{
boundExpression = new BoundDefaultExpression((SyntaxNode)(object)synthesizedInteractiveInitializerMethod.GetNonNullSyntaxNode(), synthesizedInteractiveInitializerMethod.ResultType);
}
}
RefKind refKind2;
TypeSymbol currentReturnType = GetCurrentReturnType(out refKind2);
bool flag = false;
SyntaxToken returnKeyword;
if (IsDirectlyInIterator)
{
returnKeyword = syntax.ReturnKeyword;
diagnostics.Add(ErrorCode.ERR_ReturnInIterator, ((SyntaxToken)(ref returnKeyword)).GetLocation());
flag = true;
}
else if (IsInAsyncMethod())
{
if ((int)refKind != 0)
{
returnKeyword = syntax.ReturnKeyword;
diagnostics.Add(ErrorCode.ERR_MustNotHaveRefReturn, ((SyntaxToken)(ref returnKeyword)).GetLocation());
flag = true;
}
else if (IsIAsyncEnumerableOrIAsyncEnumeratorReturningAsyncMethod())
{
returnKeyword = syntax.ReturnKeyword;
diagnostics.Add(ErrorCode.ERR_ReturnInIterator, ((SyntaxToken)(ref returnKeyword)).GetLocation());
flag = true;
}
}
else if ((object)currentReturnType != null && (int)refKind > 0 != (int)refKind2 > 0)
{
ErrorCode code = (((int)refKind != 0) ? ErrorCode.ERR_MustNotHaveRefReturn : ErrorCode.ERR_MustHaveRefReturn);
returnKeyword = syntax.ReturnKeyword;
diagnostics.Add(code, ((SyntaxToken)(ref returnKeyword)).GetLocation());
flag = true;
}
if (boundExpression != null)
{
flag |= boundExpression.HasErrors || ((object)boundExpression.Type != null && boundExpression.Type.IsErrorType());
}
if (flag)
{
return new BoundReturnStatement((SyntaxNode)(object)syntax, refKind, BindToTypeForErrorRecovery(boundExpression), CheckOverflowAtRuntime, hasErrors: true);
}
if ((object)currentReturnType != null)
{
if (currentReturnType.IsVoidType() || IsEffectivelyTaskReturningAsyncMethod())
{
if (boundExpression != null)
{
Symbol containingMemberOrLambda = ContainingMemberOrLambda;
if (containingMemberOrLambda is LambdaSymbol)
{
if (currentReturnType.IsVoidType())
{
Error(diagnostics, ErrorCode.ERR_RetNoObjectRequiredLambda, syntax.ReturnKeyword);
}
else
{
Error(diagnostics, ErrorCode.ERR_TaskRetNoObjectRequiredLambda, syntax.ReturnKeyword, currentReturnType);
}
flag = true;
}
else
{
if (currentReturnType.IsVoidType())
{
Error(diagnostics, ErrorCode.ERR_RetNoObjectRequired, syntax.ReturnKeyword, containingMemberOrLambda);
}
else
{
Error(diagnostics, ErrorCode.ERR_TaskRetNoObjectRequired, syntax.ReturnKeyword, containingMemberOrLambda, currentReturnType);
}
flag = true;
}
}
}
else if (boundExpression == null)
{
TypeSymbol typeSymbol = (IsEffectivelyGenericTaskReturningAsyncMethod() ? currentReturnType.GetMemberTypeArgumentsNoUseSiteDiagnostics().Single() : currentReturnType);
Error(diagnostics, ErrorCode.ERR_RetObjectRequired, syntax.ReturnKeyword, typeSymbol);
flag = true;
}
else
{
boundExpression = CreateReturnConversion((SyntaxNode)(object)syntax, diagnostics, boundExpression, refKind2, currentReturnType);
}
}
else if ((object)boundExpression?.Type != null && boundExpression.Type.IsVoidType())
{
Error(diagnostics, ErrorCode.ERR_CantReturnVoid, (CSharpSyntaxNode)expressionSyntax);
flag = true;
}
return new BoundReturnStatement((SyntaxNode)(object)syntax, refKind, flag ? BindToTypeForErrorRecovery(boundExpression) : boundExpression, flag);
}
internal BoundExpression CreateReturnConversion(SyntaxNode syntax, BindingDiagnosticBag diagnostics, BoundExpression argument, RefKind returnRefKind, TypeSymbol returnType)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion;
if (IsInAsyncMethod())
{
if (!IsEffectivelyGenericTaskReturningAsyncMethod())
{
conversion = Conversion.NoConversion;
flag = true;
}
else
{
returnType = returnType.GetMemberTypeArgumentsNoUseSiteDiagnostics().Single();
conversion = Conversions.ClassifyConversionFromExpression(argument, returnType, CheckOverflowAtRuntime, ref useSiteInfo);
}
}
else
{
conversion = Conversions.ClassifyConversionFromExpression(argument, returnType, CheckOverflowAtRuntime, ref useSiteInfo);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(syntax, useSiteInfo);
if (!argument.HasAnyErrors)
{
if ((int)returnRefKind != 0)
{
if (conversion.Kind == ConversionKind.Identity)
{
return BindToNaturalType(argument, diagnostics);
}
Error(diagnostics, ErrorCode.ERR_RefReturnMustHaveIdentityConversion, SyntaxNodeOrToken.op_Implicit(argument.Syntax), returnType);
argument = argument.WithHasErrors();
}
else if ((!conversion.IsImplicit || !conversion.IsValid) && !flag)
{
if (IsEffectivelyGenericTaskReturningAsyncMethod() && TypeSymbol.Equals(argument.Type, GetCurrentReturnType(out var _), (TypeCompareKind)0))
{
Error(diagnostics, ErrorCode.ERR_BadAsyncReturnExpression, SyntaxNodeOrToken.op_Implicit(argument.Syntax), returnType, argument.Type);
}
else
{
GenerateImplicitConversionError(diagnostics, argument.Syntax, conversion, argument, returnType);
if (ContainingMemberOrLambda is LambdaSymbol)
{
ReportCantConvertLambdaReturn(argument.Syntax, diagnostics);
}
}
}
}
return CreateConversion(argument.Syntax, argument, conversion, isCast: false, null, returnType, diagnostics);
}
private BoundTryStatement BindTryStatement(TryStatementSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
BoundBlock tryBlock = BindEmbeddedBlock(node.Block, diagnostics);
ImmutableArray<BoundCatchBlock> catchBlocks = BindCatchBlocks(node.Catches, diagnostics);
BoundBlock finallyBlockOpt = ((node.Finally != null) ? BindEmbeddedBlock(node.Finally.Block, diagnostics) : null);
return new BoundTryStatement((SyntaxNode)(object)node, tryBlock, catchBlocks, finallyBlockOpt);
}
private ImmutableArray<BoundCatchBlock> BindCatchBlocks(SyntaxList<CatchClauseSyntax> catchClauses, BindingDiagnosticBag diagnostics)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
int count = catchClauses.Count;
if (count == 0)
{
return ImmutableArray<BoundCatchBlock>.Empty;
}
ArrayBuilder<BoundCatchBlock> instance = ArrayBuilder<BoundCatchBlock>.GetInstance(count);
bool flag = false;
Enumerator<CatchClauseSyntax> enumerator = catchClauses.GetEnumerator();
while (enumerator.MoveNext())
{
CatchClauseSyntax current = enumerator.Current;
if (flag)
{
SyntaxToken catchKeyword = current.CatchKeyword;
diagnostics.Add(ErrorCode.ERR_TooManyCatches, ((SyntaxToken)(ref catchKeyword)).GetLocation());
}
BoundCatchBlock boundCatchBlock = GetBinder((SyntaxNode)(object)current).BindCatchBlock(current, instance, diagnostics);
instance.Add(boundCatchBlock);
flag |= current.Declaration == null && current.Filter == null;
}
return instance.ToImmutableAndFree();
}
private BoundCatchBlock BindCatchBlock(CatchClauseSyntax node, ArrayBuilder<BoundCatchBlock> previousBlocks, BindingDiagnosticBag diagnostics)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
TypeSymbol typeSymbol = null;
BoundExpression boundExpression = null;
CatchDeclarationSyntax declaration = node.Declaration;
if (declaration != null)
{
typeSymbol = BindType(declaration.Type, diagnostics).Type;
if (typeSymbol.IsErrorType())
{
flag = true;
}
else
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
TypeSymbol type = typeSymbol.EffectiveType(ref useSiteInfo);
if (!Compilation.IsExceptionType(type, ref useSiteInfo))
{
Error(diagnostics, ErrorCode.ERR_BadExceptionType, (CSharpSyntaxNode)declaration.Type);
flag = true;
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)declaration.Type, useSiteInfo);
}
else
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddDependencies(useSiteInfo);
}
}
}
CatchFilterClauseSyntax filter = node.Filter;
if (filter != null)
{
boundExpression = GetBinder((SyntaxNode)(object)filter).BindCatchFilter(filter, diagnostics);
flag |= boundExpression.HasAnyErrors;
}
if (!flag)
{
Enumerator<BoundCatchBlock> enumerator = previousBlocks.GetEnumerator();
while (enumerator.MoveNext())
{
BoundCatchBlock current = enumerator.Current;
TypeSymbol exceptionTypeOpt = current.ExceptionTypeOpt;
if (current.ExceptionFilterOpt != null || (object)exceptionTypeOpt == null || exceptionTypeOpt.IsErrorType())
{
continue;
}
if ((object)typeSymbol != null)
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo2 = GetNewCompoundUseSiteInfo(diagnostics);
if (Conversions.HasIdentityOrImplicitReferenceConversion(typeSymbol, exceptionTypeOpt, ref useSiteInfo2))
{
Error(diagnostics, ErrorCode.ERR_UnreachableCatch, (CSharpSyntaxNode)declaration.Type, new object[1] { exceptionTypeOpt });
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)declaration.Type, useSiteInfo2);
flag = true;
break;
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)declaration.Type, useSiteInfo2);
}
else if (TypeSymbol.Equals(exceptionTypeOpt, Compilation.GetWellKnownType((WellKnownType)52), (TypeCompareKind)0) && Compilation.SourceAssembly.RuntimeCompatibilityWrapNonExceptionThrows)
{
Error(diagnostics, ErrorCode.WRN_UnreachableGeneralCatch, node.CatchKeyword);
break;
}
}
}
ImmutableArray<LocalSymbol> declaredLocalsForScope = GetBinder((SyntaxNode)(object)node).GetDeclaredLocalsForScope((SyntaxNode)(object)node);
BoundExpression exceptionSourceOpt = null;
LocalSymbol localSymbol = declaredLocalsForScope.FirstOrDefault();
if ((object)localSymbol != null && localSymbol.DeclarationKind == LocalDeclarationKind.CatchVariable)
{
flag |= ValidateDeclarationNameConflictsInScope(localSymbol, diagnostics);
exceptionSourceOpt = new BoundLocal((SyntaxNode)(object)declaration, localSymbol, null, localSymbol.Type);
}
BoundBlock body = BindEmbeddedBlock(node.Block, diagnostics);
return new BoundCatchBlock((SyntaxNode)(object)node, declaredLocalsForScope, exceptionSourceOpt, typeSymbol, null, boundExpression, body, flag);
}
private BoundExpression BindCatchFilter(CatchFilterClauseSyntax filter, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureExceptionFilter.CheckFeatureAvailability(diagnostics, filter.WhenKeyword);
BoundExpression boundExpression = BindBooleanExpression(filter.FilterExpression, diagnostics);
if (boundExpression.ConstantValueOpt != (ConstantValue)null)
{
ErrorCode code = (boundExpression.ConstantValueOpt.BooleanValue ? ErrorCode.WRN_FilterIsConstantTrue : ((filter.Parent.Parent is TryStatementSyntax tryStatementSyntax && tryStatementSyntax.Catches.Count == 1 && tryStatementSyntax.Finally == null) ? ErrorCode.WRN_FilterIsConstantFalseRedundantTryCatch : ErrorCode.WRN_FilterIsConstantFalse));
Error(diagnostics, code, (CSharpSyntaxNode)filter.FilterExpression);
}
return boundExpression;
}
private void ReportCantConvertLambdaReturn(SyntaxNode syntax, BindingDiagnosticBag diagnostics)
{
if (!(syntax.Parent is QueryClauseSyntax) && !(syntax.Parent is SelectOrGroupClauseSyntax) && ContainingMemberOrLambda is LambdaSymbol lambdaSymbol)
{
Location locationForDiagnostics = GetLocationForDiagnostics(syntax);
if (IsInAsyncMethod())
{
Error(diagnostics, ErrorCode.ERR_CantConvAsyncAnonFuncReturns, locationForDiagnostics, lambdaSymbol.MessageID.Localize(), lambdaSymbol.ReturnType);
}
else
{
Error(diagnostics, ErrorCode.ERR_CantConvAnonMethReturns, locationForDiagnostics, lambdaSymbol.MessageID.Localize());
}
}
}
private static Location GetLocationForDiagnostics(SyntaxNode node)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken val;
TextSpan span;
if (!(node is LambdaExpressionSyntax lambdaExpressionSyntax))
{
if (node is AnonymousMethodExpressionSyntax anonymousMethodExpressionSyntax)
{
SyntaxTree syntaxTree = anonymousMethodExpressionSyntax.SyntaxTree;
int spanStart = ((SyntaxNode)anonymousMethodExpressionSyntax).SpanStart;
ParameterListSyntax? parameterList = anonymousMethodExpressionSyntax.ParameterList;
int end;
if (parameterList == null)
{
val = anonymousMethodExpressionSyntax.DelegateKeyword;
span = ((SyntaxToken)(ref val)).Span;
end = ((TextSpan)(ref span)).End;
}
else
{
span = ((SyntaxNode)parameterList).Span;
end = ((TextSpan)(ref span)).End;
}
return Location.Create(syntaxTree, TextSpan.FromBounds(spanStart, end));
}
return node.Location;
}
SyntaxTree syntaxTree2 = lambdaExpressionSyntax.SyntaxTree;
int spanStart2 = ((SyntaxNode)lambdaExpressionSyntax).SpanStart;
val = lambdaExpressionSyntax.ArrowToken;
span = ((SyntaxToken)(ref val)).Span;
return Location.Create(syntaxTree2, TextSpan.FromBounds(spanStart2, ((TextSpan)(ref span)).End));
}
private static bool IsValidStatementExpression(SyntaxNode syntax, BoundExpression expression)
{
if (!SyntaxFacts.IsStatementExpression(syntax))
{
return false;
}
if (expression.IsSuppressed)
{
return false;
}
if (expression.Kind == BoundKind.DelegateCreationExpression || expression.Kind == BoundKind.NameOfOperator)
{
return false;
}
return true;
}
internal BoundBlock CreateBlockFromExpression(CSharpSyntaxNode node, ImmutableArray<LocalSymbol> locals, RefKind refKind, BoundExpression expression, ExpressionSyntax expressionSyntax, BindingDiagnosticBag diagnostics)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Invalid comparison between Unknown and I4
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Invalid comparison between Unknown and I4
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Invalid comparison between Unknown and I4
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
RefKind refKind2;
TypeSymbol currentReturnType = GetCurrentReturnType(out refKind2);
SyntaxNode val = (SyntaxNode)(((object)expressionSyntax) ?? ((object)expression.Syntax));
BoundStatement item;
if (IsInAsyncMethod() && (int)refKind != 0)
{
Error(diagnostics, ErrorCode.ERR_MustNotHaveRefReturn, SyntaxNodeOrToken.op_Implicit(val));
expression = BindToTypeForErrorRecovery(expression);
item = new BoundReturnStatement(val, refKind, expression, CheckOverflowAtRuntime)
{
WasCompilerGenerated = true
};
}
else if ((object)currentReturnType != null)
{
if ((int)refKind > 0 != (int)refKind2 > 0 && expression.Kind != BoundKind.ThrowExpression)
{
ErrorCode code = (((int)refKind != 0) ? ErrorCode.ERR_MustNotHaveRefReturn : ErrorCode.ERR_MustHaveRefReturn);
Error(diagnostics, code, SyntaxNodeOrToken.op_Implicit(val));
expression = BindToTypeForErrorRecovery(expression);
item = new BoundReturnStatement(val, (RefKind)0, expression, CheckOverflowAtRuntime)
{
WasCompilerGenerated = true
};
}
else if (currentReturnType.IsVoidType() || IsEffectivelyTaskReturningAsyncMethod())
{
bool hasErrors = false;
if (expressionSyntax == null || !IsValidExpressionBody((SyntaxNode)(object)expressionSyntax, expression))
{
expression = BindToTypeForErrorRecovery(expression);
Error(diagnostics, ErrorCode.ERR_IllegalStatement, SyntaxNodeOrToken.op_Implicit(val));
hasErrors = true;
}
else
{
expression = BindToNaturalType(expression, diagnostics);
}
BoundExpressionStatement boundExpressionStatement = new BoundExpressionStatement(val, expression, hasErrors);
CheckForUnobservedAwaitable(expression, diagnostics);
item = boundExpressionStatement;
}
else if (IsIAsyncEnumerableOrIAsyncEnumeratorReturningAsyncMethod())
{
Error(diagnostics, ErrorCode.ERR_ReturnInIterator, SyntaxNodeOrToken.op_Implicit(val));
expression = BindToTypeForErrorRecovery(expression);
item = new BoundReturnStatement(val, refKind2, expression, CheckOverflowAtRuntime)
{
WasCompilerGenerated = true
};
}
else
{
expression = ((!currentReturnType.IsErrorType()) ? CreateReturnConversion(val, diagnostics, expression, refKind, currentReturnType) : BindToTypeForErrorRecovery(expression));
item = new BoundReturnStatement(val, refKind2, expression, CheckOverflowAtRuntime)
{
WasCompilerGenerated = true
};
}
}
else
{
TypeSymbol? type = expression.Type;
if ((object)type != null && (int)type.SpecialType == 6)
{
expression = BindToNaturalType(expression, diagnostics);
item = new BoundExpressionStatement(val, expression)
{
WasCompilerGenerated = true
};
}
else
{
if (!(ContainingMemberOrLambda is MethodSymbol methodSymbol) || (object)methodSymbol.ReturnType != LambdaSymbol.ReturnTypeIsBeingInferred)
{
expression = BindToNaturalType(expression, diagnostics);
}
item = new BoundReturnStatement(val, refKind, expression, CheckOverflowAtRuntime)
{
WasCompilerGenerated = true
};
}
}
return new BoundBlock((SyntaxNode)(object)node, locals, ImmutableArray.Create(item))
{
WasCompilerGenerated = (node.Kind() != SyntaxKind.ArrowExpressionClause)
};
}
private static bool IsValidExpressionBody(SyntaxNode expressionSyntax, BoundExpression expression)
{
if (!IsValidStatementExpression(expressionSyntax, expression))
{
return expressionSyntax.Kind() == SyntaxKind.ThrowExpression;
}
return true;
}
internal virtual BoundBlock BindExpressionBodyAsBlock(ArrowExpressionClauseSyntax expressionBody, BindingDiagnosticBag diagnostics)
{
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
CSharpSyntaxNode parent = expressionBody.Parent;
MessageID? messageID;
if (!(parent is ConstructorDeclarationSyntax) && !(parent is DestructorDeclarationSyntax))
{
if (!(parent is AccessorDeclarationSyntax))
{
if (!(parent is BaseMethodDeclarationSyntax))
{
if (!(parent is IndexerDeclarationSyntax))
{
if (!(parent is PropertyDeclarationSyntax))
{
if (!(parent is LocalFunctionStatementSyntax))
{
if (parent != null)
{
throw ExceptionUtilities.UnexpectedValue((object)expressionBody.Parent.Kind());
}
messageID = null;
}
else
{
messageID = null;
}
}
else
{
messageID = MessageID.IDS_FeatureExpressionBodiedProperty;
}
}
else
{
messageID = MessageID.IDS_FeatureExpressionBodiedIndexer;
}
}
else
{
messageID = MessageID.IDS_FeatureExpressionBodiedMethod;
}
}
else
{
messageID = MessageID.IDS_FeatureExpressionBodiedAccessor;
}
}
else
{
messageID = MessageID.IDS_FeatureExpressionBodiedDeOrConstructor;
}
messageID?.CheckFeatureAvailability(diagnostics, expressionBody.ArrowToken);
Binder binder = GetBinder((SyntaxNode)(object)expressionBody);
return bindExpressionBodyAsBlockInternal(expressionBody, binder, diagnostics);
static BoundBlock bindExpressionBodyAsBlockInternal(ArrowExpressionClauseSyntax arrowExpressionClauseSyntax, Binder bodyBinder, BindingDiagnosticBag diagnostics2)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
RefKind refKind;
ExpressionSyntax expressionSyntax = arrowExpressionClauseSyntax.Expression.CheckAndUnwrapRefExpression(diagnostics2, out refKind);
BindValueKind requiredReturnValueKind = bodyBinder.GetRequiredReturnValueKind(refKind);
BoundExpression expression = bodyBinder.BindValue(expressionSyntax, diagnostics2, requiredReturnValueKind);
return bodyBinder.CreateBlockFromExpression(arrowExpressionClauseSyntax, bodyBinder.GetDeclaredLocalsForScope((SyntaxNode)(object)arrowExpressionClauseSyntax), refKind, expression, expressionSyntax, diagnostics2);
}
}
public BoundBlock BindLambdaExpressionAsBlock(ExpressionSyntax body, BindingDiagnosticBag diagnostics)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
Binder binder = GetBinder((SyntaxNode)(object)body);
RefKind refKind;
ExpressionSyntax expressionSyntax = body.CheckAndUnwrapRefExpression(diagnostics, out refKind);
BindValueKind requiredReturnValueKind = GetRequiredReturnValueKind(refKind);
BoundExpression expression = binder.BindValue(expressionSyntax, diagnostics, requiredReturnValueKind);
return binder.CreateBlockFromExpression(body, binder.GetDeclaredLocalsForScope((SyntaxNode)(object)body), refKind, expression, expressionSyntax, diagnostics);
}
public BoundBlock CreateBlockFromExpression(ExpressionSyntax body, BoundExpression expression, BindingDiagnosticBag diagnostics)
{
Binder binder = GetBinder((SyntaxNode)(object)body);
return binder.CreateBlockFromExpression(body, binder.GetDeclaredLocalsForScope((SyntaxNode)(object)body), (RefKind)0, expression, body, diagnostics);
}
private BindValueKind GetRequiredReturnValueKind(RefKind refKind)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
BindValueKind result = BindValueKind.RValue;
if ((int)refKind != 0)
{
GetCurrentReturnType(out var refKind2);
result = (((int)refKind2 == 1) ? BindValueKind.RefReturn : BindValueKind.ReadonlyRef);
}
return result;
}
public virtual BoundNode BindMethodBody(CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
{
if (!(syntax is TypeDeclarationSyntax typeDecl))
{
if (!(syntax is BaseMethodDeclarationSyntax baseMethodDeclarationSyntax))
{
if (!(syntax is AccessorDeclarationSyntax accessorDeclarationSyntax))
{
if (!(syntax is ArrowExpressionClauseSyntax expressionBody))
{
if (syntax is CompilationUnitSyntax compilationUnit)
{
return BindSimpleProgram(compilationUnit, diagnostics);
}
throw ExceptionUtilities.UnexpectedValue((object)syntax.Kind());
}
return BindExpressionBodyAsBlock(expressionBody, diagnostics);
}
return BindMethodBody(accessorDeclarationSyntax, accessorDeclarationSyntax.Body, accessorDeclarationSyntax.ExpressionBody, diagnostics);
}
if (baseMethodDeclarationSyntax.Kind() == SyntaxKind.ConstructorDeclaration)
{
return BindConstructorBody((ConstructorDeclarationSyntax)baseMethodDeclarationSyntax, diagnostics);
}
return BindMethodBody(baseMethodDeclarationSyntax, baseMethodDeclarationSyntax.Body, baseMethodDeclarationSyntax.ExpressionBody, diagnostics);
}
return BindPrimaryConstructorBody(typeDecl, diagnostics);
}
private BoundNode BindSimpleProgram(CompilationUnitSyntax compilationUnit, BindingDiagnosticBag diagnostics)
{
return GetBinder((SyntaxNode)(object)compilationUnit).BindSimpleProgramCompilationUnit(compilationUnit, diagnostics);
}
private BoundNode BindSimpleProgramCompilationUnit(CompilationUnitSyntax compilationUnit, BindingDiagnosticBag diagnostics)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
ArrayBuilder<BoundStatement> instance = ArrayBuilder<BoundStatement>.GetInstance();
bool flag = true;
Enumerator<MemberDeclarationSyntax> enumerator = compilationUnit.Members.GetEnumerator();
while (enumerator.MoveNext())
{
if (enumerator.Current is GlobalStatementSyntax globalStatementSyntax)
{
if (flag)
{
flag = false;
MessageID.IDS_TopLevelStatements.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)globalStatementSyntax);
}
BoundStatement boundStatement = BindStatement(globalStatementSyntax.Statement, diagnostics);
instance.Add(boundStatement);
}
}
return new BoundNonConstructorMethodBody((SyntaxNode)(object)compilationUnit, FinishBindBlockParts(compilationUnit, instance.ToImmutableAndFree()).MakeCompilerGenerated(), null);
}
private BoundNode BindPrimaryConstructorBody(TypeDeclarationSyntax typeDecl, BindingDiagnosticBag diagnostics)
{
PrimaryConstructorBaseTypeSyntax primaryConstructorBaseTypeIfClass = typeDecl.PrimaryConstructorBaseTypeIfClass;
BoundExpressionStatement initializer;
ImmutableArray<LocalSymbol> locals;
if (primaryConstructorBaseTypeIfClass != null)
{
Binder? binder = GetBinder((SyntaxNode)(object)primaryConstructorBaseTypeIfClass);
initializer = binder.BindConstructorInitializer(primaryConstructorBaseTypeIfClass, diagnostics);
locals = binder.GetDeclaredLocalsForScope((SyntaxNode)(object)primaryConstructorBaseTypeIfClass);
}
else
{
initializer = BindImplicitConstructorInitializer((SyntaxNode)(object)typeDecl, diagnostics);
locals = ImmutableArray<LocalSymbol>.Empty;
}
return new BoundConstructorMethodBody((SyntaxNode)(object)typeDecl, locals, initializer, new BoundBlock((SyntaxNode)(object)typeDecl, ImmutableArray<LocalSymbol>.Empty, ImmutableArray<BoundStatement>.Empty).MakeCompilerGenerated(), null);
}
internal virtual BoundExpressionStatement BindConstructorInitializer(PrimaryConstructorBaseTypeSyntax initializer, BindingDiagnosticBag diagnostics)
{
BoundExpression expression = GetBinder((SyntaxNode)(object)initializer).BindConstructorInitializer(initializer.ArgumentList, (MethodSymbol)ContainingMember(), diagnostics);
return new BoundExpressionStatement((SyntaxNode)(object)initializer, expression);
}
private BoundNode BindConstructorBody(ConstructorDeclarationSyntax constructor, BindingDiagnosticBag diagnostics)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
ConstructorInitializerSyntax initializer = constructor.Initializer;
if (initializer == null && constructor.Body == null && constructor.ExpressionBody == null)
{
return null;
}
Binder binder = GetBinder((SyntaxNode)(object)constructor);
int num;
if (initializer == null)
{
num = 0;
}
else
{
num = (((SyntaxNode?)(object)initializer).IsKind(SyntaxKind.ThisConstructorInitializer) ? 1 : 0);
if (num != 0)
{
goto IL_006e;
}
}
if (hasPrimaryConstructor() && isInstanceConstructor(out var constructorSymbol) && !SynthesizedRecordCopyCtor.IsCopyConstructor(constructorSymbol))
{
Error(diagnostics, ErrorCode.ERR_UnexpectedOrMissingConstructorInitializerInRecord, initializer?.ThisOrBaseKeyword ?? constructor.Identifier);
}
goto IL_006e;
IL_006e:
if (num != 0 && ContainingType.IsDefaultValueTypeConstructor(initializer) && isInstanceConstructor(out var _) && hasPrimaryConstructor())
{
Error(diagnostics, ErrorCode.ERR_RecordStructConstructorCallsDefaultConstructor, initializer.ThisOrBaseKeyword);
}
return new BoundConstructorMethodBody((SyntaxNode)(object)constructor, binder.GetDeclaredLocalsForScope((SyntaxNode)(object)constructor), (initializer == null) ? binder.BindImplicitConstructorInitializer((SyntaxNode)(object)constructor, diagnostics) : binder.BindConstructorInitializer(initializer, diagnostics), (constructor.Body == null) ? null : ((BoundBlock)binder.BindStatement(constructor.Body, diagnostics)), (constructor.ExpressionBody == null) ? null : binder.BindExpressionBodyAsBlock(constructor.ExpressionBody, (constructor.Body == null) ? diagnostics : BindingDiagnosticBag.Discarded));
bool hasPrimaryConstructor()
{
if (ContainingType is SourceMemberContainerTypeSymbol sourceMemberContainerTypeSymbol)
{
return sourceMemberContainerTypeSymbol.HasPrimaryConstructor;
}
return false;
}
bool isInstanceConstructor(out MethodSymbol reference)
{
Symbol symbol = ContainingMember();
if (symbol is MethodSymbol methodSymbol && !symbol.IsStatic)
{
reference = methodSymbol;
return true;
}
reference = null;
return false;
}
}
internal virtual BoundExpressionStatement BindConstructorInitializer(ConstructorInitializerSyntax initializer, BindingDiagnosticBag diagnostics)
{
BoundExpression expression = GetBinder((SyntaxNode)(object)initializer).BindConstructorInitializer(initializer.ArgumentList, (MethodSymbol)ContainingMember(), diagnostics);
return new BoundExpressionStatement((SyntaxNode)(object)initializer, expression);
}
internal BoundExpressionStatement? BindImplicitConstructorInitializer(SyntaxNode ctorSyntax, BindingDiagnosticBag diagnostics)
{
BoundExpression boundExpression = BindImplicitConstructorInitializer((MethodSymbol)ContainingMember(), diagnostics, Compilation);
if (boundExpression == null)
{
return null;
}
return new BoundExpressionStatement(ctorSyntax, boundExpression)
{
WasCompilerGenerated = ((MethodSymbol)ContainingMember()).IsImplicitlyDeclared
};
}
internal static BoundExpression? BindImplicitConstructorInitializer(MethodSymbol constructor, BindingDiagnosticBag diagnostics, CSharpCompilation compilation)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Invalid comparison between Unknown and I4
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
if ((int)constructor.MethodKind != 1 || constructor.IsExtern)
{
return null;
}
NamedTypeSymbol containingType = constructor.ContainingType;
NamedTypeSymbol baseTypeNoUseSiteDiagnostics = containingType.BaseTypeNoUseSiteDiagnostics;
SourceMemberMethodSymbol sourceMemberMethodSymbol = constructor as SourceMemberMethodSymbol;
if ((object)baseTypeNoUseSiteDiagnostics != null)
{
if ((int)baseTypeNoUseSiteDiagnostics.SpecialType == 1)
{
return GenerateBaseParameterlessConstructorInitializer(constructor, diagnostics);
}
if (baseTypeNoUseSiteDiagnostics.IsErrorType() || baseTypeNoUseSiteDiagnostics.IsStatic)
{
return null;
}
}
if (containingType.IsStructType() || containingType.IsEnumType())
{
return null;
}
if (constructor is SynthesizedRecordCopyCtor constructor2)
{
return GenerateBaseCopyConstructorInitializer(constructor2, diagnostics);
}
Binder binder;
if ((object)sourceMemberMethodSymbol == null)
{
CSharpSyntaxNode nonNullSyntaxNode = constructor.GetNonNullSyntaxNode();
BinderFactory binderFactory = compilation.GetBinderFactory(nonNullSyntaxNode.SyntaxTree);
if (nonNullSyntaxNode is TypeDeclarationSyntax typeDecl)
{
binder = binderFactory.GetInTypeBodyBinder(typeDecl);
}
else
{
SyntaxToken implicitConstructorBodyToken = GetImplicitConstructorBodyToken(nonNullSyntaxNode);
binder = binderFactory.GetBinder((SyntaxNode)(object)nonNullSyntaxNode, ((SyntaxToken)(ref implicitConstructorBodyToken)).Position);
}
}
else
{
BinderFactory binderFactory2 = compilation.GetBinderFactory(sourceMemberMethodSymbol.SyntaxTree);
CSharpSyntaxNode syntaxNode = sourceMemberMethodSymbol.SyntaxNode;
if (!(syntaxNode is ConstructorDeclarationSyntax constructorDeclarationSyntax))
{
if (!(syntaxNode is TypeDeclarationSyntax typeDecl2))
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs", 3815);
}
binder = binderFactory2.GetInTypeBodyBinder(typeDecl2);
}
else
{
binder = binderFactory2.GetBinder((SyntaxNode)(object)constructorDeclarationSyntax.ParameterList);
}
}
return binder.WithAdditionalFlagsAndContainingMemberOrLambda(BinderFlags.ConstructorInitializer, constructor).BindConstructorInitializer(null, constructor, diagnostics);
}
private static SyntaxToken GetImplicitConstructorBodyToken(CSharpSyntaxNode containerNode)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return ((BaseTypeDeclarationSyntax)containerNode).OpenBraceToken;
}
internal static BoundCall? GenerateBaseParameterlessConstructorInitializer(MethodSymbol constructor, BindingDiagnosticBag diagnostics)
{
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol baseTypeNoUseSiteDiagnostics = constructor.ContainingType.BaseTypeNoUseSiteDiagnostics;
MethodSymbol methodSymbol = null;
LookupResultKind resultKind = LookupResultKind.Viable;
Location firstLocationOrNone = constructor.GetFirstLocationOrNone();
ImmutableArray<MethodSymbol>.Enumerator enumerator = baseTypeNoUseSiteDiagnostics.InstanceConstructors.GetEnumerator();
while (enumerator.MoveNext())
{
MethodSymbol current = enumerator.Current;
if (current.ParameterCount == 0)
{
methodSymbol = current;
break;
}
}
if ((object)methodSymbol == null)
{
diagnostics.Add(ErrorCode.ERR_BadCtorArgCount, firstLocationOrNone, baseTypeNoUseSiteDiagnostics, 0);
return null;
}
if (ReportUseSite(methodSymbol, diagnostics, firstLocationOrNone))
{
return null;
}
bool hasErrors = false;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = default(CompoundUseSiteInfo<AssemblySymbol>);
useSiteInfo._002Ector((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics, constructor.ContainingAssembly);
if (!AccessCheck.IsSymbolAccessible(methodSymbol, constructor.ContainingType, ref useSiteInfo))
{
diagnostics.Add(ErrorCode.ERR_BadAccess, firstLocationOrNone, methodSymbol);
resultKind = LookupResultKind.Inaccessible;
hasErrors = true;
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(firstLocationOrNone, useSiteInfo);
CSharpSyntaxNode nonNullSyntaxNode = constructor.GetNonNullSyntaxNode();
BoundExpression receiverOpt = new BoundThisReference((SyntaxNode)(object)nonNullSyntaxNode, constructor.ContainingType)
{
WasCompilerGenerated = true
};
return new BoundCall((SyntaxNode)(object)nonNullSyntaxNode, receiverOpt, (ThreeState)1, methodSymbol, ImmutableArray<BoundExpression>.Empty, ImmutableArray<string>.Empty, ImmutableArray<RefKind>.Empty, isDelegateCall: false, expanded: false, invokedAsExtensionMethod: false, ImmutableArray<int>.Empty, BitVector.Empty, resultKind, methodSymbol.ReturnType, hasErrors)
{
WasCompilerGenerated = true
};
}
private static BoundCall? GenerateBaseCopyConstructorInitializer(SynthesizedRecordCopyCtor constructor, BindingDiagnosticBag diagnostics)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol containingType = constructor.ContainingType;
NamedTypeSymbol baseTypeNoUseSiteDiagnostics = containingType.BaseTypeNoUseSiteDiagnostics;
Location firstLocationOrNone = constructor.GetFirstLocationOrNone();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = default(CompoundUseSiteInfo<AssemblySymbol>);
useSiteInfo._002Ector((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics, containingType.ContainingAssembly);
MethodSymbol methodSymbol = SynthesizedRecordCopyCtor.FindCopyConstructor(baseTypeNoUseSiteDiagnostics, containingType, ref useSiteInfo);
if ((object)methodSymbol == null)
{
diagnostics.Add(ErrorCode.ERR_NoCopyConstructorInBaseType, firstLocationOrNone, baseTypeNoUseSiteDiagnostics);
return null;
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo2 = default(CompoundUseSiteInfo<AssemblySymbol>);
useSiteInfo2._002Ector((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics, constructor.ContainingAssembly);
useSiteInfo2.Add(methodSymbol.GetUseSiteInfo());
if (ReportConstructorUseSiteDiagnostics(firstLocationOrNone, diagnostics, constructor.HasSetsRequiredMembers, useSiteInfo2))
{
return null;
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(firstLocationOrNone, useSiteInfo);
CSharpSyntaxNode nonNullSyntaxNode = constructor.GetNonNullSyntaxNode();
BoundExpression receiverOpt = new BoundThisReference((SyntaxNode)(object)nonNullSyntaxNode, constructor.ContainingType)
{
WasCompilerGenerated = true
};
BoundExpression item = new BoundParameter((SyntaxNode)(object)nonNullSyntaxNode, constructor.Parameters[0]);
return new BoundCall((SyntaxNode)(object)nonNullSyntaxNode, receiverOpt, (ThreeState)1, methodSymbol, ImmutableArray.Create(item), default(ImmutableArray<string>), default(ImmutableArray<RefKind>), isDelegateCall: false, expanded: false, invokedAsExtensionMethod: false, default(ImmutableArray<int>), default(BitVector), LookupResultKind.Viable, methodSymbol.ReturnType)
{
WasCompilerGenerated = true
};
}
private BoundNode BindMethodBody(CSharpSyntaxNode declaration, BlockSyntax blockBody, ArrowExpressionClauseSyntax expressionBody, BindingDiagnosticBag diagnostics)
{
if (blockBody == null && expressionBody == null)
{
return null;
}
return new BoundNonConstructorMethodBody((SyntaxNode)(object)declaration, (blockBody == null) ? null : ((BoundBlock)BindStatement(blockBody, diagnostics)), (expressionBody == null) ? null : BindExpressionBodyAsBlock(expressionBody, (blockBody == null) ? diagnostics : BindingDiagnosticBag.Discarded));
}
internal PatternLookupResult PerformPatternMethodLookup(BoundExpression receiver, string methodName, SyntaxNode syntaxNode, BindingDiagnosticBag diagnostics, out MethodSymbol result)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(diagnostics);
try
{
result = null;
BoundExpression boundExpression = BindInstanceMemberAccess(syntaxNode, syntaxNode, receiver, methodName, 0, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), invoked: true, indexed: false, instance);
if (boundExpression.Kind != BoundKind.MethodGroup)
{
return PatternLookupResult.NotAMethod;
}
AnalyzedArguments instance2 = AnalyzedArguments.GetInstance();
bool anyApplicableCandidates;
BoundExpression boundExpression2 = BindMethodGroupInvocation(syntaxNode, syntaxNode, methodName, (BoundMethodGroup)boundExpression, instance2, instance, null, allowUnexpandedForm: false, out anyApplicableCandidates);
instance2.Free();
if (boundExpression2.Kind != BoundKind.Call)
{
return PatternLookupResult.NotCallable;
}
BoundCall boundCall = (BoundCall)boundExpression2;
if (boundCall.ResultKind == LookupResultKind.Empty)
{
return PatternLookupResult.NoResults;
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
MethodSymbol method = boundCall.Method;
if (method is ErrorMethodSymbol || boundExpression2.HasAnyErrors)
{
return PatternLookupResult.ResultHasErrors;
}
result = method;
return PatternLookupResult.Success;
}
finally
{
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
}
}
internal TypeWithAnnotations BindTypeOrVarKeyword(TypeSyntax syntax, BindingDiagnosticBag diagnostics, out bool isVar)
{
NamespaceOrTypeOrAliasSymbolWithAnnotations symbol = BindTypeOrAliasOrVarKeyword(syntax, diagnostics, out isVar);
if (!isVar)
{
return UnwrapAlias(in symbol, diagnostics, (SyntaxNode)(object)syntax).TypeWithAnnotations;
}
return default(TypeWithAnnotations);
}
private TypeWithAnnotations BindTypeOrConstraintKeyword(TypeSyntax syntax, BindingDiagnosticBag diagnostics, out ConstraintContextualKeyword keyword)
{
NamespaceOrTypeOrAliasSymbolWithAnnotations symbol = BindTypeOrAliasOrConstraintKeyword(syntax, diagnostics, out keyword);
if (keyword == ConstraintContextualKeyword.None)
{
return UnwrapAlias(in symbol, diagnostics, (SyntaxNode)(object)syntax).TypeWithAnnotations;
}
return default(TypeWithAnnotations);
}
internal TypeWithAnnotations BindTypeOrVarKeyword(TypeSyntax syntax, BindingDiagnosticBag diagnostics, out bool isVar, out AliasSymbol alias)
{
NamespaceOrTypeOrAliasSymbolWithAnnotations symbol = BindTypeOrAliasOrVarKeyword(syntax, diagnostics, out isVar);
if (isVar)
{
alias = null;
return default(TypeWithAnnotations);
}
return UnwrapAlias(in symbol, out alias, diagnostics, (SyntaxNode)(object)syntax).TypeWithAnnotations;
}
private NamespaceOrTypeOrAliasSymbolWithAnnotations BindTypeOrAliasOrVarKeyword(TypeSyntax syntax, BindingDiagnosticBag diagnostics, out bool isVar)
{
if (syntax.IsVar)
{
NamespaceOrTypeOrAliasSymbolWithAnnotations result = BindTypeOrAliasOrKeyword((IdentifierNameSyntax)syntax, diagnostics, out isVar);
if (isVar)
{
CheckFeatureAvailability((SyntaxNode)(object)syntax, MessageID.IDS_FeatureImplicitLocal, diagnostics);
}
return result;
}
isVar = false;
return BindTypeOrAlias(syntax, diagnostics);
}
private NamespaceOrTypeOrAliasSymbolWithAnnotations BindTypeOrAliasOrConstraintKeyword(TypeSyntax syntax, BindingDiagnosticBag diagnostics, out ConstraintContextualKeyword keyword)
{
if (syntax.IsUnmanaged)
{
keyword = ConstraintContextualKeyword.Unmanaged;
}
else if (syntax.IsNotNull)
{
keyword = ConstraintContextualKeyword.NotNull;
}
else
{
keyword = ConstraintContextualKeyword.None;
}
if (keyword != ConstraintContextualKeyword.None)
{
IdentifierNameSyntax syntax2 = (IdentifierNameSyntax)syntax;
bool isKeyword;
NamespaceOrTypeOrAliasSymbolWithAnnotations result = BindTypeOrAliasOrKeyword(syntax2, diagnostics, out isKeyword);
if (isKeyword)
{
switch (keyword)
{
case ConstraintContextualKeyword.Unmanaged:
CheckFeatureAvailability((SyntaxNode)(object)syntax, MessageID.IDS_FeatureUnmanagedGenericTypeConstraint, diagnostics);
break;
case ConstraintContextualKeyword.NotNull:
CheckFeatureAvailability((SyntaxNode)(object)syntax2, MessageID.IDS_FeatureNotNullGenericTypeConstraint, diagnostics);
break;
default:
throw ExceptionUtilities.UnexpectedValue((object)keyword);
}
}
else
{
keyword = ConstraintContextualKeyword.None;
}
return result;
}
return BindTypeOrAlias(syntax, diagnostics);
}
private NamespaceOrTypeOrAliasSymbolWithAnnotations BindTypeOrAliasOrKeyword(IdentifierNameSyntax syntax, BindingDiagnosticBag diagnostics, out bool isKeyword)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return BindTypeOrAliasOrKeyword(syntax.Identifier, (SyntaxNode)(object)syntax, diagnostics, out isKeyword);
}
private NamespaceOrTypeOrAliasSymbolWithAnnotations BindTypeOrAliasOrKeyword(SyntaxToken identifier, SyntaxNode syntax, BindingDiagnosticBag diagnostics, out bool isKeyword)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
Symbol symbol = null;
LookupResult instance = LookupResult.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
LookupSymbolsInternal(instance, valueText, 0, null, LookupOptions.NamespacesOrTypesOnly, diagnose: false, ref useSiteInfo);
LookupResultKind kind = instance.Kind;
if (kind != LookupResultKind.Empty)
{
if (kind == LookupResultKind.Viable)
{
BindingDiagnosticBag instance2 = BindingDiagnosticBag.GetInstance(withDiagnostics: true, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
symbol = ResultSymbol(instance, valueText, 0, syntax, instance2, suppressUseSiteDiagnostics: false, out var wasError, null);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddDependencies((BindingDiagnosticBag<AssemblySymbol>)(object)instance2, false);
if (!wasError || !instance.IsSingleViable)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(((BindingDiagnosticBag)instance2).DiagnosticBag);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).Free();
if (instance.IsSingleViable)
{
if (UnwrapAlias(symbol, diagnostics, syntax) is TypeSymbol symbol2)
{
isKeyword = false;
if ((int)symbol.Kind != 0)
{
ReportDiagnosticsIfObsolete(diagnostics, symbol2, SyntaxNodeOrToken.op_Implicit(syntax), hasBaseReceiver: false);
}
}
else
{
isKeyword = true;
symbol = null;
}
}
else
{
isKeyword = false;
}
goto IL_00e8;
}
((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).Free();
}
isKeyword = true;
symbol = null;
}
else
{
isKeyword = true;
symbol = null;
}
goto IL_00e8;
IL_00e8:
instance.Free();
return NamespaceOrTypeOrAliasSymbolWithAnnotations.CreateUnannotated(AreNullableAnnotationsEnabled(identifier), symbol);
}
internal TypeWithAnnotations BindType(ExpressionSyntax syntax, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null, bool suppressUseSiteDiagnostics = false)
{
return UnwrapAlias(BindTypeOrAlias(syntax, diagnostics, basesBeingResolved, suppressUseSiteDiagnostics), diagnostics, (SyntaxNode)(object)syntax, basesBeingResolved).TypeWithAnnotations;
}
internal TypeWithAnnotations BindType(ExpressionSyntax syntax, BindingDiagnosticBag diagnostics, out AliasSymbol alias, ConsList<TypeSymbol> basesBeingResolved = null)
{
return UnwrapAlias(BindTypeOrAlias(syntax, diagnostics, basesBeingResolved), out alias, diagnostics, (SyntaxNode)(object)syntax, basesBeingResolved).TypeWithAnnotations;
}
internal NamespaceOrTypeOrAliasSymbolWithAnnotations BindTypeOrAlias(ExpressionSyntax syntax, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null, bool suppressUseSiteDiagnostics = false)
{
NamespaceOrTypeOrAliasSymbolWithAnnotations result = BindNamespaceOrTypeOrAliasSymbol(syntax, diagnostics, basesBeingResolved, basesBeingResolved != null || suppressUseSiteDiagnostics);
if (result.IsType || (result.IsAlias && UnwrapAliasNoDiagnostics(result.Symbol, basesBeingResolved) is TypeSymbol))
{
if (result.IsType)
{
result.TypeWithAnnotations.ReportDiagnosticsIfObsolete(this, (SyntaxNode)(object)syntax, diagnostics);
}
return result;
}
CSDiagnosticInfo errorInfo = diagnostics.Add(ErrorCode.ERR_BadSKknown, ((SyntaxNode)syntax).Location, syntax, result.Symbol.GetKindText(), MessageID.IDS_SK_TYPE.Localize());
return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(result.Symbol), result.Symbol, LookupResultKind.NotATypeOrNamespace, (DiagnosticInfo)(object)errorInfo));
}
private NamespaceOrTypeSymbol GetContainingNamespaceOrType(Symbol symbol)
{
return symbol.ContainingNamespaceOrType() ?? Compilation.Assembly.GlobalNamespace;
}
internal Symbol BindNamespaceAliasSymbol(IdentifierNameSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0001: 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)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (node.Identifier.Kind() == SyntaxKind.GlobalKeyword)
{
return Compilation.GlobalNamespaceAlias;
}
SyntaxToken identifier = node.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
LookupResult instance = LookupResult.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupSymbolsWithFallback(instance, valueText, 0, ref useSiteInfo, null, LookupOptions.NamespaceAliasesOnly);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
bool wasError;
Symbol result = ResultSymbol(instance, valueText, 0, (SyntaxNode)(object)node, diagnostics, suppressUseSiteDiagnostics: false, out wasError, null, LookupOptions.NamespaceAliasesOnly);
instance.Free();
return result;
}
internal NamespaceOrTypeOrAliasSymbolWithAnnotations BindNamespaceOrTypeSymbol(ExpressionSyntax syntax, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null)
{
return BindNamespaceOrTypeSymbol(syntax, diagnostics, basesBeingResolved, basesBeingResolved != null);
}
[MethodImpl(MethodImplOptions.NoInlining)]
internal NamespaceOrTypeOrAliasSymbolWithAnnotations BindNamespaceOrTypeSymbol(ExpressionSyntax syntax, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved, bool suppressUseSiteDiagnostics)
{
return UnwrapAlias(BindNamespaceOrTypeOrAliasSymbol(syntax, diagnostics, basesBeingResolved, suppressUseSiteDiagnostics), diagnostics, (SyntaxNode)(object)syntax, basesBeingResolved);
}
internal unsafe NamespaceOrTypeOrAliasSymbolWithAnnotations BindNamespaceOrTypeOrAliasSymbol(ExpressionSyntax syntax, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved, bool suppressUseSiteDiagnostics)
{
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0357: Unknown result type (might be due to invalid IL or missing references)
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
switch (syntax.Kind())
{
case SyntaxKind.NullableType:
return bindNullable();
case SyntaxKind.PredefinedType:
return bindPredefined();
case SyntaxKind.IdentifierName:
return BindNonGenericSimpleNamespaceOrTypeOrAliasSymbol((IdentifierNameSyntax)syntax, diagnostics, basesBeingResolved, suppressUseSiteDiagnostics, null);
case SyntaxKind.GenericName:
return BindGenericSimpleNamespaceOrTypeOrAliasSymbol((GenericNameSyntax)syntax, diagnostics, basesBeingResolved, null);
case SyntaxKind.AliasQualifiedName:
return bindAlias();
case SyntaxKind.QualifiedName:
{
QualifiedNameSyntax qualifiedNameSyntax = (QualifiedNameSyntax)syntax;
return BindQualifiedName(qualifiedNameSyntax.Left, qualifiedNameSyntax.Right, diagnostics, basesBeingResolved, suppressUseSiteDiagnostics);
}
case SyntaxKind.SimpleMemberAccessExpression:
{
MemberAccessExpressionSyntax memberAccessExpressionSyntax = (MemberAccessExpressionSyntax)syntax;
return BindQualifiedName(memberAccessExpressionSyntax.Expression, memberAccessExpressionSyntax.Name, diagnostics, basesBeingResolved, suppressUseSiteDiagnostics);
}
case SyntaxKind.ArrayType:
return BindArrayType((ArrayTypeSyntax)syntax, diagnostics, permitDimensions: false, basesBeingResolved, disallowRestrictedTypes: true);
case SyntaxKind.PointerType:
return bindPointer();
case SyntaxKind.FunctionPointerType:
{
FunctionPointerTypeSyntax functionPointerTypeSyntax = (FunctionPointerTypeSyntax)syntax;
MessageID.IDS_FeatureFunctionPointers.CheckFeatureAvailability(diagnostics, functionPointerTypeSyntax.DelegateKeyword);
CSDiagnosticInfo unsafeDiagnosticInfo = GetUnsafeDiagnosticInfo(null);
if (unsafeDiagnosticInfo != null)
{
SyntaxToken delegateKeyword = functionPointerTypeSyntax.DelegateKeyword;
SyntaxToken asteriskToken = functionPointerTypeSyntax.AsteriskToken;
BindingDiagnosticBag bindingDiagnosticBag = diagnostics;
SyntaxTree syntaxTree = ((SyntaxToken)(ref delegateKeyword)).SyntaxTree;
int spanStart = ((SyntaxToken)(ref delegateKeyword)).SpanStart;
TextSpan span = ((SyntaxToken)(ref asteriskToken)).Span;
bindingDiagnosticBag.Add((DiagnosticInfo?)(object)unsafeDiagnosticInfo, Location.Create(syntaxTree, TextSpan.FromBounds(spanStart, ((TextSpan)(ref span)).End)));
}
return TypeWithAnnotations.Create(FunctionPointerTypeSymbol.CreateFromSource(functionPointerTypeSyntax, this, diagnostics, basesBeingResolved, suppressUseSiteDiagnostics));
}
case SyntaxKind.OmittedTypeArgument:
return BindTypeArgument((TypeSyntax)syntax, diagnostics, basesBeingResolved);
case SyntaxKind.TupleType:
{
TupleTypeSyntax tupleTypeSyntax = (TupleTypeSyntax)syntax;
return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(tupleTypeSyntax.CloseParenToken), BindTupleType(tupleTypeSyntax, diagnostics, basesBeingResolved));
}
case SyntaxKind.RefType:
{
RefTypeSyntax refTypeSyntax = (RefTypeSyntax)syntax;
if (!((SyntaxNode)syntax).HasErrors)
{
SyntaxToken refKeyword = refTypeSyntax.RefKeyword;
if (refTypeSyntax.Parent is UsingDirectiveSyntax)
{
diagnostics.Add(ErrorCode.ERR_BadRefInUsingAlias, ((SyntaxToken)(ref refKeyword)).GetLocation());
}
else
{
diagnostics.Add(ErrorCode.ERR_UnexpectedToken, ((SyntaxToken)(ref refKeyword)).GetLocation(), ((object)(*(SyntaxToken*)(&refKeyword))/*cast due to constrained. prefix*/).ToString());
}
}
return BindNamespaceOrTypeOrAliasSymbol(refTypeSyntax.Type, diagnostics, basesBeingResolved, suppressUseSiteDiagnostics);
}
case SyntaxKind.ScopedType:
{
ScopedTypeSyntax scopedTypeSyntax = (ScopedTypeSyntax)syntax;
SyntaxToken scopedKeyword = scopedTypeSyntax.ScopedKeyword;
if (!((SyntaxNode)syntax).HasErrors)
{
diagnostics.Add(ErrorCode.ERR_UnexpectedToken, ((SyntaxToken)(ref scopedKeyword)).GetLocation(), ((object)(*(SyntaxToken*)(&scopedKeyword))/*cast due to constrained. prefix*/).ToString());
}
return BindNamespaceOrTypeOrAliasSymbol(scopedTypeSyntax.Type, diagnostics, basesBeingResolved, suppressUseSiteDiagnostics);
}
default:
return createErrorType();
}
NamespaceOrTypeOrAliasSymbolWithAnnotations bindAlias()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Invalid comparison between Unknown and I4
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
AliasQualifiedNameSyntax aliasQualifiedNameSyntax = (AliasQualifiedNameSyntax)syntax;
MessageID.IDS_FeatureGlobalNamespace.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)aliasQualifiedNameSyntax.Alias);
Symbol symbol = BindNamespaceAliasSymbol(aliasQualifiedNameSyntax.Alias, diagnostics);
NamespaceOrTypeSymbol namespaceOrTypeSymbol = ((symbol is AliasSymbol aliasSymbol) ? aliasSymbol.Target : ((NamespaceOrTypeSymbol)symbol));
if ((int)namespaceOrTypeSymbol.Kind == 11)
{
BindingDiagnosticBag bindingDiagnosticBag2 = diagnostics;
Location location = ((SyntaxNode)aliasQualifiedNameSyntax.Alias).Location;
object[] array = new object[1];
SyntaxToken identifier = aliasQualifiedNameSyntax.Alias.Identifier;
array[0] = ((SyntaxToken)(ref identifier)).Text;
return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(namespaceOrTypeSymbol, LookupResultKind.NotATypeOrNamespace, (DiagnosticInfo)(object)bindingDiagnosticBag2.Add(ErrorCode.ERR_ColColWithTypeAlias, location, array)));
}
return BindSimpleNamespaceOrTypeOrAliasSymbol(aliasQualifiedNameSyntax.Name, diagnostics, basesBeingResolved, suppressUseSiteDiagnostics, namespaceOrTypeSymbol);
}
NamespaceOrTypeOrAliasSymbolWithAnnotations bindNullable()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NullableTypeSyntax nullableTypeSyntax = (NullableTypeSyntax)syntax;
MessageID.IDS_FeatureNullable.CheckFeatureAvailability(diagnostics, nullableTypeSyntax.QuestionToken);
TypeSyntax elementType = nullableTypeSyntax.ElementType;
TypeWithAnnotations typeArgument = BindType(elementType, diagnostics, basesBeingResolved);
TypeWithAnnotations type = typeArgument.SetIsAnnotated(Compilation);
reportNullableReferenceTypesIfNeeded(nullableTypeSyntax.QuestionToken, typeArgument);
if (!ShouldCheckConstraints)
{
diagnostics.Add((DiagnosticInfo?)(object)new LazyUseSiteDiagnosticsInfoForNullableType(Compilation.LanguageVersion, type), syntax.GetLocation());
}
else if (type.IsNullableType())
{
ReportUseSite(type.Type.OriginalDefinition, diagnostics, (SyntaxNode)(object)syntax);
((NamedTypeSymbol)type.Type).CheckConstraints(new ConstraintsHelper.CheckConstraintsArgs(location: ((SyntaxNode)syntax).Location, currentCompilation: Compilation, conversions: Conversions, includeNullability: true, diagnostics: diagnostics));
}
else
{
CSDiagnosticInfo nullableUnconstrainedTypeParameterDiagnosticIfNecessary = GetNullableUnconstrainedTypeParameterDiagnosticIfNecessary(Compilation.LanguageVersion, in type);
if (nullableUnconstrainedTypeParameterDiagnosticIfNecessary != null)
{
diagnostics.Add((DiagnosticInfo?)(object)nullableUnconstrainedTypeParameterDiagnosticIfNecessary, ((SyntaxNode)syntax).Location);
}
}
return type;
}
NamespaceOrTypeOrAliasSymbolWithAnnotations bindPointer()
{
PointerTypeSyntax pointerTypeSyntax = (PointerTypeSyntax)syntax;
TypeWithAnnotations pointedAtType = BindType(pointerTypeSyntax.ElementType, diagnostics, basesBeingResolved);
ReportUnsafeIfNotAllowed((SyntaxNode)(object)pointerTypeSyntax, diagnostics);
if (!Flags.HasFlag(BinderFlags.SuppressConstraintChecks))
{
CheckManagedAddr(Compilation, pointedAtType.Type, ((SyntaxNode)pointerTypeSyntax).Location, diagnostics);
}
return TypeWithAnnotations.Create(new PointerTypeSymbol(pointedAtType));
}
NamespaceOrTypeOrAliasSymbolWithAnnotations bindPredefined()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
PredefinedTypeSyntax predefinedTypeSyntax = (PredefinedTypeSyntax)syntax;
NamedTypeSymbol typeSymbol = BindPredefinedTypeSymbol(predefinedTypeSyntax, diagnostics);
return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(predefinedTypeSyntax.Keyword), typeSymbol);
}
NamespaceOrTypeOrAliasSymbolWithAnnotations createErrorType()
{
diagnostics.Add(ErrorCode.ERR_TypeExpected, syntax.GetLocation());
return TypeWithAnnotations.Create(CreateErrorType());
}
void reportNullableReferenceTypesIfNeeded(SyntaxToken questionToken, TypeWithAnnotations typeArgument = default(TypeWithAnnotations))
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
DiagnosticBag diagnosticBag = ((BindingDiagnosticBag)diagnostics).DiagnosticBag;
if (diagnosticBag != null)
{
if (typeArgument.HasType && !ShouldCheckConstraints)
{
LazyMissingNonNullTypesContextDiagnosticInfo.AddAll(this, questionToken, typeArgument, diagnosticBag);
}
else if (LazyMissingNonNullTypesContextDiagnosticInfo.IsNullableReference(typeArgument.Type))
{
LazyMissingNonNullTypesContextDiagnosticInfo.AddAll(this, questionToken, null, diagnosticBag);
}
}
}
}
internal static CSDiagnosticInfo? GetNullableUnconstrainedTypeParameterDiagnosticIfNecessary(LanguageVersion languageVersion, in TypeWithAnnotations type)
{
if (type.Type.IsTypeParameterDisallowingAnnotationInCSharp8())
{
LanguageVersion languageVersion2 = MessageID.IDS_FeatureDefaultTypeParameterConstraint.RequiredVersion();
if (languageVersion2 > languageVersion)
{
return new CSDiagnosticInfo(ErrorCode.ERR_NullableUnconstrainedTypeParameter, new CSharpRequiredLanguageVersion(languageVersion2));
}
}
return null;
}
private TypeWithAnnotations BindArrayType(ArrayTypeSyntax node, BindingDiagnosticBag diagnostics, bool permitDimensions, ConsList<TypeSymbol> basesBeingResolved, bool disallowRestrictedTypes)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
TypeWithAnnotations typeWithAnnotations = BindType(node.ElementType, diagnostics, basesBeingResolved);
if (typeWithAnnotations.IsStatic)
{
Error(diagnostics, ErrorCode.ERR_ArrayOfStaticClass, (CSharpSyntaxNode)node.ElementType, new object[1] { typeWithAnnotations.Type });
}
if (disallowRestrictedTypes)
{
if (ShouldCheckConstraints)
{
if (typeWithAnnotations.IsRestrictedType())
{
Error(diagnostics, ErrorCode.ERR_ArrayElementCantBeRefAny, (CSharpSyntaxNode)node.ElementType, new object[1] { typeWithAnnotations.Type });
}
}
else
{
diagnostics.Add((DiagnosticInfo?)(object)new LazyArrayElementCantBeRefAnyDiagnosticInfo(typeWithAnnotations), node.ElementType.GetLocation());
}
}
for (int num = node.RankSpecifiers.Count - 1; num >= 0; num--)
{
ArrayRankSpecifierSyntax arrayRankSpecifierSyntax = node.RankSpecifiers[num];
SeparatedSyntaxList<ExpressionSyntax> sizes = arrayRankSpecifierSyntax.Sizes;
if (!permitDimensions && sizes.Count != 0 && sizes[0].Kind() != SyntaxKind.OmittedArraySizeExpression)
{
Error(diagnostics, ErrorCode.ERR_ArraySizeInDeclaration, (CSharpSyntaxNode)arrayRankSpecifierSyntax);
}
ArrayTypeSymbol typeSymbol = ArrayTypeSymbol.CreateCSharpArray(Compilation.Assembly, typeWithAnnotations, arrayRankSpecifierSyntax.Rank);
typeWithAnnotations = TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(arrayRankSpecifierSyntax.CloseBracketToken), typeSymbol);
}
return typeWithAnnotations;
}
private TypeSymbol BindTupleType(TupleTypeSyntax syntax, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureTuples.CheckFeatureAvailability(diagnostics, (SyntaxNode)(object)syntax);
int count = syntax.Elements.Count;
ArrayBuilder<TypeWithAnnotations> instance = ArrayBuilder<TypeWithAnnotations>.GetInstance(count);
ArrayBuilder<Location> instance2 = ArrayBuilder<Location>.GetInstance(count);
ArrayBuilder<string> elementNames = null;
PooledHashSet<string> instance3 = PooledHashSet<string>.GetInstance();
bool flag = false;
for (int i = 0; i < count; i++)
{
TupleElementSyntax tupleElementSyntax = syntax.Elements[i];
TypeWithAnnotations typeWithAnnotations = BindType(tupleElementSyntax.Type, diagnostics, basesBeingResolved);
instance.Add(typeWithAnnotations);
string name = null;
SyntaxToken identifier = tupleElementSyntax.Identifier;
if (identifier.Kind() == SyntaxKind.IdentifierToken)
{
name = ((SyntaxToken)(ref identifier)).ValueText;
flag = true;
CheckTupleMemberName(name, i, SyntaxNodeOrToken.op_Implicit(identifier), diagnostics, instance3);
instance2.Add(((SyntaxToken)(ref identifier)).GetLocation());
}
else
{
instance2.Add(((SyntaxNode)tupleElementSyntax).Location);
}
CollectTupleFieldMemberName(name, i, count, ref elementNames);
}
instance3.Free();
if (flag)
{
ReportMissingTupleElementNamesAttributesIfNeeded(Compilation, syntax.GetLocation(), diagnostics);
}
ImmutableArray<TypeWithAnnotations> elementTypesWithAnnotations = instance.ToImmutableAndFree();
ImmutableArray<Location> elementLocations = instance2.ToImmutableAndFree();
if (elementTypesWithAnnotations.Length < 2)
{
throw ExceptionUtilities.UnexpectedValue((object)elementTypesWithAnnotations.Length);
}
bool flag2 = Compilation.IsFeatureEnabled(MessageID.IDS_FeatureNullableReferenceTypes);
return NamedTypeSymbol.CreateTuple(((SyntaxNode)syntax).Location, elementTypesWithAnnotations, elementLocations, elementNames?.ToImmutableAndFree() ?? default(ImmutableArray<string>), Compilation, ShouldCheckConstraints, ShouldCheckConstraints && flag2, default(ImmutableArray<bool>), syntax, diagnostics);
}
internal static void ReportMissingTupleElementNamesAttributesIfNeeded(CSharpCompilation compilation, Location location, BindingDiagnosticBag diagnostics)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(diagnostics);
if (!compilation.HasTupleNamesAttributes(instance, location))
{
object[] array = new object[1];
AttributeDescription tupleElementNamesAttribute = AttributeDescription.TupleElementNamesAttribute;
array[0] = ((AttributeDescription)(ref tupleElementNamesAttribute)).FullName;
CSDiagnosticInfo info = new CSDiagnosticInfo(ErrorCode.ERR_TupleElementNamesAttributeMissing, array);
Error(diagnostics, (DiagnosticInfo)(object)info, location);
}
else
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
}
private static void CollectTupleFieldMemberName(string name, int elementIndex, int tupleSize, ref ArrayBuilder<string> elementNames)
{
if (elementNames != null)
{
elementNames.Add(name);
}
else if (name != null)
{
elementNames = ArrayBuilder<string>.GetInstance(tupleSize);
for (int i = 0; i < elementIndex; i++)
{
elementNames.Add((string)null);
}
elementNames.Add(name);
}
}
private static bool CheckTupleMemberName(string name, int index, SyntaxNodeOrToken syntax, BindingDiagnosticBag diagnostics, PooledHashSet<string> uniqueFieldNames)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
int num = NamedTypeSymbol.IsTupleElementNameReserved(name);
if (num == 0)
{
Error(diagnostics, ErrorCode.ERR_TupleReservedElementNameAnyPosition, syntax, name);
return false;
}
if (num > 0 && num != index + 1)
{
Error(diagnostics, ErrorCode.ERR_TupleReservedElementName, syntax, name, num);
return false;
}
if (!((HashSet<string>)(object)uniqueFieldNames).Add(name))
{
Error(diagnostics, ErrorCode.ERR_TupleDuplicateElementName, syntax);
return false;
}
return true;
}
private NamedTypeSymbol BindPredefinedTypeSymbol(PredefinedTypeSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
return GetSpecialType(node.Keyword.Kind().GetSpecialType(), diagnostics, (SyntaxNode)(object)node);
}
private NamespaceOrTypeOrAliasSymbolWithAnnotations BindSimpleNamespaceOrTypeOrAliasSymbol(SimpleNameSyntax syntax, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved, bool suppressUseSiteDiagnostics, NamespaceOrTypeSymbol qualifierOpt = null)
{
return syntax.Kind() switch
{
SyntaxKind.IdentifierName => BindNonGenericSimpleNamespaceOrTypeOrAliasSymbol((IdentifierNameSyntax)syntax, diagnostics, basesBeingResolved, suppressUseSiteDiagnostics, qualifierOpt),
SyntaxKind.GenericName => BindGenericSimpleNamespaceOrTypeOrAliasSymbol((GenericNameSyntax)syntax, diagnostics, basesBeingResolved, qualifierOpt),
_ => TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(qualifierOpt ?? Compilation.Assembly.GlobalNamespace, string.Empty, 0, null)),
};
}
protected NamespaceOrTypeOrAliasSymbolWithAnnotations BindNonGenericSimpleNamespaceOrTypeOrAliasSymbol(IdentifierNameSyntax node, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved, bool suppressUseSiteDiagnostics, NamespaceOrTypeSymbol qualifierOpt)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken identifier = node.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
if (string.IsNullOrWhiteSpace(valueText))
{
return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(Compilation.Assembly.GlobalNamespace, valueText, 0, (DiagnosticInfo?)(object)new CSDiagnosticInfo(ErrorCode.ERR_SingleTypeNameNotFound, valueText)));
}
ExtendedErrorTypeSymbol extendedErrorTypeSymbol = CreateErrorIfLookupOnTypeParameter(node.Parent, qualifierOpt, valueText, 0, diagnostics);
if ((object)extendedErrorTypeSymbol != null)
{
return TypeWithAnnotations.Create(extendedErrorTypeSymbol);
}
LookupResult instance = LookupResult.GetInstance();
LookupOptions simpleNameLookupOptions = GetSimpleNameLookupOptions(node, node.Identifier.IsVerbatimIdentifier());
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupSymbolsSimpleName(instance, qualifierOpt, valueText, 0, basesBeingResolved, simpleNameLookupOptions, diagnose: true, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
Symbol symbol = null;
if ((object)qualifierOpt == null && !isViableType(instance))
{
identifier = node.Identifier;
if (((SyntaxToken)(ref identifier)).ValueText == "dynamic")
{
if (dynamicAllowed())
{
symbol = Compilation.DynamicType;
ReportUseSiteDiagnosticForDynamic(diagnostics, node);
}
}
else if (!isViableNamespace(instance))
{
symbol = BindNativeIntegerSymbolIfAny(node, diagnostics);
}
}
if ((object)symbol == null)
{
symbol = ResultSymbol(instance, valueText, 0, (SyntaxNode)(object)node, diagnostics, suppressUseSiteDiagnostics, out var _, qualifierOpt, simpleNameLookupOptions);
if ((int)symbol.Kind == 0 && ((AliasSymbol)symbol).GetAliasTarget(basesBeingResolved) is TypeSymbol type)
{
if (type.ContainsDynamic())
{
ReportUseSiteDiagnosticForDynamic(diagnostics, node);
}
if (type.ContainsPointer())
{
ReportUnsafeIfNotAllowed((SyntaxNode)(object)node, diagnostics);
}
}
}
instance.Free();
return NamespaceOrTypeOrAliasSymbolWithAnnotations.CreateUnannotated(AreNullableAnnotationsEnabled(node.Identifier), symbol);
bool dynamicAllowed()
{
if (Compilation.LanguageVersion < MessageID.IDS_FeatureDynamic.RequiredVersion())
{
return false;
}
if (node.Parent == null)
{
return true;
}
if (node.Parent.Kind() == SyntaxKind.Attribute)
{
return false;
}
if (SyntaxFacts.IsInTypeOnlyContext(node))
{
return true;
}
if (node.Parent is UsingDirectiveSyntax { Alias: not null })
{
return true;
}
return false;
}
static bool isViableNamespace(LookupResult result)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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)
//IL_0026: Invalid comparison between Unknown and I4
if (!result.IsMultiViable)
{
return false;
}
Enumerator<Symbol> enumerator = result.Symbols.GetEnumerator();
while (enumerator.MoveNext())
{
if ((int)enumerator.Current.Kind == 12)
{
return true;
}
}
return false;
}
static bool isViableType(LookupResult result)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Invalid comparison between Unknown and I4
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Invalid comparison between Unknown and I4
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Invalid comparison between Unknown and I4
if (!result.IsMultiViable)
{
return false;
}
Enumerator<Symbol> enumerator = result.Symbols.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
SymbolKind kind = current.Kind;
if ((int)kind != 0)
{
if ((int)kind == 11 || (int)kind == 17)
{
return true;
}
}
else if ((int)((AliasSymbol)current).Target.Kind == 11)
{
return true;
}
}
return false;
}
}
private NamedTypeSymbol BindNativeIntegerSymbolIfAny(IdentifierNameSyntax node, BindingDiagnosticBag diagnostics)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
SpecialType val = (SpecialType)(node.IsNint ? 21 : (node.IsNuint ? 22 : 0));
if ((int)val == 0)
{
return null;
}
CSharpSyntaxNode parent = node.Parent;
if (!(parent is AttributeSyntax attributeSyntax))
{
if (!(parent is UsingDirectiveSyntax usingDirectiveSyntax))
{
if (parent is ArgumentSyntax argumentSyntax && IsInsideNameof && argumentSyntax.Parent?.Parent is InvocationExpressionSyntax invocationExpressionSyntax)
{
IdentifierNameSyntax obj = invocationExpressionSyntax.Expression as IdentifierNameSyntax;
if (obj != null && obj.Identifier.ContextualKind() == SyntaxKind.NameOfKeyword)
{
return null;
}
}
}
else if (usingDirectiveSyntax.Alias == null || usingDirectiveSyntax.NamespaceOrType != node)
{
return null;
}
}
else if (attributeSyntax.Name == node)
{
return null;
}
CheckFeatureAvailability((SyntaxNode)(object)node, MessageID.IDS_FeatureNativeInt, diagnostics);
return GetSpecialType(val, diagnostics, (SyntaxNode)(object)node).AsNativeInteger();
}
private void ReportUseSiteDiagnosticForDynamic(BindingDiagnosticBag diagnostics, IdentifierNameSyntax node)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
if (node.IsTypeInContextWhichNeedsDynamicAttribute())
{
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(diagnostics);
if (!Compilation.HasDynamicEmitAttributes(instance, ((SyntaxNode)node).Location))
{
object[] array = new object[1];
AttributeDescription dynamicAttribute = AttributeDescription.DynamicAttribute;
array[0] = ((AttributeDescription)(ref dynamicAttribute)).FullName;
Symbol.ReportUseSiteDiagnostic((DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_DynamicAttributeMissing, array), diagnostics, ((SyntaxNode)node).Location);
}
else
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
GetSpecialType((SpecialType)7, diagnostics, (SyntaxNode)(object)node);
}
}
private static LookupOptions GetSimpleNameLookupOptions(NameSyntax node, bool isVerbatimIdentifier)
{
if (SyntaxFacts.IsAttributeName((SyntaxNode)(object)node))
{
if (!isVerbatimIdentifier)
{
return LookupOptions.AttributeTypeOnly;
}
return LookupOptions.VerbatimNameAttributeTypeOnly;
}
return LookupOptions.NamespacesOrTypesOnly;
}
private static Symbol UnwrapAliasNoDiagnostics(Symbol symbol, ConsList<TypeSymbol> basesBeingResolved = null)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if ((int)symbol.Kind == 0)
{
return ((AliasSymbol)symbol).GetAliasTarget(basesBeingResolved);
}
return symbol;
}
private NamespaceOrTypeOrAliasSymbolWithAnnotations UnwrapAlias(in NamespaceOrTypeOrAliasSymbolWithAnnotations symbol, BindingDiagnosticBag diagnostics, SyntaxNode syntax, ConsList<TypeSymbol> basesBeingResolved = null)
{
AliasSymbol alias;
if (symbol.IsAlias)
{
return NamespaceOrTypeOrAliasSymbolWithAnnotations.CreateUnannotated(symbol.IsNullableEnabled, (NamespaceOrTypeSymbol)UnwrapAlias(symbol.Symbol, out alias, diagnostics, syntax, basesBeingResolved));
}
return symbol;
}
private NamespaceOrTypeOrAliasSymbolWithAnnotations UnwrapAlias(in NamespaceOrTypeOrAliasSymbolWithAnnotations symbol, out AliasSymbol alias, BindingDiagnosticBag diagnostics, SyntaxNode syntax, ConsList<TypeSymbol> basesBeingResolved = null)
{
if (symbol.IsAlias)
{
return NamespaceOrTypeOrAliasSymbolWithAnnotations.CreateUnannotated(symbol.IsNullableEnabled, (NamespaceOrTypeSymbol)UnwrapAlias(symbol.Symbol, out alias, diagnostics, syntax, basesBeingResolved));
}
alias = null;
return symbol;
}
private Symbol UnwrapAlias(Symbol symbol, BindingDiagnosticBag diagnostics, SyntaxNode syntax, ConsList<TypeSymbol> basesBeingResolved = null)
{
AliasSymbol alias;
return UnwrapAlias(symbol, out alias, diagnostics, syntax, basesBeingResolved);
}
private Symbol UnwrapAlias(Symbol symbol, out AliasSymbol alias, BindingDiagnosticBag diagnostics, SyntaxNode syntax, ConsList<TypeSymbol> basesBeingResolved = null)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if ((int)symbol.Kind == 0)
{
alias = (AliasSymbol)symbol;
NamespaceOrTypeSymbol aliasTarget = alias.GetAliasTarget(basesBeingResolved);
if (aliasTarget is TypeSymbol type)
{
TypeSymbolExtensions.VisitType(arg: (this, diagnostics, syntax), type: type, predicate: delegate(TypeSymbol typePart, (Binder, BindingDiagnosticBag diagnostics, SyntaxNode syntax) argTuple, bool isNested)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
argTuple.Item1.ReportDiagnosticsIfObsolete(argTuple.diagnostics, typePart, SyntaxNodeOrToken.op_Implicit(argTuple.syntax), hasBaseReceiver: false);
return false;
});
}
return aliasTarget;
}
alias = null;
return symbol;
}
private TypeWithAnnotations BindGenericSimpleNamespaceOrTypeOrAliasSymbol(GenericNameSyntax node, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved, NamespaceOrTypeSymbol qualifierOpt)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
SyntaxToken identifier = node.Identifier;
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
SeparatedSyntaxList<TypeSyntax> arguments = node.TypeArgumentList.Arguments;
bool isUnboundGenericName = node.IsUnboundGenericName;
NamedTypeSymbol namedTypeSymbol = LookupGenericTypeName(options: GetSimpleNameLookupOptions(node, isVerbatimIdentifier: false), diagnostics: diagnostics, basesBeingResolved: basesBeingResolved, qualifierOpt: qualifierOpt, node: node, plainName: valueText, arity: node.Arity);
NamedTypeSymbol typeSymbol;
if (isUnboundGenericName)
{
if (!IsUnboundTypeAllowed(node))
{
if (!namedTypeSymbol.IsErrorType())
{
diagnostics.Add(ErrorCode.ERR_UnexpectedUnboundGenericName, ((SyntaxNode)node).Location);
}
typeSymbol = namedTypeSymbol.Construct(UnboundArgumentErrorTypeSymbol.CreateTypeArguments(namedTypeSymbol.TypeParameters, node.Arity, null), unbound: false);
}
else
{
typeSymbol = namedTypeSymbol.AsUnboundGenericType();
}
}
else if ((Flags & BinderFlags.SuppressTypeArgumentBinding) != BinderFlags.None)
{
typeSymbol = namedTypeSymbol.Construct(PlaceholderTypeArgumentSymbol.CreateTypeArguments(namedTypeSymbol.TypeParameters));
}
else
{
ImmutableArray<TypeWithAnnotations> typeArguments = BindTypeArguments(arguments, diagnostics, basesBeingResolved);
typeSymbol = ConstructNamedType(namedTypeSymbol, (SyntaxNode)(object)node, arguments, typeArguments, basesBeingResolved, diagnostics);
}
return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(node.TypeArgumentList.GreaterThanToken), typeSymbol);
}
private NamedTypeSymbol LookupGenericTypeName(BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved, NamespaceOrTypeSymbol qualifierOpt, GenericNameSyntax node, string plainName, int arity, LookupOptions options)
{
//IL_0021: 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)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
ExtendedErrorTypeSymbol extendedErrorTypeSymbol = CreateErrorIfLookupOnTypeParameter(node.Parent, qualifierOpt, plainName, arity, diagnostics);
if ((object)extendedErrorTypeSymbol != null)
{
return extendedErrorTypeSymbol;
}
LookupResult instance = LookupResult.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupSymbolsSimpleName(instance, qualifierOpt, plainName, arity, basesBeingResolved, options, diagnose: true, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
bool wasError;
Symbol symbol = ResultSymbol(instance, plainName, arity, (SyntaxNode)(object)node, diagnostics, basesBeingResolved != null, out wasError, qualifierOpt, options);
NamedTypeSymbol namedTypeSymbol = symbol as NamedTypeSymbol;
if ((object)namedTypeSymbol == null)
{
namedTypeSymbol = new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(symbol), ImmutableArray.Create(symbol), instance.Kind, instance.Error, arity);
}
instance.Free();
return namedTypeSymbol;
}
private ExtendedErrorTypeSymbol CreateErrorIfLookupOnTypeParameter(CSharpSyntaxNode node, NamespaceOrTypeSymbol qualifierOpt, string name, int arity, BindingDiagnosticBag diagnostics)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
if ((object)qualifierOpt != null && (int)qualifierOpt.Kind == 17)
{
CSDiagnosticInfo cSDiagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_LookupInTypeVariable, qualifierOpt);
diagnostics.Add((DiagnosticInfo?)(object)cSDiagnosticInfo, ((SyntaxNode)node).Location);
return new ExtendedErrorTypeSymbol(Compilation, name, arity, (DiagnosticInfo?)(object)cSDiagnosticInfo);
}
return null;
}
private ImmutableArray<TypeWithAnnotations> BindTypeArguments(SeparatedSyntaxList<TypeSyntax> typeArguments, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
ArrayBuilder<TypeWithAnnotations> instance = ArrayBuilder<TypeWithAnnotations>.GetInstance(typeArguments.Count);
Enumerator<TypeSyntax> enumerator = typeArguments.GetEnumerator();
while (enumerator.MoveNext())
{
TypeSyntax current = enumerator.Current;
instance.Add(BindTypeArgument(current, diagnostics, basesBeingResolved));
}
return instance.ToImmutableAndFree();
}
private TypeWithAnnotations BindTypeArgument(TypeSyntax typeArgument, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null)
{
Binder binder = ((!Compilation.IsFeatureEnabled(MessageID.IDS_FeatureUsingTypeAlias)) ? WithAdditionalFlags(BinderFlags.SuppressUnsafeDiagnostics) : this);
if (typeArgument.Kind() != SyntaxKind.OmittedTypeArgument)
{
return binder.BindType(typeArgument, diagnostics, basesBeingResolved);
}
return TypeWithAnnotations.Create(UnboundArgumentErrorTypeSymbol.Instance);
}
private NamedTypeSymbol ConstructNamedTypeUnlessTypeArgumentOmitted(SyntaxNode typeSyntax, NamedTypeSymbol type, SeparatedSyntaxList<TypeSyntax> typeArgumentsSyntax, ImmutableArray<TypeWithAnnotations> typeArguments, BindingDiagnosticBag diagnostics)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (typeArgumentsSyntax.Any<TypeSyntax>(SyntaxKind.OmittedTypeArgument))
{
Error(diagnostics, ErrorCode.ERR_BadArity, SyntaxNodeOrToken.op_Implicit(typeSyntax), type, MessageID.IDS_SK_TYPE.Localize(), typeArgumentsSyntax.Count);
return type;
}
return ConstructNamedType(type, typeSyntax, typeArgumentsSyntax, typeArguments, null, diagnostics);
}
private BoundMethodOrPropertyGroup ConstructBoundMemberGroupAndReportOmittedTypeArguments(SyntaxNode syntax, SeparatedSyntaxList<TypeSyntax> typeArgumentsSyntax, ImmutableArray<TypeWithAnnotations> typeArguments, BoundExpression receiver, string plainName, ArrayBuilder<Symbol> members, LookupResult lookupResult, BoundMethodGroupFlags methodGroupFlags, bool hasErrors, BindingDiagnosticBag diagnostics)
{
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Invalid comparison between Unknown and I4
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Invalid comparison between Unknown and I4
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
if (!hasErrors && lookupResult.IsMultiViable && typeArgumentsSyntax.Any<TypeSyntax>(SyntaxKind.OmittedTypeArgument))
{
Error(diagnostics, ErrorCode.ERR_BadArity, SyntaxNodeOrToken.op_Implicit(syntax), plainName, MessageID.IDS_MethodGroup.Localize(), typeArgumentsSyntax.Count);
hasErrors = true;
}
BoundExpression valueExpressionIfTypeOrValueReceiver = GetValueExpressionIfTypeOrValueReceiver(receiver);
if (IsPossiblyCapturingPrimaryConstructorParameterReference(valueExpressionIfTypeOrValueReceiver, out var parameterSymbol))
{
LookupResult lookupResult2 = null;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
CheckWhatCandidatesWeHave(members, parameterSymbol.Type, plainName, (!typeArguments.IsDefault) ? typeArguments.Length : 0, ref lookupResult2, ref useSiteInfo, out var haveInstanceCandidates, out var haveStaticCandidates);
lookupResult2?.Free();
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(valueExpressionIfTypeOrValueReceiver.Syntax, useSiteInfo);
if (haveInstanceCandidates)
{
BindingDiagnosticBag bindingDiagnosticBag = null;
if (haveStaticCandidates)
{
Error(diagnostics, ErrorCode.ERR_AmbiguousPrimaryConstructorParameterAsColorColorReceiver, SyntaxNodeOrToken.op_Implicit(valueExpressionIfTypeOrValueReceiver.Syntax), parameterSymbol.Name, parameterSymbol.Type, parameterSymbol);
bindingDiagnosticBag = BindingDiagnosticBag.GetInstance(diagnostics);
}
receiver = ReplaceTypeOrValueReceiver(receiver, useType: false, bindingDiagnosticBag ?? diagnostics);
((BindingDiagnosticBag<AssemblySymbol>)(object)bindingDiagnosticBag)?.Free();
if (haveStaticCandidates)
{
receiver = new BoundBadExpression(receiver.Syntax, LookupResultKind.Ambiguous, ImmutableArray<Symbol>.Empty, ImmutableArray.Create(receiver), receiver.Type, hasErrors: true).MakeCompilerGenerated();
}
}
else
{
receiver = ReplaceTypeOrValueReceiver(receiver, useType: true, diagnostics);
}
}
SymbolKind kind = members[0].Kind;
if ((int)kind != 9)
{
if ((int)kind == 15)
{
return new BoundPropertyGroup(syntax, ArrayBuilderExtensions.SelectAsArray<Symbol, PropertySymbol>(members, s_toPropertySymbolFunc), receiver, lookupResult.Kind, hasErrors);
}
throw ExceptionUtilities.UnexpectedValue((object)members[0].Kind);
}
return new BoundMethodGroup(syntax, typeArguments, receiver, plainName, ArrayBuilderExtensions.SelectAsArray<Symbol, MethodSymbol>(members, s_toMethodSymbolFunc), lookupResult, methodGroupFlags, this, hasErrors);
}
private bool IsPossiblyCapturingPrimaryConstructorParameterReference(BoundExpression colorColorValueReceiver, out ParameterSymbol parameterSymbol)
{
if (colorColorValueReceiver is BoundParameter boundParameter)
{
ParameterSymbol parameterSymbol2 = boundParameter.ParameterSymbol;
if ((object)parameterSymbol2 != null && parameterSymbol2.ContainingSymbol is SynthesizedPrimaryConstructor synthesizedPrimaryConstructor && IsInDeclaringTypeInstanceMember(synthesizedPrimaryConstructor) && !InFieldInitializer && (object)ContainingMember() != synthesizedPrimaryConstructor && !IsInsideNameof)
{
parameterSymbol = parameterSymbol2;
return true;
}
}
parameterSymbol = null;
return false;
}
private void CheckWhatCandidatesWeHave(ArrayBuilder<Symbol> members, TypeSymbol receiverType, string plainName, int arity, ref LookupResult lookupResult, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out bool haveInstanceCandidates, out bool haveStaticCandidates)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Invalid comparison between Unknown and I4
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
haveInstanceCandidates = ArrayBuilderExtensions.Any<Symbol>(members, (Func<Symbol, bool>)((Symbol m) => !m.IsStatic));
haveStaticCandidates = ArrayBuilderExtensions.Any<Symbol>(members, (Func<Symbol, bool>)((Symbol m) => m.IsStatic));
if (haveInstanceCandidates || (int)members[0].Kind != 9)
{
return;
}
ExtensionMethodScopeEnumerator enumerator = new ExtensionMethodScopes(this).GetEnumerator();
while (enumerator.MoveNext())
{
ExtensionMethodScope current = enumerator.Current;
if (lookupResult == null)
{
lookupResult = LookupResult.GetInstance();
}
LookupExtensionMethods(lookupResult, current, plainName, arity, ref useSiteInfo);
if (lookupResult.IsMultiViable)
{
Enumerator<Symbol> enumerator2 = lookupResult.Symbols.GetEnumerator();
while (enumerator2.MoveNext())
{
if ((object)((MethodSymbol)enumerator2.Current).ReduceExtensionMethod(receiverType, Compilation) != null)
{
haveInstanceCandidates = true;
break;
}
}
}
lookupResult.Clear();
if (haveInstanceCandidates)
{
break;
}
}
}
private NamedTypeSymbol ConstructNamedType(NamedTypeSymbol type, SyntaxNode typeSyntax, SeparatedSyntaxList<TypeSyntax> typeArgumentsSyntax, ImmutableArray<TypeWithAnnotations> typeArguments, ConsList<TypeSymbol> basesBeingResolved, BindingDiagnosticBag diagnostics)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
type = type.Construct(typeArguments);
if (ShouldCheckConstraints && ConstraintsHelper.RequiresChecking(type))
{
bool includeNullability = Compilation.IsFeatureEnabled(MessageID.IDS_FeatureNullableReferenceTypes);
type.CheckConstraintsForNamedType(new ConstraintsHelper.CheckConstraintsArgs(Compilation, Conversions, includeNullability, typeSyntax.Location, diagnostics), typeSyntax, typeArgumentsSyntax, basesBeingResolved);
}
return type;
}
private NamespaceOrTypeOrAliasSymbolWithAnnotations BindQualifiedName(ExpressionSyntax leftName, SimpleNameSyntax rightName, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved, bool suppressUseSiteDiagnostics)
{
//IL_0018: 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_002b: Invalid comparison between Unknown and I4
NamespaceOrTypeSymbol namespaceOrTypeSymbol = BindNamespaceOrTypeSymbol(leftName, diagnostics, basesBeingResolved, suppressUseSiteDiagnostics: false).NamespaceOrTypeSymbol;
ReportDiagnosticsIfObsolete(diagnostics, namespaceOrTypeSymbol, SyntaxNodeOrToken.op_Implicit((SyntaxNode)(object)leftName), hasBaseReceiver: false);
int num;
if ((int)namespaceOrTypeSymbol.Kind == 11)
{
num = (((NamedTypeSymbol)namespaceOrTypeSymbol).IsUnboundGenericType ? 1 : 0);
if (num != 0)
{
namespaceOrTypeSymbol = ((NamedTypeSymbol)namespaceOrTypeSymbol).OriginalDefinition;
}
}
else
{
num = 0;
}
NamespaceOrTypeOrAliasSymbolWithAnnotations right = BindSimpleNamespaceOrTypeOrAliasSymbol(rightName, diagnostics, basesBeingResolved, suppressUseSiteDiagnostics, namespaceOrTypeSymbol);
if (num != 0)
{
return convertToUnboundGenericType();
}
return right;
NamespaceOrTypeOrAliasSymbolWithAnnotations convertToUnboundGenericType()
{
if (right.Symbol is NamedTypeSymbol { IsGenericType: not false } namedTypeSymbol)
{
TypeWithAnnotations typeWithAnnotations = right.TypeWithAnnotations;
return typeWithAnnotations.WithTypeAndModifiers(namedTypeSymbol.AsUnboundGenericType(), typeWithAnnotations.CustomModifiers);
}
return right;
}
}
internal NamedTypeSymbol GetSpecialType(SpecialType typeId, BindingDiagnosticBag diagnostics, SyntaxNode node)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return GetSpecialType(Compilation, typeId, node, diagnostics);
}
internal static NamedTypeSymbol GetSpecialType(CSharpCompilation compilation, SpecialType typeId, SyntaxNode node, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol specialType = compilation.GetSpecialType(typeId);
ReportUseSite(specialType, diagnostics, node);
return specialType;
}
internal static NamedTypeSymbol GetSpecialType(CSharpCompilation compilation, SpecialType typeId, Location location, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol specialType = compilation.GetSpecialType(typeId);
ReportUseSite(specialType, diagnostics, location);
return specialType;
}
internal Symbol GetSpecialTypeMember(SpecialMember member, BindingDiagnosticBag diagnostics, SyntaxNode syntax)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (!TryGetSpecialTypeMember<Symbol>(Compilation, member, syntax, diagnostics, out var symbol))
{
return null;
}
return symbol;
}
internal static bool TryGetSpecialTypeMember<TSymbol>(CSharpCompilation compilation, SpecialMember specialMember, SyntaxNode syntax, BindingDiagnosticBag diagnostics, out TSymbol symbol) where TSymbol : Symbol
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Expected O, but got Unknown
symbol = (TSymbol)compilation.GetSpecialTypeMember(specialMember);
if ((object)symbol == null)
{
MemberDescriptor descriptor = SpecialMembers.GetDescriptor(specialMember);
diagnostics.Add(ErrorCode.ERR_MissingPredefinedMember, syntax.Location, ((MemberDescriptor)(ref descriptor)).DeclaringTypeMetadataName, descriptor.Name);
return false;
}
UseSiteInfo<AssemblySymbol> useSiteInfoForWellKnownMemberOrContainingType = GetUseSiteInfoForWellKnownMemberOrContainingType(symbol);
if (useSiteInfoForWellKnownMemberOrContainingType.DiagnosticInfo != null)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).ReportUseSiteDiagnostic(useSiteInfoForWellKnownMemberOrContainingType.DiagnosticInfo, (Location)new SourceLocation(syntax));
}
return true;
}
private static UseSiteInfo<AssemblySymbol> GetUseSiteInfoForWellKnownMemberOrContainingType(Symbol symbol)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
UseSiteInfo<AssemblySymbol> result = symbol.GetUseSiteInfo();
symbol.MergeUseSiteInfo(ref result, symbol.ContainingType.GetUseSiteInfo());
return result;
}
internal static bool ReportUseSite(Symbol symbol, BindingDiagnosticBag diagnostics, SyntaxNode node)
{
return diagnostics.ReportUseSite(symbol, node);
}
internal static bool ReportUseSite(Symbol symbol, BindingDiagnosticBag diagnostics, SyntaxToken token)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return diagnostics.ReportUseSite(symbol, token);
}
internal static bool ReportUseSite(Symbol symbol, BindingDiagnosticBag diagnostics, Location location)
{
return diagnostics.ReportUseSite(symbol, location);
}
internal NamedTypeSymbol GetWellKnownType(WellKnownType type, BindingDiagnosticBag diagnostics, SyntaxNode node)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return GetWellKnownType(type, diagnostics, node.Location);
}
internal NamedTypeSymbol GetWellKnownType(WellKnownType type, BindingDiagnosticBag diagnostics, Location location)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return GetWellKnownType(Compilation, type, diagnostics, location);
}
internal static NamedTypeSymbol GetWellKnownType(CSharpCompilation compilation, WellKnownType type, BindingDiagnosticBag diagnostics, SyntaxNode node)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return GetWellKnownType(compilation, type, diagnostics, node.Location);
}
internal static NamedTypeSymbol GetWellKnownType(CSharpCompilation compilation, WellKnownType type, BindingDiagnosticBag diagnostics, Location location)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol wellKnownType = compilation.GetWellKnownType(type);
ReportUseSite(wellKnownType, diagnostics, location);
return wellKnownType;
}
internal NamedTypeSymbol GetWellKnownType(WellKnownType type, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
NamedTypeSymbol wellKnownType = Compilation.GetWellKnownType(type);
wellKnownType.AddUseSiteInfo(ref useSiteInfo);
return wellKnownType;
}
internal Symbol GetWellKnownTypeMember(WellKnownMember member, BindingDiagnosticBag diagnostics, Location location = null, SyntaxNode syntax = null, bool isOptional = false)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return GetWellKnownTypeMember(Compilation, member, diagnostics, location, syntax, isOptional);
}
internal static Symbol GetWellKnownTypeMember(CSharpCompilation compilation, WellKnownMember member, BindingDiagnosticBag diagnostics, Location location = null, SyntaxNode syntax = null, bool isOptional = false)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
UseSiteInfo<AssemblySymbol> useSiteInfo;
Symbol wellKnownTypeMember = GetWellKnownTypeMember(compilation, member, out useSiteInfo, isOptional);
if (syntax != null)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(useSiteInfo, syntax);
return wellKnownTypeMember;
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(useSiteInfo, location);
return wellKnownTypeMember;
}
internal static Symbol GetWellKnownTypeMember(CSharpCompilation compilation, WellKnownMember member, out UseSiteInfo<AssemblySymbol> useSiteInfo, bool isOptional = false)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
Symbol wellKnownTypeMember = compilation.GetWellKnownTypeMember(member);
if ((object)wellKnownTypeMember != null)
{
useSiteInfo = GetUseSiteInfoForWellKnownMemberOrContainingType(wellKnownTypeMember);
if (useSiteInfo.DiagnosticInfo != null && isOptional)
{
if ((int)useSiteInfo.DiagnosticInfo.Severity == 3)
{
useSiteInfo = default(UseSiteInfo<AssemblySymbol>);
return null;
}
useSiteInfo = new UseSiteInfo<AssemblySymbol>((DiagnosticInfo)null, useSiteInfo.PrimaryDependency, useSiteInfo.SecondaryDependencies);
}
}
else if (!isOptional)
{
MemberDescriptor descriptor = WellKnownMembers.GetDescriptor(member);
useSiteInfo = new UseSiteInfo<AssemblySymbol>((DiagnosticInfo)(object)new CSDiagnosticInfo(ErrorCode.ERR_MissingPredefinedMember, ((MemberDescriptor)(ref descriptor)).DeclaringTypeMetadataName, descriptor.Name));
}
else
{
useSiteInfo = default(UseSiteInfo<AssemblySymbol>);
}
return wellKnownTypeMember;
}
internal Symbol ResultSymbol(LookupResult result, string simpleName, int arity, SyntaxNode where, BindingDiagnosticBag diagnostics, bool suppressUseSiteDiagnostics, out bool wasError, NamespaceOrTypeSymbol qualifierOpt, LookupOptions options = LookupOptions.Default)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Invalid comparison between Unknown and I4
Symbol symbol = resultSymbol(result, simpleName, arity, where, diagnostics, suppressUseSiteDiagnostics, out wasError, qualifierOpt, options);
if ((int)symbol.Kind == 11)
{
CheckReceiverAndRuntimeSupportForSymbolAccess(where, null, symbol, diagnostics);
if (suppressUseSiteDiagnostics && ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).DependenciesBag != null)
{
AssemblySymbol containingAssembly = symbol.ContainingAssembly;
if ((object)containingAssembly != null && containingAssembly != Compilation.Assembly && containingAssembly != Compilation.Assembly.CorLibrary)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddDependency(containingAssembly);
}
}
}
return symbol;
Symbol resultSymbol(LookupResult lookupResult, string text, int arity2, SyntaxNode val, BindingDiagnosticBag bindingDiagnosticBag, bool flag2, out bool reference, NamespaceOrTypeSymbol namespaceOrTypeSymbol, LookupOptions options2)
{
//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
//IL_06fd: Invalid comparison between Unknown and I4
//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
//IL_06ab: Invalid comparison between Unknown and I4
//IL_0896: Unknown result type (might be due to invalid IL or missing references)
//IL_089c: Invalid comparison between Unknown and I4
//IL_07eb: Unknown result type (might be due to invalid IL or missing references)
//IL_07f0: Unknown result type (might be due to invalid IL or missing references)
//IL_074c: Unknown result type (might be due to invalid IL or missing references)
//IL_0752: Invalid comparison between Unknown and I4
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Invalid comparison between Unknown and I4
//IL_0544: Unknown result type (might be due to invalid IL or missing references)
//IL_054b: Invalid comparison between Unknown and I4
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Invalid comparison between Unknown and I4
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Invalid comparison between Unknown and I4
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Invalid comparison between Unknown and I4
//IL_0552: Unknown result type (might be due to invalid IL or missing references)
//IL_0559: Invalid comparison between Unknown and I4
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_0337: Invalid comparison between Unknown and I4
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Invalid comparison between Unknown and I4
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Invalid comparison between Unknown and I4
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Invalid comparison between Unknown and I4
//IL_0397: Unknown result type (might be due to invalid IL or missing references)
//IL_039e: Invalid comparison between Unknown and I4
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_0342: Invalid comparison between Unknown and I4
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Invalid comparison between Unknown and I4
//IL_061a: Unknown result type (might be due to invalid IL or missing references)
//IL_0620: Expected O, but got Unknown
//IL_0629: Unknown result type (might be due to invalid IL or missing references)
//IL_062f: Expected O, but got Unknown
//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
//IL_04c7: Invalid comparison between Unknown and I4
//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
//IL_03ac: Invalid comparison between Unknown and I4
//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
//IL_04d2: Invalid comparison between Unknown and I4
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Expected O, but got Unknown
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02c1: Expected O, but got Unknown
ArrayBuilder<Symbol> symbols = lookupResult.Symbols;
reference = false;
if (lookupResult.IsMultiViable)
{
if (symbols.Count > 1)
{
symbols.Sort((IComparer<Symbol>)ConsistentSymbolOrder.Instance);
ImmutableArray<Symbol> immutableArray = symbols.ToImmutable();
for (int i = 0; i < symbols.Count; i++)
{
symbols[i] = UnwrapAlias(symbols[i], bindingDiagnosticBag, val);
}
BestSymbolInfo secondBest;
BestSymbolInfo bestSymbolInfo = GetBestSymbolInfo(symbols, out secondBest);
if (bestSymbolInfo.IsFromCompilation && !secondBest.IsFromCompilation)
{
Symbol symbol2 = symbols[bestSymbolInfo.Index];
Symbol symbol3 = symbols[secondBest.Index];
object obj = ((!bestSymbolInfo.IsFromSourceModule) ? ((object)symbol2.ContainingModule) : ((object)symbol2.GetFirstLocation().SourceTree.FilePath));
if (NameAndArityMatchRecursively(symbol2, symbol3))
{
if ((int)symbol2.Kind == 12 && (int)symbol3.Kind == 11)
{
bindingDiagnosticBag.Add(ErrorCode.WRN_SameFullNameThisNsAgg, val.Location, immutableArray, obj, symbol2, symbol3.ContainingAssembly, symbol3);
return immutableArray[bestSymbolInfo.Index];
}
if ((int)symbol2.Kind == 11 && (int)symbol3.Kind == 12)
{
bindingDiagnosticBag.Add(ErrorCode.WRN_SameFullNameThisAggNs, val.Location, immutableArray, obj, symbol2, GetContainingAssembly(symbol3), symbol3);
return immutableArray[bestSymbolInfo.Index];
}
if ((int)symbol2.Kind == 11 && (int)symbol3.Kind == 11)
{
bindingDiagnosticBag.Add(ErrorCode.WRN_SameFullNameThisAggAgg, val.Location, immutableArray, obj, symbol2, symbol3.ContainingAssembly, symbol3);
return immutableArray[bestSymbolInfo.Index];
}
}
}
Symbol symbol4 = symbols[bestSymbolInfo.Index];
Symbol symbol5 = symbols[secondBest.Index];
if (bestSymbolInfo.IsFromFile && !secondBest.IsFromFile)
{
return symbol4;
}
bool flag;
CSDiagnosticInfo cSDiagnosticInfo;
if (symbol4 != symbol5 && NameAndArityMatchRecursively(symbol4, symbol5))
{
flag = !bestSymbolInfo.IsFromSourceModule || !secondBest.IsFromSourceModule;
if ((int)symbol4.Kind == 11 && (int)symbol5.Kind == 11)
{
if (symbol4.OriginalDefinition == symbol5.OriginalDefinition)
{
flag = true;
cSDiagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_AmbigContext, immutableArray, new object[3]
{
(val as NameSyntax)?.ErrorDisplayName() ?? text,
(object)new FormattedSymbol((ISymbolInternal)(object)symbol4, SymbolDisplayFormat.CSharpErrorMessageFormat),
(object)new FormattedSymbol((ISymbolInternal)(object)symbol5, SymbolDisplayFormat.CSharpErrorMessageFormat)
});
}
else
{
cSDiagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_SameFullNameAggAgg, immutableArray, new object[3] { symbol4.ContainingAssembly, symbol4, symbol5.ContainingAssembly });
if (secondBest.IsFromAddedModule)
{
flag = false;
}
else if (Flags.Includes(BinderFlags.IgnoreCorLibraryDuplicatedTypes) && secondBest.IsFromCorLibrary)
{
return symbol4;
}
}
}
else if ((int)symbol4.Kind == 12 && (int)symbol5.Kind == 11)
{
cSDiagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_SameFullNameNsAgg, immutableArray, new object[4]
{
GetContainingAssembly(symbol4),
symbol4,
symbol5.ContainingAssembly,
symbol5
});
if (bestSymbolInfo.IsFromSourceModule && secondBest.IsFromAddedModule)
{
flag = false;
}
}
else if ((int)symbol4.Kind == 11 && (int)symbol5.Kind == 12)
{
if (!secondBest.IsFromCompilation || secondBest.IsFromSourceModule)
{
cSDiagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_SameFullNameNsAgg, immutableArray, new object[4]
{
GetContainingAssembly(symbol5),
symbol5,
symbol4.ContainingAssembly,
symbol4
});
}
else
{
object obj2 = ((!bestSymbolInfo.IsFromSourceModule) ? ((object)symbol4.ContainingModule) : ((object)symbol4.GetFirstLocation().SourceTree.FilePath));
ModuleSymbol moduleSymbol = symbol5.ContainingModule;
if ((object)moduleSymbol == null)
{
ImmutableArray<NamespaceSymbol>.Enumerator enumerator = ((NamespaceSymbol)symbol5).ConstituentNamespaces.GetEnumerator();
while (enumerator.MoveNext())
{
NamespaceSymbol current = enumerator.Current;
if (current.ContainingAssembly == Compilation.Assembly)
{
ModuleSymbol containingModule = current.ContainingModule;
if ((object)moduleSymbol == null || moduleSymbol.Ordinal > containingModule.Ordinal)
{
moduleSymbol = containingModule;
}
}
}
}
cSDiagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_SameFullNameThisAggThisNs, immutableArray, new object[4] { obj2, symbol4, moduleSymbol, symbol5 });
}
}
else if ((int)symbol4.Kind == 16 && (int)symbol5.Kind == 16)
{
cSDiagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_AmbigMember, immutableArray, new object[2] { symbol4, symbol5 });
}
else
{
cSDiagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_AmbigMember, immutableArray, new object[2] { symbol4, symbol5 });
flag = true;
}
}
else
{
flag = true;
cSDiagnosticInfo = ((!(symbol4 is NamespaceOrTypeSymbol) || !(symbol5 is NamespaceOrTypeSymbol)) ? new CSDiagnosticInfo(ErrorCode.ERR_AmbigMember, immutableArray, new object[2] { symbol4, symbol5 }) : ((!options2.IsAttributeTypeLookup() || (int)symbol4.Kind != 11 || (int)symbol5.Kind != 11 || !(immutableArray[bestSymbolInfo.Index].Name != immutableArray[secondBest.Index].Name) || !Compilation.IsAttributeType((TypeSymbol)(NamedTypeSymbol)symbol4) || !Compilation.IsAttributeType((TypeSymbol)(NamedTypeSymbol)symbol5)) ? new CSDiagnosticInfo(ErrorCode.ERR_AmbigContext, immutableArray, new object[3]
{
(val as NameSyntax)?.ErrorDisplayName() ?? text,
(object)new FormattedSymbol((ISymbolInternal)(object)symbol4, SymbolDisplayFormat.CSharpErrorMessageFormat),
(object)new FormattedSymbol((ISymbolInternal)(object)symbol5, SymbolDisplayFormat.CSharpErrorMessageFormat)
}) : new CSDiagnosticInfo(ErrorCode.ERR_AmbiguousAttribute, immutableArray, new object[3]
{
(val as NameSyntax)?.ErrorDisplayName() ?? text,
symbol4,
symbol5
})));
}
reference = true;
if (flag && cSDiagnosticInfo != null)
{
bindingDiagnosticBag.Add((DiagnosticInfo?)(object)cSDiagnosticInfo, val.Location);
}
return new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(immutableArray[0]), immutableArray, LookupResultKind.Ambiguous, (DiagnosticInfo)(object)cSDiagnosticInfo, arity2);
}
Symbol symbol6 = symbols[0];
if (symbol6 is TypeSymbol typeSymbol && (int)typeSymbol.PrimitiveTypeCode == 17 && text == "Void")
{
reference = true;
CSDiagnosticInfo cSDiagnosticInfo2 = new CSDiagnosticInfo(ErrorCode.ERR_SystemVoid);
bindingDiagnosticBag.Add((DiagnosticInfo?)(object)cSDiagnosticInfo2, val.Location);
symbol6 = new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(symbol6), symbol6, LookupResultKind.NotReferencable, (DiagnosticInfo)(object)cSDiagnosticInfo2);
}
else
{
if ((int)symbol6.Kind == 11 && ((SourceModuleSymbol)Compilation.SourceModule).AnyReferencedAssembliesAreLinked && ((BindingDiagnosticBag)bindingDiagnosticBag).DiagnosticBag != null)
{
EmbeddedTypesManager.IsValidEmbeddableType((NamedTypeSymbol)symbol6, val, ((BindingDiagnosticBag)bindingDiagnosticBag).DiagnosticBag);
}
if (!flag2)
{
reference = ReportUseSite(symbol6, bindingDiagnosticBag, val);
}
else if ((int)symbol6.Kind == 4)
{
ErrorTypeSymbol errorTypeSymbol = (ErrorTypeSymbol)symbol6;
if (errorTypeSymbol.Unreported)
{
DiagnosticInfo errorInfo = errorTypeSymbol.ErrorInfo;
if (errorInfo != null && errorInfo.Code == 146)
{
reference = true;
bindingDiagnosticBag.Add(errorInfo, val.Location);
symbol6 = new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(errorTypeSymbol), errorTypeSymbol.Name, errorTypeSymbol.Arity, errorInfo);
}
}
}
}
return symbol6;
}
reference = true;
if (lookupResult.Kind == LookupResultKind.Empty)
{
string aliasOpt = null;
SyntaxNode val2 = val;
while (val2 is ExpressionSyntax)
{
if (val2.Kind() == SyntaxKind.AliasQualifiedName)
{
SyntaxToken identifier = ((AliasQualifiedNameSyntax)(object)val2).Alias.Identifier;
aliasOpt = ((SyntaxToken)(ref identifier)).ValueText;
break;
}
val2 = val2.Parent;
}
CSDiagnosticInfo errorInfo2 = NotFound(val, text, arity2, (val as NameSyntax)?.ErrorDisplayName() ?? text, bindingDiagnosticBag, aliasOpt, namespaceOrTypeSymbol, options2);
return new ExtendedErrorTypeSymbol(namespaceOrTypeSymbol ?? Compilation.Assembly.GlobalNamespace, text, arity2, (DiagnosticInfo?)(object)errorInfo2);
}
if (!flag2)
{
for (int j = 0; j < symbols.Count; j++)
{
ReportUseSite(symbols[j], bindingDiagnosticBag, val);
}
}
if (lookupResult.Error != null && ((object)namespaceOrTypeSymbol == null || (int)namespaceOrTypeSymbol.Kind != 4))
{
((BindingDiagnosticBag)bindingDiagnosticBag).Add((Diagnostic)(object)new CSDiagnostic(lookupResult.Error, val.Location));
}
if (symbols.Count > 1 || symbols[0] is NamespaceOrTypeSymbol || symbols[0] is AliasSymbol || lookupResult.Kind == LookupResultKind.NotATypeOrNamespace || lookupResult.Kind == LookupResultKind.NotAnAttributeType)
{
return new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(symbols[0]), symbols.ToImmutable(), lookupResult.Kind, lookupResult.Error, arity2);
}
return symbols[0];
}
}
private static AssemblySymbol GetContainingAssembly(Symbol symbol)
{
return symbol.ContainingAssembly ?? ((NamespaceSymbol)symbol).ConstituentNamespaces.First().ContainingAssembly;
}
private BestSymbolInfo GetBestSymbolInfo(ArrayBuilder<Symbol> symbols, out BestSymbolInfo secondBest)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Invalid comparison between Unknown and I4
BestSymbolInfo first = default(BestSymbolInfo);
BestSymbolInfo first2 = default(BestSymbolInfo);
CSharpCompilation compilation = Compilation;
for (int i = 0; i < symbols.Count; i++)
{
Symbol symbol = symbols[i];
BestSymbolLocation bestSymbolLocation;
if ((int)symbol.Kind == 12)
{
bestSymbolLocation = BestSymbolLocation.None;
ImmutableArray<NamespaceSymbol>.Enumerator enumerator = ((NamespaceSymbol)symbol).ConstituentNamespaces.GetEnumerator();
while (enumerator.MoveNext())
{
NamespaceSymbol current = enumerator.Current;
BestSymbolLocation location = GetLocation(compilation, current);
if (BestSymbolInfo.IsSecondLocationBetter(bestSymbolLocation, location))
{
bestSymbolLocation = location;
if (bestSymbolLocation == BestSymbolLocation.FromSourceModule)
{
break;
}
}
}
}
else
{
bestSymbolLocation = GetLocation(compilation, symbol);
}
BestSymbolInfo second = new BestSymbolInfo(bestSymbolLocation, i);
if (BestSymbolInfo.Sort(ref first2, ref second))
{
BestSymbolInfo.Sort(ref first, ref first2);
}
}
secondBest = first2;
return first;
}
private static BestSymbolLocation GetLocation(CSharpCompilation compilation, Symbol symbol)
{
if (symbol is NamedTypeSymbol { IsFileLocal: not false })
{
return BestSymbolLocation.FromFile;
}
AssemblySymbol containingAssembly = symbol.ContainingAssembly;
if (containingAssembly == compilation.SourceAssembly)
{
if (!(symbol.ContainingModule == compilation.SourceModule))
{
return BestSymbolLocation.FromAddedModule;
}
return BestSymbolLocation.FromSourceModule;
}
if (!(containingAssembly == containingAssembly.CorLibrary))
{
return BestSymbolLocation.FromReferencedAssembly;
}
return BestSymbolLocation.FromCorLibrary;
}
private CSDiagnosticInfo NotFound(SyntaxNode where, string simpleName, int arity, string whereText, BindingDiagnosticBag diagnostics, string aliasOpt, NamespaceOrTypeSymbol qualifierOpt, LookupOptions options)
{
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
Location location = where.Location;
if (options.IsAttributeTypeLookup() && !options.IsVerbatimNameAttributeTypeLookup())
{
string whereText2 = ((arity > 0) ? (simpleName + "Attribute<>") : (simpleName + "Attribute"));
NotFound(where, simpleName, arity, whereText2, diagnostics, aliasOpt, qualifierOpt, options | LookupOptions.VerbatimNameAttributeTypeOnly);
}
AssemblySymbol forwardedToAssembly;
if ((object)qualifierOpt != null)
{
if (qualifierOpt.IsType)
{
if (qualifierOpt is ErrorTypeSymbol { ErrorInfo: not null } errorTypeSymbol)
{
return (CSDiagnosticInfo)(object)errorTypeSymbol.ErrorInfo;
}
return diagnostics.Add(ErrorCode.ERR_DottedTypeNameNotFoundInAgg, location, whereText, qualifierOpt);
}
forwardedToAssembly = GetForwardedToAssembly(simpleName, arity, ref qualifierOpt, diagnostics, location);
if ((object)qualifierOpt == Compilation.GlobalNamespace)
{
if ((object)forwardedToAssembly != null)
{
return diagnostics.Add(ErrorCode.ERR_GlobalSingleTypeNameNotFoundFwd, location, whereText, forwardedToAssembly);
}
return diagnostics.Add(ErrorCode.ERR_GlobalSingleTypeNameNotFound, location, whereText);
}
object obj = qualifierOpt;
if (aliasOpt != null && qualifierOpt.IsNamespace && ((NamespaceSymbol)qualifierOpt).IsGlobalNamespace)
{
obj = aliasOpt;
}
if ((object)forwardedToAssembly != null)
{
return diagnostics.Add(ErrorCode.ERR_DottedTypeNameNotFoundInNSFwd, location, whereText, obj, forwardedToAssembly);
}
return diagnostics.Add(ErrorCode.ERR_DottedTypeNameNotFoundInNS, location, whereText, obj);
}
if (options == LookupOptions.NamespaceAliasesOnly)
{
return diagnostics.Add(ErrorCode.ERR_AliasNotFound, location, whereText);
}
IdentifierNameSyntax obj2 = where as IdentifierNameSyntax;
object obj3;
if (obj2 == null)
{
obj3 = null;
}
else
{
SyntaxToken identifier = obj2.Identifier;
obj3 = ((SyntaxToken)(ref identifier)).Text;
}
if ((string?)obj3 == "var" && !options.IsAttributeTypeLookup())
{
ErrorCode code = ((where.Parent is QueryClauseSyntax) ? ErrorCode.ERR_TypeVarNotFoundRangeVariable : ErrorCode.ERR_TypeVarNotFound);
return diagnostics.Add(code, location);
}
forwardedToAssembly = GetForwardedToAssembly(simpleName, arity, ref qualifierOpt, diagnostics, location);
if ((object)forwardedToAssembly != null)
{
if (!(qualifierOpt == null))
{
return diagnostics.Add(ErrorCode.ERR_DottedTypeNameNotFoundInNSFwd, location, whereText, qualifierOpt, forwardedToAssembly);
}
return diagnostics.Add(ErrorCode.ERR_SingleTypeNameNotFoundFwd, location, whereText, forwardedToAssembly);
}
return diagnostics.Add(ErrorCode.ERR_SingleTypeNameNotFound, location, whereText);
}
protected virtual AssemblySymbol GetForwardedToAssemblyInUsingNamespaces(string metadataName, ref NamespaceOrTypeSymbol qualifierOpt, BindingDiagnosticBag diagnostics, Location location)
{
return Next?.GetForwardedToAssemblyInUsingNamespaces(metadataName, ref qualifierOpt, diagnostics, location);
}
protected AssemblySymbol GetForwardedToAssembly(string fullName, BindingDiagnosticBag diagnostics, Location location)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Invalid comparison between Unknown and I4
MetadataTypeName emittedName = MetadataTypeName.FromFullName(fullName, false, -1);
ImmutableArray<AssemblySymbol>.Enumerator enumerator = Compilation.Assembly.Modules[0].GetReferencedAssemblySymbols().GetEnumerator();
while (enumerator.MoveNext())
{
NamedTypeSymbol namedTypeSymbol = enumerator.Current.TryLookupForwardedMetadataTypeWithCycleDetection(ref emittedName, null);
if ((object)namedTypeSymbol == null)
{
continue;
}
if ((int)namedTypeSymbol.Kind == 4)
{
DiagnosticInfo errorInfo = ((ErrorTypeSymbol)namedTypeSymbol).ErrorInfo;
if (errorInfo.Code == 731)
{
diagnostics.Add(ErrorCode.ERR_CycleInTypeForwarder, location, fullName, namedTypeSymbol.ContainingAssembly.Name);
}
else if (errorInfo.Code == 8206)
{
diagnostics.Add(errorInfo, location);
return null;
}
}
return namedTypeSymbol.ContainingAssembly;
}
return null;
}
internal static ContextualAttributeBinder TryGetContextualAttributeBinder(Binder binder)
{
if ((binder.Flags & BinderFlags.InContextualAttributeBinder) != BinderFlags.None)
{
do
{
if (binder is ContextualAttributeBinder result)
{
return result;
}
binder = binder.Next;
}
while (binder != null);
}
return null;
}
protected AssemblySymbol GetForwardedToAssembly(string name, int arity, ref NamespaceOrTypeSymbol qualifierOpt, BindingDiagnosticBag diagnostics, Location location)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Invalid comparison between Unknown and I4
ContextualAttributeBinder contextualAttributeBinder = TryGetContextualAttributeBinder(this);
if (contextualAttributeBinder != null)
{
Symbol attributeTarget = contextualAttributeBinder.AttributeTarget;
if ((object)attributeTarget != null && (int)attributeTarget.Kind == 2)
{
return null;
}
}
string text = MetadataHelpers.ComposeAritySuffixedMetadataName(name, arity, (string)null);
string fullName = MetadataHelpers.BuildQualifiedName(qualifierOpt?.ToDisplayString(SymbolDisplayFormat.QualifiedNameOnlyFormat), text);
AssemblySymbol forwardedToAssembly = GetForwardedToAssembly(fullName, diagnostics, location);
if ((object)forwardedToAssembly != null)
{
return forwardedToAssembly;
}
if ((object)qualifierOpt == null)
{
return GetForwardedToAssemblyInUsingNamespaces(text, ref qualifierOpt, diagnostics, location);
}
return null;
}
internal static bool CheckFeatureAvailability(SyntaxNode syntax, MessageID feature, BindingDiagnosticBag diagnostics, Location? location = null)
{
return CheckFeatureAvailability(syntax, feature, ((BindingDiagnosticBag)diagnostics).DiagnosticBag, location);
}
internal static bool CheckFeatureAvailability(SyntaxToken syntax, MessageID feature, BindingDiagnosticBag diagnostics, bool forceWarning = false)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return CheckFeatureAvailability(syntax, feature, ((BindingDiagnosticBag)diagnostics).DiagnosticBag, forceWarning);
}
internal static bool CheckFeatureAvailability(SyntaxTree tree, MessageID feature, BindingDiagnosticBag diagnostics, Location location)
{
return CheckFeatureAvailability(tree, feature, ((BindingDiagnosticBag)diagnostics).DiagnosticBag, location);
}
private static bool CheckFeatureAvailability(SyntaxNode syntax, MessageID feature, DiagnosticBag? diagnostics, Location? location = null)
{
return CheckFeatureAvailability(syntax.SyntaxTree, feature, diagnostics, (location, syntax), ((Location location, SyntaxNode syntax) tuple) => tuple.location ?? tuple.syntax.GetLocation());
}
private static bool CheckFeatureAvailability(SyntaxToken syntax, MessageID feature, DiagnosticBag? diagnostics, bool forceWarning = false)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
return CheckFeatureAvailability(((SyntaxToken)(ref syntax)).SyntaxTree, feature, diagnostics, syntax, (SyntaxToken val) => ((SyntaxToken)(ref val)).GetLocation(), forceWarning);
}
private static bool CheckFeatureAvailability(SyntaxTree tree, MessageID feature, DiagnosticBag? diagnostics, Location location)
{
return CheckFeatureAvailability(tree, feature, diagnostics, location, (Location result) => result);
}
private static bool CheckFeatureAvailability<TData>(SyntaxTree tree, MessageID feature, DiagnosticBag? diagnostics, TData data, Func<TData, Location> getLocation, bool forceWarning = false)
{
CSDiagnosticInfo featureAvailabilityDiagnosticInfo = feature.GetFeatureAvailabilityDiagnosticInfo((CSharpParseOptions)(object)tree.Options);
if (featureAvailabilityDiagnosticInfo != null)
{
if (forceWarning)
{
diagnostics?.Add(ErrorCode.WRN_ErrorOverride, getLocation(data), featureAvailabilityDiagnosticInfo, (int)featureAvailabilityDiagnosticInfo.Code);
}
else
{
diagnostics?.Add((DiagnosticInfo)(object)featureAvailabilityDiagnosticInfo, getLocation(data));
}
return false;
}
return true;
}
private BoundTupleBinaryOperator BindTupleBinaryOperator(BinaryExpressionSyntax node, BinaryOperatorKind kind, BoundExpression left, BoundExpression right, BindingDiagnosticBag diagnostics)
{
TupleBinaryOperatorInfo.Multiple multiple = BindTupleBinaryOperatorNestedInfo(node, kind, left, right, diagnostics);
BoundExpression left2 = ApplyConvertedTypes(left, multiple, isRight: false, diagnostics);
BoundExpression right2 = ApplyConvertedTypes(right, multiple, isRight: true, diagnostics);
TypeSymbol specialType = GetSpecialType((SpecialType)7, diagnostics, (SyntaxNode)(object)node);
return new BoundTupleBinaryOperator((SyntaxNode)(object)node, left2, right2, kind, multiple, specialType);
}
private BoundExpression ApplyConvertedTypes(BoundExpression expr, TupleBinaryOperatorInfo @operator, bool isRight, BindingDiagnosticBag diagnostics)
{
TypeSymbol typeSymbol = (isRight ? @operator.RightConvertedTypeOpt : @operator.LeftConvertedTypeOpt);
if ((object)typeSymbol == null)
{
if (@operator.InfoKind == TupleBinaryOperatorInfoKind.Multiple && expr is BoundTupleLiteral boundTupleLiteral)
{
TupleBinaryOperatorInfo.Multiple multiple = (TupleBinaryOperatorInfo.Multiple)@operator;
if (multiple.Operators.Length == 0)
{
return BindToNaturalType(expr, diagnostics, reportNoTargetType: false);
}
ImmutableArray<BoundExpression> arguments = boundTupleLiteral.Arguments;
int length = arguments.Length;
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(length);
for (int i = 0; i < length; i++)
{
instance.Add(ApplyConvertedTypes(arguments[i], multiple.Operators[i], isRight, diagnostics));
}
return new BoundConvertedTupleLiteral(boundTupleLiteral.Syntax, boundTupleLiteral, wasTargetTyped: false, instance.ToImmutableAndFree(), boundTupleLiteral.ArgumentNamesOpt, boundTupleLiteral.InferredNamesOpt, boundTupleLiteral.Type, boundTupleLiteral.HasErrors);
}
return BindToNaturalType(expr, diagnostics, reportNoTargetType: false);
}
return GenerateConversionForAssignment(typeSymbol, expr, diagnostics);
}
private TupleBinaryOperatorInfo BindTupleBinaryOperatorInfo(BinaryExpressionSyntax node, BinaryOperatorKind kind, BoundExpression left, BoundExpression right, BindingDiagnosticBag diagnostics)
{
TypeSymbol type = left.Type;
TypeSymbol type2 = right.Type;
if (((object)type != null && type.IsDynamic()) || ((object)type2 != null && type2.IsDynamic()))
{
return BindTupleDynamicBinaryOperatorSingleInfo(node, kind, left, right, diagnostics);
}
if (IsTupleBinaryOperation(left, right))
{
return BindTupleBinaryOperatorNestedInfo(node, kind, left, right, diagnostics);
}
BoundExpression boundExpression = BindSimpleBinaryOperator(node, diagnostics, left, right, leaveUnconvertedIfInterpolatedString: false);
if (!(boundExpression is BoundLiteral))
{
if (boundExpression is BoundBinaryOperator boundBinaryOperator)
{
PrepareBoolConversionAndTruthOperator(boundBinaryOperator.Type, node, kind, diagnostics, out var conversionForBool, out var conversionForBoolPlaceholder, out var boolOperator);
CheckConstraintLanguageVersionAndRuntimeSupportForOperator((SyntaxNode)(object)node, boolOperator.Method, isUnsignedRightShift: false, boolOperator.ConstrainedToTypeOpt, diagnostics);
return new TupleBinaryOperatorInfo.Single(boundBinaryOperator.Left.Type, boundBinaryOperator.Right.Type, boundBinaryOperator.OperatorKind, boundBinaryOperator.Method, boundBinaryOperator.ConstrainedToType, conversionForBoolPlaceholder, conversionForBool, boolOperator);
}
throw ExceptionUtilities.UnexpectedValue((object)boundExpression);
}
return new TupleBinaryOperatorInfo.NullNull(kind);
}
private void PrepareBoolConversionAndTruthOperator(TypeSymbol type, BinaryExpressionSyntax node, BinaryOperatorKind binaryOperator, BindingDiagnosticBag diagnostics, out BoundExpression conversionForBool, out BoundValuePlaceholder conversionForBoolPlaceholder, out UnaryOperatorSignature boolOperator)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
TypeSymbol specialType = GetSpecialType((SpecialType)7, diagnostics, (SyntaxNode)(object)node);
Conversion conversion = Conversions.ClassifyImplicitConversionFromType(type, specialType, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node, useSiteInfo);
if (conversion.IsImplicit)
{
conversionForBoolPlaceholder = new BoundValuePlaceholder((SyntaxNode)(object)node, type).MakeCompilerGenerated();
conversionForBool = CreateConversion((SyntaxNode)(object)node, conversionForBoolPlaceholder, conversion, isCast: false, null, specialType, diagnostics);
boolOperator = default(UnaryOperatorSignature);
return;
}
UnaryOperatorKind kind = binaryOperator switch
{
BinaryOperatorKind.Equal => UnaryOperatorKind.False,
BinaryOperatorKind.NotEqual => UnaryOperatorKind.True,
_ => throw ExceptionUtilities.UnexpectedValue((object)binaryOperator),
};
BoundExpression operand = new BoundTupleOperandPlaceholder((SyntaxNode)(object)node, type);
LookupResultKind resultKind;
ImmutableArray<MethodSymbol> originalUserDefinedOperators;
UnaryOperatorAnalysisResult unaryOperatorAnalysisResult = UnaryOperatorOverloadResolution(kind, operand, node, diagnostics, out resultKind, out originalUserDefinedOperators);
if (unaryOperatorAnalysisResult.HasValue)
{
conversionForBoolPlaceholder = new BoundValuePlaceholder((SyntaxNode)(object)node, type).MakeCompilerGenerated();
conversionForBool = CreateConversion((SyntaxNode)(object)node, conversionForBoolPlaceholder, unaryOperatorAnalysisResult.Conversion, isCast: false, null, unaryOperatorAnalysisResult.Signature.OperandType, diagnostics);
boolOperator = unaryOperatorAnalysisResult.Signature;
}
else
{
GenerateImplicitConversionError(diagnostics, (SyntaxNode)(object)node, conversion, operand, specialType);
conversionForBoolPlaceholder = null;
conversionForBool = null;
boolOperator = default(UnaryOperatorSignature);
}
}
private TupleBinaryOperatorInfo BindTupleDynamicBinaryOperatorSingleInfo(BinaryExpressionSyntax node, BinaryOperatorKind kind, BoundExpression left, BoundExpression right, BindingDiagnosticBag diagnostics)
{
//IL_0021: 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)
bool flag = false;
if (!IsLegalDynamicOperand(left) || !IsLegalDynamicOperand(right))
{
object[] array = new object[3];
SyntaxToken operatorToken = node.OperatorToken;
array[0] = ((SyntaxToken)(ref operatorToken)).Text;
array[1] = left.Display;
array[2] = right.Display;
Error(diagnostics, ErrorCode.ERR_BadBinaryOps, (CSharpSyntaxNode)node, array);
flag = true;
}
BinaryOperatorKind kind2 = (flag ? kind : kind.WithType(BinaryOperatorKind.Dynamic));
TypeSymbol obj = (flag ? CreateErrorType() : Compilation.DynamicType);
return new TupleBinaryOperatorInfo.Single(obj, obj, kind2, null, null, null, null, default(UnaryOperatorSignature));
}
private TupleBinaryOperatorInfo.Multiple BindTupleBinaryOperatorNestedInfo(BinaryExpressionSyntax node, BinaryOperatorKind kind, BoundExpression left, BoundExpression right, BindingDiagnosticBag diagnostics)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
left = GiveTupleTypeToDefaultLiteralIfNeeded(left, right.Type);
right = GiveTupleTypeToDefaultLiteralIfNeeded(right, left.Type);
if (left.IsLiteralDefaultOrImplicitObjectCreation() || right.IsLiteralDefaultOrImplicitObjectCreation())
{
ReportBinaryOperatorError(node, diagnostics, node.OperatorToken, left, right, LookupResultKind.Ambiguous);
return TupleBinaryOperatorInfo.Multiple.ErrorInstance;
}
int tupleCardinality = GetTupleCardinality(left);
int tupleCardinality2 = GetTupleCardinality(right);
if (tupleCardinality != tupleCardinality2)
{
Error(diagnostics, ErrorCode.ERR_TupleSizesMismatchForBinOps, (CSharpSyntaxNode)node, new object[2] { tupleCardinality, tupleCardinality2 });
return TupleBinaryOperatorInfo.Multiple.ErrorInstance;
}
var (elements, immutableArray) = GetTupleArgumentsOrPlaceholders(left);
var (elements2, immutableArray2) = GetTupleArgumentsOrPlaceholders(right);
ReportNamesMismatchesIfAny(left, right, immutableArray, immutableArray2, diagnostics);
int length = elements.Length;
ArrayBuilder<TupleBinaryOperatorInfo> instance = ArrayBuilder<TupleBinaryOperatorInfo>.GetInstance(length);
for (int i = 0; i < length; i++)
{
instance.Add(BindTupleBinaryOperatorInfo(node, kind, elements[i], elements2[i], diagnostics));
}
CSharpCompilation compilation = Compilation;
ImmutableArray<TupleBinaryOperatorInfo> immutableArray3 = instance.ToImmutableAndFree();
bool num = left.Type?.IsNullableType() ?? false;
bool flag = right.Type?.IsNullableType() ?? false;
bool isNullable = num || flag;
TypeSymbol leftConvertedTypeOpt = MakeConvertedType(ImmutableArrayExtensions.SelectAsArray<TupleBinaryOperatorInfo, TypeSymbol>(immutableArray3, (Func<TupleBinaryOperatorInfo, TypeSymbol>)((TupleBinaryOperatorInfo o) => o.LeftConvertedTypeOpt)), node.Left, elements, immutableArray, isNullable, compilation, diagnostics);
TypeSymbol rightConvertedTypeOpt = MakeConvertedType(ImmutableArrayExtensions.SelectAsArray<TupleBinaryOperatorInfo, TypeSymbol>(immutableArray3, (Func<TupleBinaryOperatorInfo, TypeSymbol>)((TupleBinaryOperatorInfo o) => o.RightConvertedTypeOpt)), node.Right, elements2, immutableArray2, isNullable, compilation, diagnostics);
return new TupleBinaryOperatorInfo.Multiple(immutableArray3, leftConvertedTypeOpt, rightConvertedTypeOpt);
}
private static void ReportNamesMismatchesIfAny(BoundExpression left, BoundExpression right, ImmutableArray<string> leftNames, ImmutableArray<string> rightNames, BindingDiagnosticBag diagnostics)
{
bool flag = left is BoundTupleExpression;
bool flag2 = right is BoundTupleExpression;
if (!flag && !flag2)
{
return;
}
bool isDefault = leftNames.IsDefault;
bool isDefault2 = rightNames.IsDefault;
if (isDefault && isDefault2)
{
return;
}
ImmutableArray<bool> immutableArray = (flag ? ((BoundTupleExpression)left).InferredNamesOpt : default(ImmutableArray<bool>));
bool isDefault3 = immutableArray.IsDefault;
ImmutableArray<bool> immutableArray2 = (flag2 ? ((BoundTupleExpression)right).InferredNamesOpt : default(ImmutableArray<bool>));
bool isDefault4 = immutableArray2.IsDefault;
int num = (isDefault ? rightNames.Length : leftNames.Length);
for (int i = 0; i < num; i++)
{
string text = (isDefault ? null : leftNames[i]);
string text2 = (isDefault2 ? null : rightNames[i]);
if (string.CompareOrdinal(text2, text) != 0)
{
bool flag3 = !isDefault3 && immutableArray[i];
bool flag4 = !isDefault4 && immutableArray2[i];
bool flag5 = flag && text != null && !flag3;
bool flag6 = flag2 && text2 != null && !flag4;
if (flag5 || flag6)
{
bool num2 = ((flag5 && flag6) ? flag2 : flag6);
Location location = ((BoundTupleExpression)(num2 ? right : left)).Arguments[i].Syntax.Parent.Location;
string text3 = (num2 ? text2 : text);
diagnostics.Add(ErrorCode.WRN_TupleBinopLiteralNameMismatch, location, text3);
}
}
}
}
internal static BoundExpression GiveTupleTypeToDefaultLiteralIfNeeded(BoundExpression expr, TypeSymbol targetType)
{
if (!expr.IsLiteralDefault() || (object)targetType == null)
{
return expr;
}
return new BoundDefaultExpression(expr.Syntax, targetType);
}
private static bool IsTupleBinaryOperation(BoundExpression left, BoundExpression right)
{
bool flag = left.IsLiteralDefaultOrImplicitObjectCreation();
bool flag2 = right.IsLiteralDefaultOrImplicitObjectCreation();
if (flag && flag2)
{
return false;
}
if (GetTupleCardinality(left) > 1 || flag)
{
return GetTupleCardinality(right) > 1 || flag2;
}
return false;
}
private static int GetTupleCardinality(BoundExpression expr)
{
if (expr is BoundTupleExpression boundTupleExpression)
{
return boundTupleExpression.Arguments.Length;
}
TypeSymbol type = expr.Type;
if ((object)type == null)
{
return -1;
}
TypeSymbol typeSymbol = type.StrippedType();
if ((object)typeSymbol != null && typeSymbol.IsTupleType)
{
return typeSymbol.TupleElementTypesWithAnnotations.Length;
}
return -1;
}
private static (ImmutableArray<BoundExpression> Elements, ImmutableArray<string> Names) GetTupleArgumentsOrPlaceholders(BoundExpression expr)
{
if (expr is BoundTupleExpression boundTupleExpression)
{
return (Elements: boundTupleExpression.Arguments, Names: boundTupleExpression.ArgumentNamesOpt);
}
TypeSymbol typeSymbol = expr.Type.StrippedType();
return (Elements: ImmutableArrayExtensions.SelectAsArray<TypeWithAnnotations, SyntaxNode, BoundExpression>(typeSymbol.TupleElementTypesWithAnnotations, (Func<TypeWithAnnotations, SyntaxNode, BoundExpression>)((TypeWithAnnotations t, SyntaxNode s) => new BoundTupleOperandPlaceholder(s, t.Type)), expr.Syntax), Names: typeSymbol.TupleElementNames);
}
private TypeSymbol MakeConvertedType(ImmutableArray<TypeSymbol> convertedTypes, CSharpSyntaxNode syntax, ImmutableArray<BoundExpression> elements, ImmutableArray<string> names, bool isNullable, CSharpCompilation compilation, BindingDiagnosticBag diagnostics)
{
ImmutableArray<TypeSymbol>.Enumerator enumerator = convertedTypes.GetEnumerator();
while (enumerator.MoveNext())
{
if ((object)enumerator.Current == null)
{
return null;
}
}
ImmutableArray<Location> elementLocations = ImmutableArrayExtensions.SelectAsArray<BoundExpression, Location>(elements, (Func<BoundExpression, Location>)((BoundExpression e) => e.Syntax.Location));
NamedTypeSymbol namedTypeSymbol = NamedTypeSymbol.CreateTuple(null, ImmutableArrayExtensions.SelectAsArray<TypeSymbol, TypeWithAnnotations>(convertedTypes, (Func<TypeSymbol, TypeWithAnnotations>)((TypeSymbol t) => TypeWithAnnotations.Create(t))), elementLocations, names, compilation, shouldCheckConstraints: true, includeNullability: false, default(ImmutableArray<bool>), syntax, diagnostics);
if (!isNullable)
{
return namedTypeSymbol;
}
return GetSpecialType((SpecialType)32, diagnostics, (SyntaxNode)(object)syntax).Construct(namedTypeSymbol);
}
internal bool ReportUnsafeIfNotAllowed(SyntaxNode node, BindingDiagnosticBag diagnostics, TypeSymbol sizeOfTypeOpt = null)
{
CSDiagnosticInfo unsafeDiagnosticInfo = GetUnsafeDiagnosticInfo(sizeOfTypeOpt);
if (unsafeDiagnosticInfo == null)
{
return false;
}
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic((DiagnosticInfo)(object)unsafeDiagnosticInfo, node.Location));
return true;
}
internal bool ReportUnsafeIfNotAllowed(Location location, BindingDiagnosticBag diagnostics)
{
CSDiagnosticInfo unsafeDiagnosticInfo = GetUnsafeDiagnosticInfo(null);
if (unsafeDiagnosticInfo == null)
{
return false;
}
((BindingDiagnosticBag)diagnostics).Add((Diagnostic)(object)new CSDiagnostic((DiagnosticInfo)(object)unsafeDiagnosticInfo, location));
return true;
}
private CSDiagnosticInfo GetUnsafeDiagnosticInfo(TypeSymbol sizeOfTypeOpt)
{
if (Flags.Includes(BinderFlags.SuppressUnsafeDiagnostics))
{
return null;
}
if (IsIndirectlyInIterator)
{
return new CSDiagnosticInfo(ErrorCode.ERR_IllegalInnerUnsafe);
}
if (!InUnsafeRegion)
{
if ((object)sizeOfTypeOpt != null)
{
return new CSDiagnosticInfo(ErrorCode.ERR_SizeofUnsafe, sizeOfTypeOpt);
}
return new CSDiagnosticInfo(ErrorCode.ERR_UnsafeNeeded);
}
return null;
}
private BoundExpression BindWithExpression(WithExpressionSyntax syntax, BindingDiagnosticBag diagnostics)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
MessageID.IDS_FeatureRecords.CheckFeatureAvailability(diagnostics, syntax.WithKeyword);
BoundExpression boundExpression = BindRValueWithoutTargetType(syntax.Expression, diagnostics);
TypeSymbol typeSymbol = boundExpression.Type;
bool hasErrors = false;
if ((object)typeSymbol == null || typeSymbol.IsVoidType())
{
diagnostics.Add(ErrorCode.ERR_InvalidWithReceiverType, ((SyntaxNode)syntax.Expression).Location);
typeSymbol = CreateErrorType();
}
MethodSymbol methodSymbol = null;
if (typeSymbol.IsValueType && !typeSymbol.IsPointerOrFunctionPointer())
{
CheckFeatureAvailability((SyntaxNode)(object)syntax, MessageID.IDS_FeatureWithOnStructs, diagnostics);
}
else if (typeSymbol.IsAnonymousType && !typeSymbol.IsDelegateType())
{
CheckFeatureAvailability((SyntaxNode)(object)syntax, MessageID.IDS_FeatureWithOnAnonymousTypes, diagnostics);
}
else if (!typeSymbol.IsErrorType())
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
methodSymbol = SynthesizedRecordClone.FindValidCloneMethod((typeSymbol is TypeParameterSymbol typeParameterSymbol) ? typeParameterSymbol.EffectiveBaseClass(ref useSiteInfo) : typeSymbol, ref useSiteInfo);
if ((object)methodSymbol == null)
{
hasErrors = true;
diagnostics.Add(ErrorCode.ERR_CannotClone, ((SyntaxNode)syntax.Expression).Location, typeSymbol);
}
else
{
methodSymbol.AddUseSiteInfo(ref useSiteInfo);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)syntax.Expression, useSiteInfo);
}
BoundObjectInitializerExpressionBase initializerExpression = BindInitializerExpression(syntax.Initializer, typeSymbol, (SyntaxNode)(object)syntax.Expression, isForNewInstance: true, diagnostics);
return new BoundWithExpression((SyntaxNode)(object)syntax, boundExpression, methodSymbol, initializerExpression, typeSymbol, hasErrors);
}
internal ImmutableArray<Symbol> BindXmlNameAttribute(XmlNameAttributeSyntax syntax, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
IdentifierNameSyntax identifier = syntax.Identifier;
if (((SyntaxNode)identifier).IsMissing)
{
return ImmutableArray<Symbol>.Empty;
}
SyntaxToken identifier2 = identifier.Identifier;
string valueText = ((SyntaxToken)(ref identifier2)).ValueText;
LookupResult instance = LookupResult.GetInstance();
LookupSymbolsWithFallback(instance, valueText, 0, ref useSiteInfo);
if (instance.Kind == LookupResultKind.Empty)
{
instance.Free();
return ImmutableArray<Symbol>.Empty;
}
ImmutableArray<Symbol> result = instance.Symbols.ToImmutable();
instance.Free();
return result;
}
protected BoundExpression ConvertForEachCollection(BoundExpression collectionExpr, Conversion collectionConversionClassification, TypeSymbol collectionType, BindingDiagnosticBag diagnostics)
{
BoundExpression boundExpression = CreateConversion(collectionExpr.Syntax, collectionExpr, collectionConversionClassification, isCast: false, null, collectionType, diagnostics);
if ((boundExpression as BoundConversion)?.Operand != collectionExpr)
{
boundExpression = new BoundConversion(collectionExpr.Syntax, collectionExpr, collectionConversionClassification, CheckOverflowAtRuntime, explicitCastInCode: false, null, null, collectionType);
}
return boundExpression;
}
internal bool GetEnumeratorInfoAndInferCollectionElementType(SyntaxNode syntax, ExpressionSyntax collectionSyntax, ref BoundExpression collectionExpr, bool isAsync, BindingDiagnosticBag diagnostics, out TypeWithAnnotations inferredType, out ForEachEnumeratorInfo.Builder builder)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Invalid comparison between Unknown and I4
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Invalid comparison between Unknown and I4
bool enumeratorInfo = GetEnumeratorInfo(syntax, collectionSyntax, ref collectionExpr, isAsync, diagnostics, out builder);
if (!enumeratorInfo)
{
inferredType = default(TypeWithAnnotations);
return enumeratorInfo;
}
if (collectionExpr.HasDynamicType())
{
inferredType = TypeWithAnnotations.Create(DynamicTypeSymbol.Instance);
return enumeratorInfo;
}
if ((int)collectionExpr.Type.SpecialType == 20 && (int)builder.CollectionType.SpecialType == 24)
{
inferredType = TypeWithAnnotations.Create(GetSpecialType((SpecialType)8, diagnostics, collectionExpr.Syntax));
return enumeratorInfo;
}
inferredType = builder.ElementTypeWithAnnotations;
return enumeratorInfo;
}
private BoundExpression UnwrapCollectionExpressionIfNullable(BoundExpression collectionExpr, BindingDiagnosticBag diagnostics)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
TypeSymbol type = collectionExpr.Type;
if ((object)type != null && type.IsNullableType())
{
SyntaxNode syntax = collectionExpr.Syntax;
MethodSymbol methodSymbol = (MethodSymbol)GetSpecialTypeMember((SpecialMember)115, diagnostics, syntax);
if ((object)methodSymbol != null)
{
methodSymbol = methodSymbol.AsMember((NamedTypeSymbol)type);
return BoundCall.Synthesized(syntax, collectionExpr, ReceiverIsSubjectToCloning(collectionExpr, methodSymbol), methodSymbol);
}
return new BoundBadExpression(syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create(collectionExpr), type.GetNullableUnderlyingType())
{
WasCompilerGenerated = true
};
}
return collectionExpr;
}
private bool GetEnumeratorInfo(SyntaxNode syntax, ExpressionSyntax collectionSyntax, ref BoundExpression collectionExpr, bool isAsync, BindingDiagnosticBag diagnostics, out ForEachEnumeratorInfo.Builder builder)
{
BoundExpression collectionExpr2 = collectionExpr;
switch (GetEnumeratorInfoCore(syntax, collectionSyntax, ref collectionExpr, isAsync, diagnostics, out builder))
{
case EnumeratorResult.Succeeded:
return true;
case EnumeratorResult.FailedAndReported:
return false;
default:
{
TypeSymbol type = collectionExpr.Type;
if (string.IsNullOrEmpty(type.Name) && collectionExpr.HasErrors)
{
return false;
}
if (type.IsErrorType())
{
return false;
}
ForEachEnumeratorInfo.Builder builder2;
ErrorCode code = ((GetEnumeratorInfoCore(syntax, collectionSyntax, ref collectionExpr2, !isAsync, BindingDiagnosticBag.Discarded, out builder2) != EnumeratorResult.Succeeded) ? (isAsync ? ErrorCode.ERR_AwaitForEachMissingMember : ErrorCode.ERR_ForEachMissingMember) : (isAsync ? ErrorCode.ERR_AwaitForEachMissingMemberWrongAsync : ErrorCode.ERR_ForEachMissingMemberWrongAsync));
diagnostics.Add(code, ((SyntaxNode)collectionSyntax).Location, type, isAsync ? "GetAsyncEnumerator" : "GetEnumerator");
return false;
}
}
}
private EnumeratorResult GetEnumeratorInfoCore(SyntaxNode syntax, ExpressionSyntax collectionSyntax, ref BoundExpression collectionExpr, bool isAsync, BindingDiagnosticBag diagnostics, out ForEachEnumeratorInfo.Builder builder)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Invalid comparison between Unknown and I4
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Invalid comparison between Unknown and I4
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
if (!isAsync)
{
TypeSymbol? type = collectionExpr.Type;
if ((object)type != null && type.HasInlineArrayAttribute(out var _))
{
FieldSymbol fieldSymbol = collectionExpr.Type.TryGetPossiblyUnsupportedByLanguageInlineArrayElementField();
if ((object)fieldSymbol != null)
{
bool inlineArrayUsedAsValue = false;
WellKnownType val;
if (CheckValueKind(collectionExpr.Syntax, collectionExpr, BindValueKind.Assignable | BindValueKind.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
{
val = (WellKnownType)275;
}
else
{
val = (WellKnownType)276;
if (!CheckValueKind(collectionExpr.Syntax, collectionExpr, BindValueKind.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
{
inlineArrayUsedAsValue = true;
}
}
NamedTypeSymbol wellKnownType = GetWellKnownType(val, diagnostics, collectionExpr.Syntax);
if (wellKnownType.IsErrorType())
{
builder = default(ForEachEnumeratorInfo.Builder);
return EnumeratorResult.FailedAndReported;
}
wellKnownType = wellKnownType.Construct(ImmutableArray.Create(fieldSymbol.TypeWithAnnotations));
wellKnownType.CheckConstraints(new ConstraintsHelper.CheckConstraintsArgs(Compilation, Conversions, collectionExpr.Syntax.GetLocation(), diagnostics));
if (!TypeSymbol.IsInlineArrayElementFieldSupported(fieldSymbol))
{
diagnostics.Add(ErrorCode.ERR_InlineArrayForEachNotSupported, collectionExpr.Syntax.GetLocation(), collectionExpr.Type);
builder = default(ForEachEnumeratorInfo.Builder);
return EnumeratorResult.FailedAndReported;
}
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(diagnostics);
BoundExpression collectionExpr2 = new BoundValuePlaceholder(collectionExpr.Syntax, wellKnownType).MakeCompilerGenerated();
EnumeratorResult enumeratorResult = getEnumeratorInfo(syntax, collectionSyntax, ref collectionExpr2, isAsync: false, instance, out builder);
if (!builder.ViaExtensionMethod && ((enumeratorResult == EnumeratorResult.Succeeded && builder.ElementTypeWithAnnotations.Equals(fieldSymbol.TypeWithAnnotations, (TypeCompareKind)63) && builder.CurrentPropertyGetter?.RefKind == (RefKind?)(((int)val != 276) ? 1 : 3)) || enumeratorResult == EnumeratorResult.FailedAndReported))
{
builder.CollectionType = collectionExpr.Type;
builder.InlineArraySpanType = val;
builder.InlineArrayUsedAsValue = inlineArrayUsedAsValue;
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRangeAndFree((BindingDiagnosticBag<AssemblySymbol>)(object)instance);
CheckFeatureAvailability(collectionExpr.Syntax, MessageID.IDS_FeatureInlineArrays, diagnostics);
if (enumeratorResult == EnumeratorResult.Succeeded)
{
if ((int)val == 276)
{
GetWellKnownTypeMember((WellKnownMember)131, diagnostics, null, collectionExpr.Syntax);
}
GetWellKnownTypeMember((WellKnownMember)129, diagnostics, null, collectionExpr.Syntax);
GetWellKnownTypeMember((WellKnownMember)130, diagnostics, null, collectionExpr.Syntax);
}
return enumeratorResult;
}
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
diagnostics.Add(ErrorCode.ERR_InlineArrayForEachNotSupported, collectionExpr.Syntax.GetLocation(), collectionExpr.Type);
builder = default(ForEachEnumeratorInfo.Builder);
return EnumeratorResult.FailedAndReported;
}
}
}
return getEnumeratorInfo(syntax, collectionSyntax, ref collectionExpr, isAsync, diagnostics, out builder);
EnumeratorResult createPatternBasedEnumeratorResult(ref ForEachEnumeratorInfo.Builder reference, BoundExpression boundExpression, bool flag, bool viaExtensionMethod, BindingDiagnosticBag bindingDiagnosticBag)
{
reference.ViaExtensionMethod = viaExtensionMethod;
reference.CollectionType = (viaExtensionMethod ? reference.GetEnumeratorInfo.Method.Parameters[0].Type : boundExpression.Type);
if (SatisfiesForEachPattern(syntax, collectionSyntax, ref reference, flag, bindingDiagnosticBag))
{
reference.ElementTypeWithAnnotations = ((PropertySymbol)reference.CurrentPropertyGetter.AssociatedSymbol).TypeWithAnnotations;
GetDisposalInfoForEnumerator(syntax, ref reference, boundExpression, flag, bindingDiagnosticBag);
return EnumeratorResult.Succeeded;
}
MethodSymbol method = reference.GetEnumeratorInfo.Method;
bindingDiagnosticBag.Add(flag ? ErrorCode.ERR_BadGetAsyncEnumerator : ErrorCode.ERR_BadGetEnumerator, ((SyntaxNode)collectionSyntax).Location, method.ReturnType, method);
return EnumeratorResult.FailedAndReported;
}
EnumeratorResult getEnumeratorInfo(SyntaxNode syntax2, ExpressionSyntax expressionSyntax, ref BoundExpression reference2, bool flag, BindingDiagnosticBag bindingDiagnosticBag, out ForEachEnumeratorInfo.Builder reference)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Invalid comparison between Unknown and I4
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Invalid comparison between Unknown and I4
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Invalid comparison between Unknown and I4
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Invalid comparison between Unknown and I4
reference = default(ForEachEnumeratorInfo.Builder);
reference.IsAsync = flag;
TypeSymbol type2 = reference2.Type;
if ((object)type2 == null)
{
if (!ReportConstantNullCollectionExpr(reference2, bindingDiagnosticBag))
{
bindingDiagnosticBag.Add(ErrorCode.ERR_AnonMethGrpInForEach, ((SyntaxNode)expressionSyntax).Location, reference2.Display);
}
return EnumeratorResult.FailedAndReported;
}
if (reference2.ResultKind == LookupResultKind.NotAValue)
{
return EnumeratorResult.FailedAndReported;
}
if ((int)type2.Kind == 3 && flag)
{
bindingDiagnosticBag.Add(ErrorCode.ERR_BadDynamicAwaitForEach, ((SyntaxNode)expressionSyntax).Location);
return EnumeratorResult.FailedAndReported;
}
if ((int)type2.Kind == 1 || (int)type2.Kind == 3)
{
if (ReportConstantNullCollectionExpr(reference2, bindingDiagnosticBag))
{
return EnumeratorResult.FailedAndReported;
}
reference = GetDefaultEnumeratorInfo(syntax2, reference, bindingDiagnosticBag, type2);
return EnumeratorResult.Succeeded;
}
BoundExpression boundExpression = UnwrapCollectionExpressionIfNullable(reference2, bindingDiagnosticBag);
TypeSymbol type3 = boundExpression.Type;
if (SatisfiesGetEnumeratorPattern(syntax2, expressionSyntax, ref reference, boundExpression, flag, viaExtensionMethod: false, bindingDiagnosticBag))
{
reference2 = boundExpression;
if (ReportConstantNullCollectionExpr(reference2, bindingDiagnosticBag))
{
return EnumeratorResult.FailedAndReported;
}
return createPatternBasedEnumeratorResult(ref reference, boundExpression, flag, viaExtensionMethod: false, bindingDiagnosticBag);
}
if (!flag && IsIEnumerable(type3))
{
reference2 = boundExpression;
bindingDiagnosticBag.Add(ErrorCode.ERR_ForEachMissingMember, ((SyntaxNode)expressionSyntax).Location, type3, "GetEnumerator");
return EnumeratorResult.FailedAndReported;
}
if (flag && IsIAsyncEnumerable(type3))
{
reference2 = boundExpression;
bindingDiagnosticBag.Add(ErrorCode.ERR_AwaitForEachMissingMember, ((SyntaxNode)expressionSyntax).Location, type3, "GetAsyncEnumerator");
return EnumeratorResult.FailedAndReported;
}
EnumeratorResult enumeratorResult2 = SatisfiesIEnumerableInterfaces(expressionSyntax, ref reference, boundExpression, flag, bindingDiagnosticBag, type3);
if (enumeratorResult2 != EnumeratorResult.FailedNotReported)
{
reference2 = boundExpression;
return enumeratorResult2;
}
if (!flag && (int)type2.SpecialType == 20)
{
if (ReportConstantNullCollectionExpr(reference2, bindingDiagnosticBag))
{
return EnumeratorResult.FailedAndReported;
}
reference = GetDefaultEnumeratorInfo(syntax2, reference, bindingDiagnosticBag, type2);
return EnumeratorResult.Succeeded;
}
if (SatisfiesGetEnumeratorPattern(syntax2, expressionSyntax, ref reference, reference2, flag, viaExtensionMethod: true, bindingDiagnosticBag))
{
return createPatternBasedEnumeratorResult(ref reference, reference2, flag, viaExtensionMethod: true, bindingDiagnosticBag);
}
return EnumeratorResult.FailedNotReported;
}
}
private EnumeratorResult SatisfiesIEnumerableInterfaces(ExpressionSyntax collectionSyntax, ref ForEachEnumeratorInfo.Builder builder, BoundExpression collectionExpr, bool isAsync, BindingDiagnosticBag diagnostics, TypeSymbol unwrappedCollectionExprType)
{
if (!AllInterfacesContainsIEnumerable(collectionSyntax, ref builder, unwrappedCollectionExprType, isAsync, diagnostics, out var foundMultiple))
{
return EnumeratorResult.FailedNotReported;
}
if (ReportConstantNullCollectionExpr(collectionExpr, diagnostics))
{
return EnumeratorResult.FailedAndReported;
}
if (foundMultiple)
{
diagnostics.Add(isAsync ? ErrorCode.ERR_MultipleIAsyncEnumOfT : ErrorCode.ERR_MultipleIEnumOfT, ((SyntaxNode)collectionSyntax).Location, unwrappedCollectionExprType, isAsync ? Compilation.GetWellKnownType((WellKnownType)288) : Compilation.GetSpecialType((SpecialType)25));
return EnumeratorResult.FailedAndReported;
}
NamedTypeSymbol namedTypeSymbol = (NamedTypeSymbol)builder.CollectionType;
if (namedTypeSymbol.IsGenericType)
{
builder.ElementTypeWithAnnotations = namedTypeSymbol.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics.Single();
MethodSymbol methodSymbol;
if (isAsync)
{
methodSymbol = (MethodSymbol)GetWellKnownTypeMember(Compilation, (WellKnownMember)427, diagnostics, ((SyntaxNode)collectionSyntax).Location);
if ((object)methodSymbol != null && !methodSymbol.Parameters[0].IsOptional)
{
diagnostics.Add(ErrorCode.ERR_AwaitForEachMissingMember, ((SyntaxNode)collectionSyntax).Location, unwrappedCollectionExprType, "GetAsyncEnumerator");
return EnumeratorResult.FailedAndReported;
}
}
else
{
methodSymbol = (MethodSymbol)GetSpecialTypeMember((SpecialMember)89, diagnostics, (SyntaxNode)(object)collectionSyntax);
}
MethodSymbol methodSymbol2 = null;
if ((object)methodSymbol != null)
{
MethodSymbol methodSymbol3 = methodSymbol.AsMember(namedTypeSymbol);
TypeSymbol returnType = methodSymbol3.ReturnType;
builder.GetEnumeratorInfo = BindDefaultArguments(methodSymbol3, null, expanded: false, collectionExpr.Syntax, diagnostics, assertMissingParametersAreOptional: false);
MethodSymbol methodSymbol5;
if (isAsync)
{
MethodSymbol methodSymbol4 = (MethodSymbol)GetWellKnownTypeMember((WellKnownMember)428, diagnostics, ((SyntaxNode)collectionSyntax).Location);
if ((object)methodSymbol4 != null)
{
methodSymbol2 = methodSymbol4.AsMember((NamedTypeSymbol)returnType);
}
methodSymbol5 = (MethodSymbol)GetWellKnownTypeMember(Compilation, (WellKnownMember)429, diagnostics, ((SyntaxNode)collectionSyntax).Location);
}
else
{
methodSymbol5 = (MethodSymbol)GetSpecialTypeMember((SpecialMember)91, diagnostics, (SyntaxNode)(object)collectionSyntax);
}
if ((object)methodSymbol5 != null)
{
builder.CurrentPropertyGetter = methodSymbol5.AsMember((NamedTypeSymbol)returnType);
}
}
if (!isAsync)
{
methodSymbol2 = (MethodSymbol)GetSpecialTypeMember((SpecialMember)87, diagnostics, (SyntaxNode)(object)collectionSyntax);
}
if ((object)methodSymbol2 != null)
{
builder.MoveNextInfo = MethodArgumentInfo.CreateParameterlessMethod(methodSymbol2);
}
}
else
{
builder.GetEnumeratorInfo = GetParameterlessSpecialTypeMemberInfo((SpecialMember)84, (SyntaxNode)(object)collectionSyntax, diagnostics);
builder.CurrentPropertyGetter = (MethodSymbol)GetSpecialTypeMember((SpecialMember)86, diagnostics, (SyntaxNode)(object)collectionSyntax);
builder.MoveNextInfo = GetParameterlessSpecialTypeMemberInfo((SpecialMember)87, (SyntaxNode)(object)collectionSyntax, diagnostics);
builder.ElementTypeWithAnnotations = builder.CurrentPropertyGetter?.ReturnTypeWithAnnotations ?? TypeWithAnnotations.Create(GetSpecialType((SpecialType)1, diagnostics, (SyntaxNode)(object)collectionSyntax));
}
builder.NeedsDisposal = true;
return EnumeratorResult.Succeeded;
}
private bool ReportConstantNullCollectionExpr(BoundExpression collectionExpr, BindingDiagnosticBag diagnostics)
{
ConstantValue constantValueOpt = collectionExpr.ConstantValueOpt;
if (constantValueOpt != null && constantValueOpt.IsNull)
{
diagnostics.Add(ErrorCode.ERR_NullNotValid, collectionExpr.Syntax.Location);
return true;
}
return false;
}
private void GetDisposalInfoForEnumerator(SyntaxNode syntax, ref ForEachEnumeratorInfo.Builder builder, BoundExpression expr, bool isAsync, BindingDiagnosticBag diagnostics)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
TypeSymbol returnType = builder.GetEnumeratorInfo.Method.ReturnType;
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
MethodSymbol methodSymbol = null;
if (returnType.IsRefLikeType || isAsync)
{
BoundDisposableValuePlaceholder expr2 = new BoundDisposableValuePlaceholder(syntax, returnType);
methodSymbol = TryFindDisposePatternMethod(expr2, syntax, isAsync, BindingDiagnosticBag.Discarded);
if ((object)methodSymbol != null)
{
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(methodSymbol.ParameterCount);
ImmutableArray<int> argsToParamsOpt = default(ImmutableArray<int>);
bool expanded = methodSymbol.HasParamsParameter();
BindDefaultArguments(syntax, methodSymbol.Parameters, instance, null, ref argsToParamsOpt, out var defaultArguments, expanded, enableCallerInfo: true, diagnostics);
builder.NeedsDisposal = true;
builder.PatternDisposeInfo = new MethodArgumentInfo(methodSymbol, instance.ToImmutableAndFree(), argsToParamsOpt, defaultArguments, expanded);
if (!isAsync)
{
CheckFeatureAvailability(expr.Syntax, MessageID.IDS_FeatureDisposalPattern, diagnostics);
}
}
}
if (!returnType.IsRefLikeType && (object)methodSymbol == null)
{
if ((!returnType.IsSealed && !isAsync) || Conversions.ClassifyImplicitConversionFromType(returnType, isAsync ? Compilation.GetWellKnownType((WellKnownType)287) : Compilation.GetSpecialType((SpecialType)35), ref useSiteInfo).IsImplicit)
{
builder.NeedsDisposal = true;
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(syntax, useSiteInfo);
}
}
private ForEachEnumeratorInfo.Builder GetDefaultEnumeratorInfo(SyntaxNode syntax, ForEachEnumeratorInfo.Builder builder, BindingDiagnosticBag diagnostics, TypeSymbol collectionExprType)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Invalid comparison between Unknown and I4
builder.CollectionType = GetSpecialType((SpecialType)24, diagnostics, syntax);
if (collectionExprType.IsDynamic())
{
ForEachStatementSyntax obj = syntax as ForEachStatementSyntax;
builder.ElementTypeWithAnnotations = TypeWithAnnotations.Create((obj != null && obj.Type.IsVar) ? ((TypeSymbol)DynamicTypeSymbol.Instance) : ((TypeSymbol)GetSpecialType((SpecialType)1, diagnostics, syntax)));
}
else
{
builder.ElementTypeWithAnnotations = (((int)collectionExprType.SpecialType == 20) ? TypeWithAnnotations.Create(GetSpecialType((SpecialType)8, diagnostics, syntax)) : ((ArrayTypeSymbol)collectionExprType).ElementTypeWithAnnotations);
}
builder.GetEnumeratorInfo = GetParameterlessSpecialTypeMemberInfo((SpecialMember)84, syntax, diagnostics);
builder.CurrentPropertyGetter = (MethodSymbol)GetSpecialTypeMember((SpecialMember)86, diagnostics, syntax);
builder.MoveNextInfo = GetParameterlessSpecialTypeMemberInfo((SpecialMember)87, syntax, diagnostics);
builder.NeedsDisposal = true;
return builder;
}
private bool SatisfiesGetEnumeratorPattern(SyntaxNode syntax, ExpressionSyntax collectionSyntax, ref ForEachEnumeratorInfo.Builder builder, BoundExpression collectionExpr, bool isAsync, bool viaExtensionMethod, BindingDiagnosticBag diagnostics)
{
string methodName = (isAsync ? "GetAsyncEnumerator" : "GetEnumerator");
MethodArgumentInfo methodArgumentInfo;
if (viaExtensionMethod)
{
methodArgumentInfo = FindForEachPatternMethodViaExtension(syntax, collectionSyntax, collectionExpr, methodName, diagnostics);
}
else
{
LookupResult instance = LookupResult.GetInstance();
methodArgumentInfo = FindForEachPatternMethod(syntax, collectionSyntax, collectionExpr.Type, methodName, instance, warningsOnly: true, diagnostics, isAsync);
instance.Free();
}
builder.GetEnumeratorInfo = methodArgumentInfo;
return (object)methodArgumentInfo != null;
}
private MethodArgumentInfo FindForEachPatternMethod(SyntaxNode syntax, ExpressionSyntax collectionSyntax, TypeSymbol patternType, string methodName, LookupResult lookupResult, bool warningsOnly, BindingDiagnosticBag diagnostics, bool isAsync)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: 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_0065: Invalid comparison between Unknown and I4
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupMembersInType(lookupResult, patternType, methodName, 0, null, LookupOptions.Default, this, diagnose: false, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)collectionSyntax, useSiteInfo);
if (!lookupResult.IsMultiViable)
{
ReportPatternMemberLookupDiagnostics(collectionSyntax, lookupResult, patternType, methodName, warningsOnly, diagnostics);
return null;
}
ArrayBuilder<MethodSymbol> instance = ArrayBuilder<MethodSymbol>.GetInstance();
Enumerator<Symbol> enumerator = lookupResult.Symbols.GetEnumerator();
while (enumerator.MoveNext())
{
Symbol current = enumerator.Current;
if ((int)current.Kind != 9)
{
instance.Free();
if (warningsOnly)
{
ReportEnumerableWarning(collectionSyntax, diagnostics, patternType, current);
}
return null;
}
if (((MethodSymbol)current).ParameterCount == 0 || isAsync)
{
instance.Add((MethodSymbol)current);
}
}
MethodArgumentInfo result = PerformForEachPatternOverloadResolution(syntax, collectionSyntax, patternType, instance, warningsOnly, diagnostics, isAsync);
instance.Free();
return result;
}
private MethodArgumentInfo PerformForEachPatternOverloadResolution(SyntaxNode syntax, ExpressionSyntax collectionSyntax, TypeSymbol patternType, ArrayBuilder<MethodSymbol> candidateMethods, bool warningsOnly, BindingDiagnosticBag diagnostics, bool isAsync)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Invalid comparison between Unknown and I4
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
ArrayBuilder<TypeWithAnnotations> instance2 = ArrayBuilder<TypeWithAnnotations>.GetInstance();
OverloadResolutionResult<MethodSymbol> instance3 = OverloadResolutionResult<MethodSymbol>.GetInstance();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
BoundImplicitReceiver receiver = new BoundImplicitReceiver((SyntaxNode)(object)collectionSyntax, patternType);
OverloadResolution.MethodInvocationOverloadResolution(candidateMethods, instance2, receiver, instance, instance3, ref useSiteInfo, isMethodGroupConversion: false, allowRefOmittedArguments: false, inferWithDynamic: false, allowUnexpandedForm: true, (RefKind)0, null, isFunctionPointerResolution: false, isExtensionMethodResolution: false, default(CallingConventionInfo));
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)collectionSyntax, useSiteInfo);
MethodSymbol methodSymbol = null;
MethodArgumentInfo result = null;
if (instance3.Succeeded)
{
methodSymbol = instance3.ValidResult.Member;
if (methodSymbol.IsStatic || (int)methodSymbol.DeclaredAccessibility != 6)
{
if (warningsOnly)
{
MessageID id = (isAsync ? MessageID.IDS_FeatureAsyncStreams : MessageID.IDS_Collection);
diagnostics.Add(ErrorCode.WRN_PatternNotPublicOrNotInstance, ((SyntaxNode)collectionSyntax).Location, patternType, id.Localize(), methodSymbol);
}
methodSymbol = null;
}
else if (methodSymbol.CallsAreOmitted(syntax.SyntaxTree))
{
methodSymbol = null;
}
else
{
ImmutableArray<int> argsToParamsOpt = instance3.ValidResult.Result.ArgsToParamsOpt;
bool expanded = instance3.ValidResult.Result.Kind == MemberResolutionKind.ApplicableInExpandedForm;
BindDefaultArguments(syntax, methodSymbol.Parameters, instance.Arguments, instance.RefKinds, ref argsToParamsOpt, out var defaultArguments, expanded, enableCallerInfo: true, diagnostics);
result = new MethodArgumentInfo(methodSymbol, instance.Arguments.ToImmutable(), argsToParamsOpt, defaultArguments, expanded);
}
}
else
{
ImmutableArray<MethodSymbol> allApplicableMembers = instance3.GetAllApplicableMembers();
if (allApplicableMembers.Length > 1 && warningsOnly)
{
diagnostics.Add(ErrorCode.WRN_PatternIsAmbiguous, ((SyntaxNode)collectionSyntax).Location, patternType, MessageID.IDS_Collection.Localize(), allApplicableMembers[0], allApplicableMembers[1]);
}
}
instance3.Free();
instance.Free();
instance2.Free();
return result;
}
private MethodArgumentInfo FindForEachPatternMethodViaExtension(SyntaxNode syntax, ExpressionSyntax collectionSyntax, BoundExpression collectionExpr, string methodName, BindingDiagnosticBag diagnostics)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
AnalyzedArguments instance = AnalyzedArguments.GetInstance();
MethodGroupResolution methodGroupResolution = BindExtensionMethod((SyntaxNode)(object)collectionSyntax, methodName, instance, collectionExpr, default(ImmutableArray<TypeWithAnnotations>), isMethodGroupConversion: false, (RefKind)0, null, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(methodGroupResolution.Diagnostics, false);
OverloadResolutionResult<MethodSymbol> overloadResolutionResult = methodGroupResolution.OverloadResolutionResult;
if (overloadResolutionResult != null && overloadResolutionResult.Succeeded)
{
MethodSymbol member = overloadResolutionResult.ValidResult.Member;
if (member.CallsAreOmitted(syntax.SyntaxTree))
{
methodGroupResolution.Free();
instance.Free();
return null;
}
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
Conversion conversion = Conversions.ClassifyConversionFromExpression(collectionExpr, member.Parameters[0].Type, CheckOverflowAtRuntime, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(syntax, useSiteInfo);
collectionExpr = new BoundConversion(collectionExpr.Syntax, collectionExpr, conversion, CheckOverflowAtRuntime, explicitCastInCode: false, null, null, member.Parameters[0].Type);
MethodArgumentInfo result = BindDefaultArguments(member, collectionExpr, overloadResolutionResult.ValidResult.Result.Kind == MemberResolutionKind.ApplicableInExpandedForm, collectionExpr.Syntax, diagnostics);
methodGroupResolution.Free();
instance.Free();
return result;
}
ImmutableArray<MethodSymbol>? immutableArray = overloadResolutionResult?.GetAllApplicableMembers();
if (immutableArray.HasValue)
{
ImmutableArray<MethodSymbol> valueOrDefault = immutableArray.GetValueOrDefault();
if (valueOrDefault.Length > 1)
{
diagnostics.Add(ErrorCode.WRN_PatternIsAmbiguous, ((SyntaxNode)collectionSyntax).Location, collectionExpr.Type, MessageID.IDS_Collection.Localize(), valueOrDefault[0], valueOrDefault[1]);
goto IL_01e3;
}
}
overloadResolutionResult?.ReportDiagnostics(this, ((SyntaxNode)collectionSyntax).Location, (SyntaxNode)(object)collectionSyntax, diagnostics, methodName, null, (SyntaxNode)(object)collectionSyntax, methodGroupResolution.AnalyzedArguments, methodGroupResolution.MethodGroup.Methods.ToImmutable(), null, null);
goto IL_01e3;
IL_01e3:
methodGroupResolution.Free();
instance.Free();
return null;
}
private bool SatisfiesForEachPattern(SyntaxNode syntax, ExpressionSyntax collectionSyntax, ref ForEachEnumeratorInfo.Builder builder, bool isAsync, BindingDiagnosticBag diagnostics)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected I4, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Invalid comparison between Unknown and I4
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Invalid comparison between Unknown and I4
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Invalid comparison between Unknown and I4
TypeSymbol returnType = builder.GetEnumeratorInfo.Method.ReturnType;
TypeKind typeKind = returnType.TypeKind;
switch (typeKind - 2)
{
case 10:
throw ExceptionUtilities.UnexpectedValue((object)returnType.TypeKind);
default:
return false;
case 0:
case 2:
case 5:
case 8:
case 9:
{
LookupResult instance = LookupResult.GetInstance();
try
{
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupMembersInType(instance, returnType, "Current", 0, null, LookupOptions.Default, this, diagnose: false, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)collectionSyntax, useSiteInfo);
useSiteInfo._002Ector(useSiteInfo);
if (!instance.IsSingleViable)
{
ReportPatternMemberLookupDiagnostics(collectionSyntax, instance, returnType, "Current", warningsOnly: false, diagnostics);
return false;
}
Symbol singleSymbolOrDefault = instance.SingleSymbolOrDefault;
if (singleSymbolOrDefault.IsStatic || (int)singleSymbolOrDefault.DeclaredAccessibility != 6 || (int)singleSymbolOrDefault.Kind != 15)
{
return false;
}
MethodSymbol ownOrInheritedGetMethod = ((PropertySymbol)singleSymbolOrDefault).GetOwnOrInheritedGetMethod();
if ((object)ownOrInheritedGetMethod == null)
{
return false;
}
bool num = IsAccessible(ownOrInheritedGetMethod, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)collectionSyntax, useSiteInfo);
if (!num)
{
return false;
}
builder.CurrentPropertyGetter = ownOrInheritedGetMethod;
instance.Clear();
MethodArgumentInfo methodArgumentInfo = FindForEachPatternMethod(syntax, collectionSyntax, returnType, isAsync ? "MoveNextAsync" : "MoveNext", instance, warningsOnly: false, diagnostics, isAsync);
if ((object)methodArgumentInfo == null || methodArgumentInfo.Method.IsStatic || (int)methodArgumentInfo.Method.DeclaredAccessibility != 6 || IsInvalidMoveNextMethod(methodArgumentInfo.Method, isAsync))
{
return false;
}
builder.MoveNextInfo = methodArgumentInfo;
return true;
}
finally
{
instance.Free();
}
}
}
}
private bool IsInvalidMoveNextMethod(MethodSymbol moveNextMethodCandidate, bool isAsync)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
if (isAsync)
{
return false;
}
return (int)moveNextMethodCandidate.OriginalDefinition.ReturnType.SpecialType != 7;
}
private void ReportEnumerableWarning(ExpressionSyntax collectionSyntax, BindingDiagnosticBag diagnostics, TypeSymbol enumeratorType, Symbol patternMemberCandidate)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
if (IsAccessible(patternMemberCandidate, ref useSiteInfo))
{
diagnostics.Add(ErrorCode.WRN_PatternBadSignature, ((SyntaxNode)collectionSyntax).Location, enumeratorType, MessageID.IDS_Collection.Localize(), patternMemberCandidate);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)collectionSyntax, useSiteInfo);
}
internal static bool IsIEnumerable(TypeSymbol type)
{
//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)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
SpecialType specialType = type.OriginalDefinition.SpecialType;
if (specialType - 24 <= 1)
{
return true;
}
return false;
}
private bool IsIAsyncEnumerable(TypeSymbol type)
{
return type.OriginalDefinition.Equals(Compilation.GetWellKnownType((WellKnownType)288));
}
private bool AllInterfacesContainsIEnumerable(ExpressionSyntax collectionSyntax, ref ForEachEnumeratorInfo.Builder builder, TypeSymbol type, bool isAsync, BindingDiagnosticBag diagnostics, out bool foundMultiple)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
NamedTypeSymbol namedTypeSymbol = GetIEnumerableOfT(type, isAsync, Compilation, ref useSiteInfo, out foundMultiple);
if ((object)namedTypeSymbol == null || !IsAccessible(namedTypeSymbol, ref useSiteInfo))
{
namedTypeSymbol = null;
if (!isAsync)
{
NamedTypeSymbol specialType = Compilation.GetSpecialType((SpecialType)24);
if ((object)specialType != null && Conversions.ClassifyImplicitConversionFromType(type, specialType, ref useSiteInfo).IsImplicit)
{
namedTypeSymbol = specialType;
}
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)collectionSyntax, useSiteInfo);
builder.CollectionType = namedTypeSymbol;
return (object)namedTypeSymbol != null;
}
internal static NamedTypeSymbol GetIEnumerableOfT(TypeSymbol type, bool isAsync, CSharpCompilation compilation, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out bool foundMultiple)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
NamedTypeSymbol result = null;
foundMultiple = false;
if ((int)type.TypeKind == 11)
{
TypeParameterSymbol typeParameterSymbol = (TypeParameterSymbol)type;
GetIEnumerableOfT(ImmutableArrayExtensions.Concat<NamedTypeSymbol>(typeParameterSymbol.EffectiveBaseClass(ref useSiteInfo).AllInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteInfo), typeParameterSymbol.AllEffectiveInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteInfo)), isAsync, compilation, ref result, ref foundMultiple);
}
else
{
GetIEnumerableOfT(type.AllInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteInfo), isAsync, compilation, ref result, ref foundMultiple);
}
return result;
}
private static void GetIEnumerableOfT(ImmutableArray<NamedTypeSymbol> interfaces, bool isAsync, CSharpCompilation compilation, ref NamedTypeSymbol result, ref bool foundMultiple)
{
if (foundMultiple)
{
return;
}
interfaces = MethodTypeInferrer.ModuloReferenceTypeNullabilityDifferences(interfaces, (VarianceKind)2);
ImmutableArray<NamedTypeSymbol>.Enumerator enumerator = interfaces.GetEnumerator();
while (enumerator.MoveNext())
{
NamedTypeSymbol current = enumerator.Current;
if (IsIEnumerableT(current.OriginalDefinition, isAsync, compilation))
{
if ((object)result != null && !TypeSymbol.Equals(current, result, (TypeCompareKind)4))
{
foundMultiple = true;
break;
}
result = current;
}
}
}
internal static bool IsIEnumerableT(TypeSymbol type, bool isAsync, CSharpCompilation compilation)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Invalid comparison between Unknown and I4
if (isAsync)
{
return type.Equals(compilation.GetWellKnownType((WellKnownType)288));
}
return (int)type.SpecialType == 25;
}
private void ReportPatternMemberLookupDiagnostics(ExpressionSyntax collectionSyntax, LookupResult lookupResult, TypeSymbol patternType, string memberName, bool warningsOnly, BindingDiagnosticBag diagnostics)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
if (lookupResult.Symbols.Any())
{
if (warningsOnly)
{
ReportEnumerableWarning(collectionSyntax, diagnostics, patternType, lookupResult.Symbols.First());
return;
}
lookupResult.Clear();
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
LookupMembersInType(lookupResult, patternType, memberName, 0, null, LookupOptions.Default, this, diagnose: true, ref useSiteInfo);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)collectionSyntax, useSiteInfo);
if (lookupResult.Error != null)
{
diagnostics.Add(lookupResult.Error, ((SyntaxNode)collectionSyntax).Location);
}
}
else if (!warningsOnly)
{
diagnostics.Add(ErrorCode.ERR_NoSuchMember, ((SyntaxNode)collectionSyntax).Location, patternType, memberName);
}
}
private MethodArgumentInfo GetParameterlessSpecialTypeMemberInfo(SpecialMember member, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
MethodSymbol methodSymbol = (MethodSymbol)GetSpecialTypeMember(member, diagnostics, syntax);
if ((object)methodSymbol == null)
{
return null;
}
return MethodArgumentInfo.CreateParameterlessMethod(methodSymbol);
}
private MethodArgumentInfo BindDefaultArguments(MethodSymbol method, BoundExpression extensionReceiverOpt, bool expanded, SyntaxNode syntax, BindingDiagnosticBag diagnostics, bool assertMissingParametersAreOptional = true)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
if (method.ParameterCount == 0)
{
return MethodArgumentInfo.CreateParameterlessMethod(method);
}
ArrayBuilder<BoundExpression> instance = ArrayBuilder<BoundExpression>.GetInstance(method.ParameterCount);
if (method.IsExtensionMethod)
{
instance.Add(extensionReceiverOpt);
}
ImmutableArray<int> argsToParamsOpt = default(ImmutableArray<int>);
BindDefaultArguments(syntax, method.Parameters, instance, null, ref argsToParamsOpt, out var defaultArguments, expanded, enableCallerInfo: true, diagnostics, assertMissingParametersAreOptional);
return new MethodArgumentInfo(method, instance.ToImmutableAndFree(), argsToParamsOpt, defaultArguments, expanded);
}
}