Class OverloadResolution
- Namespace
- ICSharpCode.Decompiler.CSharp.Resolver
- Assembly
- ICSharpCode.Decompiler.dll
C# overload resolution (C# 4.0 spec: §7.5).
public class OverloadResolution
- Inheritance
-
OverloadResolution
- Inherited Members
Constructors
OverloadResolution(ICompilation, ResolveResult[], string[], IType[], CSharpConversions)
public OverloadResolution(ICompilation compilation, ResolveResult[] arguments, string[] argumentNames = null, IType[] typeArguments = null, CSharpConversions conversions = null)
Parameters
compilation
ICompilationarguments
ResolveResult[]argumentNames
string[]typeArguments
IType[]conversions
CSharpConversions
Properties
AllowExpandingParams
Gets/Sets whether expanding 'params' into individual elements is allowed. The default value is true.
public bool AllowExpandingParams { get; set; }
Property Value
AllowImplicitIn
Gets/Sets whether a value argument can be passed to an in
reference parameter.
public bool AllowImplicitIn { get; set; }
Property Value
AllowOptionalParameters
Gets/Sets whether optional parameters may be left at their default value. The default value is true. If this property is set to false, optional parameters will be treated like regular parameters.
public bool AllowOptionalParameters { get; set; }
Property Value
ArgumentConversions
Gets the implicit conversions that are being applied to the arguments.
public IList<Conversion> ArgumentConversions { get; }
Property Value
Arguments
Gets the arguments for which this OverloadResolution instance was created.
public IList<ResolveResult> Arguments { get; }
Property Value
BestCandidate
public IParameterizedMember BestCandidate { get; }
Property Value
BestCandidateAmbiguousWith
public IParameterizedMember BestCandidateAmbiguousWith { get; }
Property Value
BestCandidateErrors
Returns the errors that apply to the best candidate. This includes additional errors that do not affect applicability (e.g. AmbiguousMatch, MethodConstraintsNotSatisfied)
public OverloadResolutionErrors BestCandidateErrors { get; }
Property Value
BestCandidateIsExpandedForm
public bool BestCandidateIsExpandedForm { get; }
Property Value
CheckForOverflow
Gets/Sets whether ConversionResolveResults created by this OverloadResolution instance apply overflow checking. The default value is false.
public bool CheckForOverflow { get; set; }
Property Value
FoundApplicableCandidate
public bool FoundApplicableCandidate { get; }
Property Value
InferredTypeArguments
public IReadOnlyList<IType> InferredTypeArguments { get; }
Property Value
IsAmbiguous
public bool IsAmbiguous { get; }
Property Value
IsExtensionMethodInvocation
Gets/Sets whether the methods are extension methods that are being called using extension method syntax.
public bool IsExtensionMethodInvocation { get; set; }
Property Value
Remarks
Setting this property to true restricts the possible conversions on the first argument to implicit identity, reference, or boxing conversions.
Methods
AddCandidate(IParameterizedMember)
Adds a candidate to overload resolution.
public OverloadResolutionErrors AddCandidate(IParameterizedMember member)
Parameters
member
IParameterizedMemberThe candidate member to add.
Returns
- OverloadResolutionErrors
The errors that prevent the member from being applicable, if any. Note: this method does not return errors that do not affect applicability.
AddCandidate(IParameterizedMember, OverloadResolutionErrors)
Adds a candidate to overload resolution.
public OverloadResolutionErrors AddCandidate(IParameterizedMember member, OverloadResolutionErrors additionalErrors)
Parameters
member
IParameterizedMemberThe candidate member to add.
additionalErrors
OverloadResolutionErrorsAdditional errors that apply to the candidate. This is used to represent errors during member lookup (e.g. OverloadResolutionErrors.Inaccessible) in overload resolution.
Returns
- OverloadResolutionErrors
The errors that prevent the member from being applicable, if any. Note: this method does not return errors that do not affect applicability.
AddMethodLists(IReadOnlyList<MethodListWithDeclaringType>)
Adds all candidates from the method lists.
This method implements the logic that causes applicable methods in derived types to hide all methods in base types.
public void AddMethodLists(IReadOnlyList<MethodListWithDeclaringType> methodLists)
Parameters
methodLists
IReadOnlyList<MethodListWithDeclaringType>The methods, grouped by declaring type. Base types must come first in the list.
CreateResolveResult(ResolveResult, IList<ResolveResult>, IType)
Creates a ResolveResult representing the result of overload resolution.
public CSharpInvocationResolveResult CreateResolveResult(ResolveResult targetResolveResult, IList<ResolveResult> initializerStatements = null, IType returnTypeOverride = null)
Parameters
targetResolveResult
ResolveResultThe target expression of the call. May be
null
for static methods/constructors.initializerStatements
IList<ResolveResult>Statements for Objects/Collections initializer. InitializerStatements
returnTypeOverride
ITypeIf not null, use this instead of the ReturnType of the member as the type of the created resolve result.
Returns
GetArgumentToParameterMap()
Gets an array that maps argument indices to parameter indices. For arguments that could not be mapped to any parameter, the value will be -1.
parameterIndex = GetArgumentToParameterMap()[argumentIndex]
public IReadOnlyList<int> GetArgumentToParameterMap()
Returns
GetArgumentsWithConversions()
Returns the arguments for the method call in the order they were provided (not in the order of the parameters). Arguments are wrapped in a ConversionResolveResult if an implicit conversion is being applied to them when calling the method.
public IList<ResolveResult> GetArgumentsWithConversions()
Returns
GetArgumentsWithConversionsAndNames()
Returns the arguments for the method call in the order they were provided (not in the order of the parameters). Arguments are wrapped in a ConversionResolveResult if an implicit conversion is being applied to them when calling the method. For arguments where an explicit argument name was provided, the argument will be wrapped in a NamedArgumentResolveResult.
public IList<ResolveResult> GetArgumentsWithConversionsAndNames()
Returns
GetBestCandidateWithSubstitutedTypeArguments()
public IParameterizedMember GetBestCandidateWithSubstitutedTypeArguments()
Returns
IsApplicable(OverloadResolutionErrors)
Returns whether a candidate with the given errors is still considered to be applicable.
public static bool IsApplicable(OverloadResolutionErrors errors)
Parameters
errors
OverloadResolutionErrors
Returns
ValidateConstraints(ITypeParameter, IType, TypeVisitor)
Validates whether the given type argument satisfies the constraints for the given type parameter.
public static bool ValidateConstraints(ITypeParameter typeParameter, IType typeArgument, TypeVisitor substitution = null)
Parameters
typeParameter
ITypeParameterThe type parameter.
typeArgument
ITypeThe type argument.
substitution
TypeVisitorThe substitution that defines how type parameters are replaced with type arguments. The substitution is used to check constraints that depend on other type parameters (or recursively on the same type parameter). May be null if no substitution should be used.
Returns
- bool
True if the constraints are satisfied; false otherwise.