當前位置: 首頁>>代碼示例>>C#>>正文


C# TypeDefinition.IsCompilerGenerated方法代碼示例

本文整理匯總了C#中Mono.Cecil.TypeDefinition.IsCompilerGenerated方法的典型用法代碼示例。如果您正苦於以下問題:C# TypeDefinition.IsCompilerGenerated方法的具體用法?C# TypeDefinition.IsCompilerGenerated怎麽用?C# TypeDefinition.IsCompilerGenerated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.Cecil.TypeDefinition的用法示例。


在下文中一共展示了TypeDefinition.IsCompilerGenerated方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ProcessType

        private void ProcessType(bool? assemblyConfigureAwaitValue, TypeDefinition type)
        {
            if (type.IsCompilerGenerated() && type.IsIAsyncStateMachine())
            {
                return;
            }

            var configureAwaitValue = (bool?)type.GetConfigureAwaitAttribute()?.ConstructorArguments[0].Value;
            configureAwaitValue = configureAwaitValue ?? assemblyConfigureAwaitValue;

            foreach (var method in type.Methods)
            {
                var localConfigureAwaitValue = (bool?)method.GetConfigureAwaitAttribute()?.ConstructorArguments[0].Value;
                var localConfigWasSet = localConfigureAwaitValue.HasValue;
                localConfigureAwaitValue = localConfigureAwaitValue ?? configureAwaitValue;
                if (localConfigureAwaitValue == null)
                    continue;

                var asyncStateMachineType = method.GetAsyncStateMachineType();
                if (asyncStateMachineType != null)
                {
                    AddAwaitConfigToAsyncMethod(asyncStateMachineType, localConfigureAwaitValue.Value);
                }
                else if (localConfigWasSet)
                {
                    LogWarning($"ConfigureAwaitAttribue applied to non-async method '{method.FullName}'.");
                    continue;
                }
            }
        }
開發者ID:caesay,項目名稱:ConfigureAwait,代碼行數:30,代碼來源:ModuleWeaver.cs

示例2: VisitType

		public void VisitType(TypeDefinition type)
		{						
			if (type.TypeImplements("System.Collections.IEnumerator") && !type.IsCompilerGenerated())
			{
				Log.DebugLine(this, "-----------------------------------"); 
				Log.DebugLine(this, "checking {0}", type);		
				
				PropertyDefinition[] properties = type.Properties.GetProperties("Current");
				
				bool found = false;
				foreach (PropertyDefinition prop in properties)
				{
					if (prop.PropertyType.ToString() != "System.Object")
					{
						found = true;
						break;
					}
				}
		
				if (!found)
				{
					Log.DebugLine(this, "no strongly typed Current");		
					Reporter.TypeFailed(type, CheckID, string.Empty);
				}
			}
		}
開發者ID:dbremner,項目名稱:smokey,代碼行數:26,代碼來源:TypedEnumeratorRule.cs

示例3: GetOriginalCodeLocation

		public static MethodDefinition GetOriginalCodeLocation(TypeDefinition type)
		{
			if (type != null && type.DeclaringType != null && type.IsCompilerGenerated()) {
				MethodDefinition constructor = GetTypeConstructor(type);
				return FindMethodUsageInType(type.DeclaringType, constructor);
			}
			return null;
		}
開發者ID:kiinoo,項目名稱:ILSpy,代碼行數:8,代碼來源:Helpers.cs

示例4: IsCompilerGeneratedStateMachine

		public static bool IsCompilerGeneratedStateMachine(TypeDefinition type)
		{
			if (!(type.DeclaringType != null && type.IsCompilerGenerated()))
				return false;
			foreach (TypeReference i in type.Interfaces) {
				if (i.Namespace == "System.Runtime.CompilerServices" && i.Name == "IAsyncStateMachine")
					return true;
			}
			return false;
		}
開發者ID:FaceHunter,項目名稱:ILSpy,代碼行數:10,代碼來源:AsyncDecompiler.cs

示例5: IsCompilerGeneratorEnumerator

 public static bool IsCompilerGeneratorEnumerator(TypeDefinition type)
 {
     if (!(type.DeclaringType != null && type.IsCompilerGenerated()))
         return false;
     foreach (TypeReference i in type.Interfaces) {
         if (i.Namespace == "System.Collections" && i.Name == "IEnumerator")
             return true;
     }
     return false;
 }
開發者ID:ropean,項目名稱:Usable,代碼行數:10,代碼來源:YieldReturnDecompiler.cs

