• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IMethodDefinition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IMethodDefinition的典型用法代码示例。如果您正苦于以下问题:C# IMethodDefinition类的具体用法?C# IMethodDefinition怎么用?C# IMethodDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IMethodDefinition类属于命名空间,在下文中一共展示了IMethodDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: WriteDestructor

 private void WriteDestructor(IMethodDefinition method)
 {
     WriteSymbol("~");
     WriteIdentifier(((INamedEntity)method.ContainingTypeDefinition).Name);
     WriteSymbol("(");
     WriteSymbol(")", false);
     WriteEmptyBody();
 }
开发者ID:pgavlin,项目名称:ApiTools,代码行数:8,代码来源:CSDeclarationWriter.Methods.cs


示例17: AddAlternativeInvocation

        private void AddAlternativeInvocation(BlockStatement block,
            IMethodDefinition fakeMethod, IMethodReference originalCall)
        {
            var context = new ReplacementMethodConstructionContext(host, originalCall, fakeMethod, block, log, null);
            var methodBuilder = context.GetMethodBuilder();

            methodBuilder.BuildMethod();
        }
开发者ID:jamarchist,项目名称:SharpMock,代码行数:8,代码来源:AddInterceptionTargetsToAssembly.cs


示例18: ClosureFinder

 /// <summary>
 /// 
 /// </summary>
 /// <param name="method"></param>
 /// <param name="host"></param>
 internal ClosureFinder(IMethodDefinition method, IMetadataHost host) {
   this.method = method;
   this.fieldForCapturedLocalOrParameter = new Dictionary<object, BoundField>();
   this.host = host;
   this.nameTable = host.NameTable;
   this.counter = 0;
   this.classList.Add((INamedTypeDefinition)method.ContainingTypeDefinition);
 }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:13,代码来源:CapturedLocalOrArgumentFinder.cs


示例19: MutationResult

 public MutationResult(Mutant mutant, ICciModuleSource mutatedModules, List<CciModuleSource> old, IMethodDefinition methodMutated, List<IMethodDefinition> additionalMethodsMutated=null)
 {
     _mutant = mutant;
     MutatedModules = mutatedModules;
     Old = old;
     MethodMutated = methodMutated;
     AdditionalMethodsMutated = additionalMethodsMutated;
 }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:8,代码来源:MutationResult.cs


示例20: SummarizeMethod

        public ReachabilitySummary SummarizeMethod(IMethodDefinition method, WholeProgram wholeProgram) {

            if (method.IsExternal == false && method.IsAbstract == false) {
                ReachabilitySummary summary = new ReachabilitySummary();
                IMethodDefinition target;


                // foreach MSIL instruction in the method
                foreach (var op in method.Body.Operations) {
                    switch (op.OperationCode) {
                        // non virtual method calls: just add static type
                        case OperationCode.Newobj:
                        case OperationCode.Call:
                        case OperationCode.Calli:
                            target = (op.Value as IMethodReference).ResolvedMethod;
                            summary.NonvirtuallyCalledMethods.Add(target);
                            break;

                        case OperationCode.Ldvirtftn:
                        case OperationCode.Callvirt:
                            target = (op.Value as IMethodReference).ResolvedMethod;            

                            if (target.IsVirtual == false) {
                                summary.NonvirtuallyCalledMethods.Add(target);
                            } else {
                                ITypeDefinition typeDefiningTarget = target.ContainingTypeDefinition;                                
                                IMethodDefinition targetUnspecialized = GarbageCollectHelper.UnspecializeAndResolveMethodReference(op.Value as IMethodReference);

                                // find all possible implementations of virtual call
                                foreach (ITypeDefinition subType in new ITypeDefinition[] { typeDefiningTarget }.Concat(wholeProgram.ClassHierarchy().AllSubClassesOfClass(typeDefiningTarget))) {
                                    if (GarbageCollectHelper.TypeIsConstructable(subType)) {

                                        // walk class hierarchy from subType up to (including) typeDefiningTarget, looking for targetUnspecialized.
                                        ICollection<IMethodDefinition> implementationsOfMethodDefinitionForSubType = GarbageCollectHelper.Implements(subType, typeDefiningTarget, targetUnspecialized);

                                        // we have to have found at least 1 implementation
                                        Contract.Assert(implementationsOfMethodDefinitionForSubType.Count() > 0);

                                        // add all of them as virtually called methods
                                        foreach (IMethodDefinition implementationOfTarget in implementationsOfMethodDefinitionForSubType) {
                                            summary.VirtuallyCalledMethods.Add(implementationOfTarget);
                                        }
                                    }
                                }

                            }
                            break;

                        default:
                            break;
                    }
                }

                return summary;
            } else {
                return null;
            }
        }
开发者ID:RUB-SysSec,项目名称:Probfuscator,代码行数:58,代码来源:SimpleBytecodeMethodSummarizer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IMethodInfo类代码示例发布时间:2022-05-24
下一篇:
C# IMethodData类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap