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


C# MethodDefinition.IsCompilerGenerated方法代码示例

本文整理汇总了C#中Mono.Cecil.MethodDefinition.IsCompilerGenerated方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDefinition.IsCompilerGenerated方法的具体用法?C# MethodDefinition.IsCompilerGenerated怎么用?C# MethodDefinition.IsCompilerGenerated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Cecil.MethodDefinition的用法示例。


在下文中一共展示了MethodDefinition.IsCompilerGenerated方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitMethod

		// All we care about are the method properties and the name so we can get
		// by with just visiting MethodDefinition. 
		public void VisitMethod(MethodDefinition method)
		{
			// If the method is not private,
			if ((method.Attributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Private)
			{
				// not a ctor, not virtual (it'll be virtual if it's an explicit interface
				// member implementation), and not a property or event,
				if (!method.IsConstructor && !method.IsVirtual && method.SemanticsAttributes == 0)
				{
					// then it's a candidate for our rule so we'll go ahead and
					// do some logging. Note that DebugLine is compiled out in
					// release builds.
					Log.DebugLine(this, "-----------------------------------"); 
					Log.DebugLine(this, "{0}", method);				
			
					// If the name starts with Do and isn't compiler generated,
					if (method.Name.StartsWith("Do") && !method.IsCompilerGenerated())
					{
						// then we have a failure. For rules which fail within a
						// method, offset should be the first offset to the instruction
						// which triggered the violation. Details can be used to
						// communicate additional information to the user about the
						// cause of the violation.
						int offset = 0;
						string details = string.Empty;
						Log.DebugLine(this, "doesn't start with Do");
						
						// Note that there are also AssemblyFailed and TypeFailed methods.
						Reporter.MethodFailed(method, CheckID, offset, details);
					}
				}
			}
		}
开发者ID:dbremner,项目名称:smokey,代码行数:35,代码来源:PublicStartsWithDoRule.cs

示例2: GetOriginalCodeLocation

		public static MethodDefinition GetOriginalCodeLocation(MethodDefinition method)
		{
			if (method.IsCompilerGenerated()) {
				return FindMethodUsageInType(method.DeclaringType, method) ?? method;
			}

			var typeUsage = GetOriginalCodeLocation(method.DeclaringType);

			return typeUsage ?? method;
		}
开发者ID:FaceHunter,项目名称:ILSpy,代码行数:10,代码来源:Helpers.cs

示例3: FormatAccessor

        public static string FormatAccessor(string name, MethodDefinition accessor, bool needsAttributes)
        {
            if (accessor == null || String.IsNullOrEmpty (name))
                return String.Empty;

            var sb = new StringBuilder ();
            Utils.Indent++;
            try {
                sb.AppendLine ();
                if (accessor.HasCustomAttributes)
                    sb.Append (accessor.CustomAttributes.Format ());
                if (needsAttributes) {
                    sb.AppendIndent (FormatAttributes (accessor));
                    sb.Append (' ');
                } else
                    sb.AppendIndent ();

                sb.Append (name);
                bool needNewline = false;
                if (accessor.IsAbstract || accessor.DeclaringType.IsInterface || (needNewline = accessor.IsCompilerGenerated ())) {
                    sb.Append (";");
                } else
                    sb.Append (" { throw new NotImplementedException (); }");
            } finally {
                Utils.Indent--;
            }

            return sb.ToString ();
        }
开发者ID:grendello,项目名称:StubGen,代码行数:29,代码来源:FormattingExtensions.cs

示例4: SetAccessFlags

        /// <summary>
        /// Add the given method to its declaring class.
        /// </summary>
        protected virtual void SetAccessFlags(DexLib.MethodDefinition dmethod, MethodDefinition method)
        {
            // subclass accesses have already been fixed on an actual use basis.
            if (method.IsPrivate)
                dmethod.IsPrivate = true;
            else if (method.IsFamily || method.IsFamilyOrAssembly) 
                dmethod.IsProtected = true;
            else
                dmethod.IsPublic = true;

            if (method.DeclaringType.IsInterface)
            {
                dmethod.IsAbstract = true;
                //dmethod.
            }
            else
            {
                if (method.IsConstructor)
                {
                    dmethod.IsConstructor = true;
                    dmethod.IsStatic = method.IsStatic;
                    if (method.IsStatic)
                    {
                        // reset access modifiers for static constructors.
                        dmethod.IsPrivate = false;
                        dmethod.IsProtected = false;
                    }
                }
                else if (method.IsAbstract) dmethod.IsAbstract = true;
                else if (method.IsVirtual) dmethod.IsVirtual = true;
                else if (method.IsStatic) dmethod.IsStatic = true;
                else dmethod.IsFinal = true;
                //if (method.IsInitOnly) dmethod.IsFinal = true;
            }

            if (method.IsCompilerGenerated())
                dmethod.IsSynthetic = true;
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:41,代码来源:MethodBuilder.cs


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