本文整理汇总了C#中IMethodDefinition类的典型用法代码示例。如果您正苦于以下问题:C# IMethodDefinition类的具体用法?C# IMethodDefinition怎么用?C# IMethodDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMethodDefinition类属于命名空间,在下文中一共展示了IMethodDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MutationResult
public MutationResult(Mutant mutant, ICciModuleSource mutatedModules, List<CciModuleSource> old, IMethodDefinition methodMutated)
{
_mutant = mutant;
MutatedModules = mutatedModules;
Old = old;
MethodMutated = methodMutated;
}
示例2: ParamNamesMatch
private bool ParamNamesMatch(IDifferences differences, IMethodDefinition implMethod, IMethodDefinition contractMethod)
{
int paramCount = implMethod.ParameterCount;
Contract.Assert(paramCount == contractMethod.ParameterCount);
IParameterDefinition[] implParams = implMethod.Parameters.ToArray();
IParameterDefinition[] contractParams = contractMethod.Parameters.ToArray();
bool match = true;
for (int i = 0; i < paramCount; i++)
{
IParameterDefinition implParam = implParams[i];
IParameterDefinition contractParam = contractParams[i];
if (!implParam.Name.Value.Equals(contractParam.Name.Value))
{
differences.AddIncompatibleDifference(this,
"Parameter name on member '{0}' is '{1}' in the implementation but '{2}' in the contract.",
implMethod.FullName(), implParam.Name.Value, contractParam.Name.Value);
match = false;
}
}
return match;
}
示例3: ParamNamesAndTypesMatch
private bool ParamNamesAndTypesMatch(IDifferences differences, IMethodDefinition implMethod, IMethodDefinition contractMethod)
{
int paramCount = implMethod.ParameterCount;
Contract.Assert(paramCount == contractMethod.ParameterCount);
IParameterDefinition[] implParams = implMethod.Parameters.ToArray();
IParameterDefinition[] contractParams = contractMethod.Parameters.ToArray();
bool match = true;
for (int i = 0; i < paramCount; i++)
{
IParameterDefinition implParam = implParams[i];
IParameterDefinition contractParam = contractParams[i];
if (!implParam.Name.Value.Equals(contractParam.Name.Value))
{
differences.AddIncompatibleDifference("DelegateParamNameMustMatch",
"Parameter name on delegate '{0}' is '{1}' in the implementation but '{2}' in the contract.",
implMethod.ContainingType.FullName(), implParam.Name.Value, contractParam.Name.Value);
match = false;
}
if (!_typeComparer.Equals(implParam.Type, contractParam.Type))
{
differences.AddTypeMismatchDifference("DelegateParamTypeMustMatch", implParam.Type, contractParam.Type,
"Type for parameter '{0}' on delegate '{1}' is '{2}' in the implementation but '{3}' in the contract.",
implParam.Name.Value, implMethod.ContainingType.FullName(), implParam.Type.FullName(), contractParam.Type.FullName());
match = false;
}
}
return match;
}
示例4: WriteMethodDefinition
private void WriteMethodDefinition(IMethodDefinition method)
{
if (method.IsPropertyOrEventAccessor())
return;
if (method.IsDestructor())
{
WriteDestructor(method);
return;
}
string name = method.GetMethodName();
WriteMethodPseudoCustomAttributes(method);
WriteAttributes(method.Attributes);
WriteAttributes(method.SecurityAttributes);
if (!method.ContainingTypeDefinition.IsInterface)
{
if (!method.IsExplicitInterfaceMethod()) WriteVisibility(method.Visibility);
WriteMethodModifiers(method);
}
WriteInterfaceMethodModifiers(method);
WriteMethodDefinitionSignature(method, name);
WriteMethodBody(method);
}
示例5: IsPropertyModifier
public static bool IsPropertyModifier(IMethodDefinition method)
{
return method.IsSpecialName && method.ContainingTypeDefinition
.Properties.Any(p => p.Setter != null
&& p.Setter.Name.UniqueKey == method.Name.UniqueKey);
}
示例6: GetHiddenBaseClassMethod
private static IMethodDefinition GetHiddenBaseClassMethod(IMethodDefinition derivedClassMethod, ITypeDefinition baseClass) {
Contract.Requires(derivedClassMethod != null);
Contract.Requires(baseClass != null);
foreach (ITypeDefinitionMember baseMember in baseClass.GetMembersNamed(derivedClassMethod.Name, false)) {
IMethodDefinition/*?*/ baseMethod = baseMember as IMethodDefinition;
if (baseMethod == null) continue;
if (baseMethod.Visibility == TypeMemberVisibility.Private) continue;
if ((baseMethod.Visibility == TypeMemberVisibility.Assembly || baseMethod.Visibility == TypeMemberVisibility.FamilyAndAssembly) &&
!UnitHelper.UnitsAreEquivalent(TypeHelper.GetDefiningUnit(derivedClassMethod.ContainingTypeDefinition), TypeHelper.GetDefiningUnit(baseClass)))
continue;
if (!derivedClassMethod.IsHiddenBySignature) return baseMethod;
if (derivedClassMethod.IsGeneric || baseMethod.IsGeneric) {
if (derivedClassMethod.GenericParameterCount == baseMethod.GenericParameterCount &&
IteratorHelper.EnumerablesAreEqual(((ISignature)derivedClassMethod).Parameters, ((ISignature)baseMethod).Parameters, MemberHelper.GenericMethodParameterEqualityComparer))
return baseMethod;
} else if (IteratorHelper.EnumerablesAreEqual(((ISignature)derivedClassMethod).Parameters, ((ISignature)baseMethod).Parameters, MemberHelper.ParameterInformationComparer))
return baseMethod;
}
var bases = baseClass.IsInterface ? baseClass.Interfaces : baseClass.BaseClasses;
foreach (ITypeReference baseClassReference in bases) {
IMethodDefinition overriddenMethod = GetHiddenBaseClassMethod(derivedClassMethod, baseClassReference.ResolvedType);
if (!(overriddenMethod is Dummy)) return overriddenMethod;
}
return Dummy.MethodDefinition;
}
示例7: Diff
private DifferenceType Diff(IDifferences differences, IMethodDefinition implMethod, IMethodDefinition contractMethod)
{
if (implMethod == null || contractMethod == null)
return DifferenceType.Unknown;
return DiffConstraints(differences, implMethod, implMethod.GenericParameters, contractMethod.GenericParameters);
}
示例8: AnalyzeCallOperations
private static void AnalyzeCallOperations(IMethodDefinition method)
{
foreach (var operation in getCallOperations(method))
{
Console.WriteLine("\t\t" + getTypeOfMethod(operation));
}
}
示例9: Of
public static int Of(IMethodDefinition method, PdbReader pdb, IMetadataHost host)
{
if (method.HasOperations())
return method.CalculateStatements(pdb, host);
else
return 0;
}
示例10: FindCandidateMethods
private List<IMethodDefinition> FindCandidateMethods(IMethodDefinition method)
{
var methodsInThisType = method.ContainingTypeDefinition.Methods
.Where(m => m != method && m.Name.Value == method.Name.Value);
return methodsInThisType.ToList();
}
示例11: WriteMethodDefinitionSignature
private void WriteMethodDefinitionSignature(IMethodDefinition method, string name)
{
bool isOperator = method.IsConversionOperator();
if (!isOperator && !method.IsConstructor)
{
WriteAttributes(method.ReturnValueAttributes, true);
// We are ignoring custom modifiers right now, we might need to add them later.
WriteTypeName(method.Type, isDynamic: IsDynamic(method.ReturnValueAttributes));
}
WriteIdentifier(name);
if (isOperator)
{
WriteSpace();
WriteTypeName(method.Type);
}
Contract.Assert(!(method is IGenericMethodInstance), "Currently don't support generic method instances");
if (method.IsGeneric)
WriteGenericParameters(method.GenericParameters);
WriteParameters(method.Parameters, extensionMethod: method.IsExtensionMethod(), acceptsExtraArguments: method.AcceptsExtraArguments);
if (method.IsGeneric && !method.IsOverride() && !method.IsExplicitInterfaceMethod())
WriteGenericContraints(method.GenericParameters);
}
示例12: FindBestMatch
private IMethodDefinition FindBestMatch(IMethodDefinition matchMethod, TypeMapping mapping, int typeIndex, int memberIndex)
{
// No matches if we don't have a matching type.
if (mapping[typeIndex] == null)
return null;
foreach (IMethodDefinition method in mapping[typeIndex].Methods)
{
if (method.Name.Value != matchMethod.Name.Value) continue;
if (method.ParameterCount != matchMethod.ParameterCount) continue;
if (method.IsGeneric && matchMethod.IsGeneric &&
method.GenericParameterCount != matchMethod.GenericParameterCount)
continue;
MemberMapping member = mapping.FindMember(method);
// It is possible to find a match that was filtered at the mapping layer
if (member == null) continue;
// If the other member also doesn't have a match then this is our best match
if (member[memberIndex] == null)
return method;
}
return null;
}
示例13: Unspecialize
/// <summary>
/// Returns the unspecialized version of the given method reference.
/// </summary>
public static IMethodReference Unspecialize(IMethodDefinition method) {
var smd = method as ISpecializedMethodDefinition;
if (smd != null) return smd.UnspecializedVersion;
var gmi = method as IGenericMethodInstance;
if (gmi != null) return gmi.GenericMethod;
return method;
}
示例14: Of
public static int Of(IMethodDefinition method, PdbReader pdb, IMetadataHost host)
{
if (method.HasOperations())
return method.CalculateCyclomaticComplexity(pdb, host);
else
return 0;
}
示例15: Of
public static IEnumerable<string> Of(IMethodDefinition method)
{
return Enumerable.Empty<string>()
.Union(method.ReturnTypes())
.Union(method.ParameterTypes())
.Union(method.TypesOfGenericsConstraints())
.ToList();
}