示例6: VisitType

		public void VisitType(TypeDefinition type)
		{						
			Log.DebugLine(this, "-----------------------------------"); 
			Log.DebugLine(this, "checking {0}", type);				

			if (!type.IsCompilerGenerated())
			{
				if (DoBaseFailed(type) || DoInterfaceFailed(type))
				{
					Reporter.TypeFailed(type, CheckID, string.Empty);
				}
			}
		}
開發者ID:dbremner,項目名稱:smokey,代碼行數:13,代碼來源:SuffixNameRule.cs

示例7: GetOriginalCodeLocation

		/// <summary>
		/// Given a compiler-generated type, returns the method where that type is used.
		/// Used to detect the 'parent method' for a lambda/iterator/async state machine.
		/// </summary>
		public static MethodDefinition GetOriginalCodeLocation(TypeDefinition type)
		{
			if (type != null && type.DeclaringType != null && type.IsCompilerGenerated()) {
				if (type.IsValueType) {
					// Value types might not have any constructor; but they must be stored in a local var
					// because 'initobj' (or 'call .ctor') expects a managed ref.
					return FindVariableOfTypeUsageInType(type.DeclaringType, type);
				} else {
					MethodDefinition constructor = GetTypeConstructor(type);
					if (constructor == null)
						return null;
					return FindMethodUsageInType(type.DeclaringType, constructor);
				}
			}
			return null;
		}
開發者ID:FaceHunter,項目名稱:ILSpy,代碼行數:20,代碼來源:Helpers.cs

示例8: VisitType

		public void VisitType(TypeDefinition type)
		{						
			DBC.Assert(m_state == State.Types, "state is {0}", m_state);
			Log.DebugLine(this, "{0}", type.FullName);

			if (!type.ExternallyVisible(Cache) && DoInstantiable(type) && DoValidType(type))
			{	
				if (!type.IsCompilerGenerated())
				{
					var key = new AssemblyCache.TypeKey(type);
					DBC.Assert(m_keys.IndexOf(key) < 0, "{0} is already in types", type.FullName);
					Log.DebugLine(this, "adding {0}", type.FullName);
					
					m_keys.Add(key);
				}
			}
		}
開發者ID:dbremner,項目名稱:smokey,代碼行數:17,代碼來源:NotInstantiatedRule.cs

示例9: VisitType

		public void VisitType(TypeDefinition type)
		{
			if (!type.IsCompilerGenerated())
			{
				if (!type.IsSubclassOf("System.Delegate", Cache) && !type.IsSubclassOf("System.MulticastDelegate", Cache))
				{
					Log.DebugLine(this, "-----------------------------------"); 
					Log.DebugLine(this, "{0:F}", type.FullName);				
		
					if (!type.IsValueType && !type.IsInterface && !type.IsBeforeFieldInit)
					{
						if (type.Name != "<Module>")
							Reporter.TypeFailed(type, CheckID, string.Empty);
					}
				}
			}
		}
開發者ID:dbremner,項目名稱:smokey,代碼行數:17,代碼來源:InlineStaticInitRule.cs

示例10: VisitType

		public void VisitType(TypeDefinition type)
		{						
			if (type.IsValueType && !type.IsEnum && !type.IsCompilerGenerated())
			{				
				Log.DebugLine(this, "-----------------------------------"); 
				Log.DebugLine(this, "checking {0}", type);				
	
				// Try to find Equals and GetHashCode.
				var methods = new List<MethodInfo>();
				methods.AddRange(Cache.FindMethods(type, "Equals"));
				methods.AddRange(Cache.FindMethods(type, "GetHashCode"));
				
				// Make sure we found the correct ones.
				bool foundEquals = false;
				for (int i = 0; i < methods.Count && !foundEquals; ++i)
					if (methods[i].Method.Reuses("System.Boolean", "Equals", "System.Object"))
						foundEquals = true;

				bool foundHash = false;
				for (int i = 0; i < methods.Count && !foundHash; ++i)
					if (methods[i].Method.Reuses("System.Int32", "GetHashCode"))
						foundHash = true;

				// If not we have a problem.
				if (!foundEquals && !foundHash)
				{
					string details = "Equals and GetHashCode are missing";
					Log.DebugLine(this, details);
					Reporter.TypeFailed(type, CheckID, details);
				}
				else if (!foundEquals)
				{
					string details = "Equals is missing";
					Log.DebugLine(this, details);
					Reporter.TypeFailed(type, CheckID, details);
				}
				else if (!foundHash)
				{
					string details = "GetHashCode is missing";
					Log.DebugLine(this, details);
					Reporter.TypeFailed(type, CheckID, details);
				}
			}
		}
