当前位置: 首页>>代码示例>>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;未经允许,请勿转载。