當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。