開發者ID:dbremner,項目名稱:smokey,代碼行數:44,代碼來源:StructOverridesRule.cs

示例11: VisitType

		public void VisitType(TypeDefinition type)
		{						
			Log.DebugLine(this, "-----------------------------------"); 
			Log.DebugLine(this, "checking {0}", type);				

			if (!type.IsCompilerGenerated())
			{
				if (!type.IsAbstract)
//				if (!type.IsAbstract && !type.FullName.Contains("PrivateImplementationDetails"))
				{
					if (type.BaseType != null && type.BaseType.FullName == "System.Object")
					{
						if (DoHasNoVirtuals(type) && DoAllFieldsAreStatic(type))
						{
							Log.DebugLine(this, "cab be made static"); 
							Reporter.TypeFailed(type, CheckID, string.Empty);
						}
					}
				}
			}
		}
開發者ID:dbremner,項目名稱:smokey,代碼行數:21,代碼來源:ClassCanBeMadeStaticRule.cs

示例12: VisitType

		public void VisitType(TypeDefinition candidate)
		{
			if (!candidate.IsAbstract && !candidate.ExternallyVisible(Cache) && candidate.IsClass && !candidate.IsSealed)
			{
				if (candidate.FullName != "<Module>" && !candidate.IsCompilerGenerated())
				{
					Log.DebugLine(this, "checking {0}", candidate);	
					
					foreach (TypeDefinition type in Cache.Types)
					{	
						if (type.IsSubclassOf(candidate, Cache))
						{
//							Log.DebugLine(this, "   is base class for {0} [{1}]", type, type.BaseType);	
							return;
						}
//						else
//							Log.DebugLine(this, "   not a base class for {0} [{1}]", type, type.BaseType);	
					}
	
//					Log.DebugLine(this, "   failed");	
					Reporter.TypeFailed(candidate, CheckID, string.Empty);
				}
			}
		}
開發者ID:dbremner,項目名稱:smokey,代碼行數:24,代碼來源:NotSealedRule.cs

示例13: IsPotentialClosure

		bool IsPotentialClosure(TypeDefinition potentialDisplayClass)
		{
			if (potentialDisplayClass == null || !potentialDisplayClass.IsCompilerGenerated())
				return false;
			// check that methodContainingType is within containingType
			while (potentialDisplayClass != context.CurrentType) {
				potentialDisplayClass = potentialDisplayClass.DeclaringType;
				if (potentialDisplayClass == null)
					return false;
			}
			return true;
		}
開發者ID:stgwilli,項目名稱:ILSpy,代碼行數:12,代碼來源:DelegateConstruction.cs

示例14: IsCompilerGeneratorEnumerator

		public static bool IsCompilerGeneratorEnumerator(TypeDefinition type)
		{
			if (!(type.Name.StartsWith("<", StringComparison.Ordinal) && type.IsCompilerGenerated()))
				return false;
			foreach (TypeReference i in type.Interfaces) {
				if (i.Namespace == "System.Collections" && i.Name == "IEnumerator")
					return true;
			}
			return false;
		}
開發者ID:hlesesne,項目名稱:ILSpy,代碼行數:10,代碼來源:YieldReturnDecompiler.cs

示例15: GetTypeActionAttribute

 private TypeActionAttribute GetTypeActionAttribute(TypeDefinition provider)
 {
     var attr = provider.GetCustomAttribute<TypeActionAttribute>();
     if (attr != null) {
         return attr;
     }
     switch (ImplicitImports) {
         case ImplicitImportSetting.OnlyCompilerGenerated:
             if (provider.IsCompilerGenerated()) {
                 goto case ImplicitImportSetting.ImplicitByDefault;
             }
             goto case ImplicitImportSetting.NoImplicit;
         case ImplicitImportSetting.ImplicitByDefault:
             return new NewTypeAttribute(true);
         default:
         case ImplicitImportSetting.NoImplicit:
             return null;
     }
 }
開發者ID:gitter-badger,項目名稱:Patchwork,代碼行數:19,代碼來源:AssemblyPatcher.cs


注:本文中的Mono.Cecil.TypeDefinition.IsCompilerGenerated方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。