当前位置: 首页>>代码示例>>C#>>正文


C# IMethodDefinition类代码示例

本文整理汇总了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;
 }
开发者ID:buchu73,项目名称:visualmutator,代码行数:7,代码来源:MutationResult.cs

示例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;
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:25,代码来源:ParameterNamesCannotChange.cs

示例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;
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:33,代码来源:DelegatesMustMatch.cs

示例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);
        }
开发者ID:lishibo,项目名称:buildtools,代码行数:27,代码来源:CSDeclarationWriter.Methods.cs

示例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);

        }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:7,代码来源:EMM_ModiferMethodChange.cs

示例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;
    }
开发者ID:xornand,项目名称:cci,代码行数:26,代码来源:Utils.cs

示例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);
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:7,代码来源:CannotRemoveGenerics.cs

示例8: AnalyzeCallOperations

 private static void AnalyzeCallOperations(IMethodDefinition method)
 {
     foreach (var operation in getCallOperations(method))
     {
         Console.WriteLine("\t\t" + getTypeOfMethod(operation));
     }
 }
开发者ID:halllo,项目名称:MTSS12,代码行数:7,代码来源:Program.cs

示例9: Of

 public static int Of(IMethodDefinition method, PdbReader pdb, IMetadataHost host)
 {
     if (method.HasOperations())
         return method.CalculateStatements(pdb, host);
     else
         return 0;
 }
开发者ID:cessor,项目名称:MTSS12,代码行数:7,代码来源:NumberOfStatements.cs

示例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();
            }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:7,代码来源:OMR_OverloadingMethodContentsChange.cs

示例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);
        }
开发者ID:lishibo,项目名称:buildtools,代码行数:27,代码来源:CSDeclarationWriter.Methods.cs

示例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;
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:28,代码来源:ParameterTypeCannotChange.cs

示例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;
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:10,代码来源:MethodHelper.cs

示例14: Of

 public static int Of(IMethodDefinition method, PdbReader pdb, IMetadataHost host)
 {
     if (method.HasOperations())
         return method.CalculateCyclomaticComplexity(pdb, host);
     else
         return 0;
 }
开发者ID:halllo,项目名称:MTSS12,代码行数:7,代码来源:CyclomaticComplexityOfAst.cs

示例15: Of

 public static IEnumerable<string> Of(IMethodDefinition method)
 {
     return Enumerable.Empty<string>()
         .Union(method.ReturnTypes())
         .Union(method.ParameterTypes())
         .Union(method.TypesOfGenericsConstraints())
         .ToList();
 }
开发者ID:halllo,项目名称:MTSS12,代码行数:8,代码来源:TypeDependenciesOfSignature.cs


注:本文中的IMethodDefinition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。