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


C# MethodDefinition.GetFullName方法代码示例

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


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

示例1: IsSecurityCritical

	public bool IsSecurityCritical (MethodDefinition method)
	{
		string entry = method.GetFullName ();
		if (critical.Contains (entry))
			return true;

		TypeDefinition type = method.DeclaringType;
		if (!IsSecurityCritical (type))
			return false;

		switch (method.Name) {
		// e.g. everything we override from System.Object (which is transparent)
		case "Equals":
			return (method.Parameters.Count != 1 || method.Parameters [0].ParameterType.FullName != "System.Object");
		case "Finalize":
		case "GetHashCode":
		case "ToString":
			return method.HasParameters;
		// e.g. some transparent interfaces, like IDisposable (implicit or explicit)
		// downgrade some SC into SSC to respect the override/inheritance rules
		case "System.IDisposable.Dispose":
		case "Dispose":
			return method.HasParameters;
		default:
			return true;
		}
	}
开发者ID:dfr0,项目名称:moon,代码行数:27,代码来源:detect.cs

示例2: MarkAsSafeCritical

	static void MarkAsSafeCritical (MethodDefinition method)
	{
		AssemblyDefinition ad = method.DeclaringType.Module.Assembly;
		List<string> list = methods [ad];
		string m = method.GetFullName ();
		if (!list.Contains (m))
			list.Add (m);
	}
开发者ID:kangaroo,项目名称:moon,代码行数:8,代码来源:detect-ssc.cs

示例3: ProcessMethod


//.........这里部分代码省略.........
		// skip signature check for visible API (we get them from find-sc)
		if (!sc && !method.IsVisible ()) {
			TypeReference rtype = method.ReturnType;
			if (!CheckType (rtype)) {
				sc = true;
				comment = String.Format ("using '{0}' as return type", rtype.FullName);
			}
		}

		// check if this method implements an interface where the corresponding member
		// is [SecurityCritical]
		TypeDefinition type = method.DeclaringType;
		if (!sc && type.HasInterfaces) {
			foreach (TypeReference intf in type.Interfaces) {
				TypeDefinition td = intf.Resolve ();
				if (td == null || !td.HasMethods)
					continue;
				foreach (MethodDefinition im in td.GetMethods ()) {
					if (im.IsSecurityCritical ()) {
						if (Compare (method, im)) {
							sc = true;
							comment = String.Format ("implements '{0}'.", im);
						}
					}
				}
			}
		}

		// if we're overriding a [SecurityCritical] method then we must be one too! or
		// if we are [SecurityCritical] then the base method needs to be too!
		if (method.IsVirtual && !method.IsAbstract) {
			TypeReference tr = method.DeclaringType.BaseType;
			if (tr != null) {
				TypeDefinition td = tr.Resolve ();
				if (td != null) {
					foreach (MethodDefinition bm in td.GetMethods ()) {
						if (Compare (method, bm)) {
							if (!sc) {
								if (bm.IsSecurityCritical ()) {
									sc = true;
									comment = String.Format ("overrides '{0}'.", bm);
								}
							} else {
								if (!bm.IsSecurityCritical ()) {
									string bms = bm.ToString ();
									if (!methods.ContainsKey (bms)) {
										comment = String.Format ("Promoting {0}base method to [SecurityCritical] because of '{1}'.", 
											bm.IsVisible () ? "[VISIBLE] " : String.Empty, method);
										methods.Add (bms, comment);
									}
								}
							}							
						}
					}
				}
			}
		} else {
			// note: we don't want to break the override rules above (resulting in TypeLoadException)
			// an icall that is NOT part of the visible API is considered as critical (like a p/invoke)
			if (method.IsInternalCall && !method.IsVisible ()) {
				sc = true;
				comment = "internal call";
			}
		}

		if (sc) {
			// note: add a warning on visible API since adding [SecurityCritical]
			// on "new" visible API would introduce incompatibility (so this needs
			// to be reviewed).
			if (method.IsVisible ())
				comment = "[VISIBLE] " + comment;
			methods.Add (method.GetFullName (), comment);
		}

		// if this method is [SecurityCritical] (already or because we determined it should be)
		// and implements an interface then some interface members may needs to be [SecurityCritical] 
		// too or a TypeLoadException will be thrown 
		// e.g. AppDomain.add_AssemblyResolve versus _AppDomain
		if (sc || method.IsSecurityCritical ()) {
			if (type.HasInterfaces) {
				foreach (TypeReference intf in type.Interfaces) {
					TypeDefinition td = intf.Resolve ();
					if (td == null || !td.HasMethods)
						continue;
					foreach (MethodDefinition im in td.GetMethods ()) {
						// note: in this case we don't care if the method is indirectly critical (e.g.via its type)
						if (Compare (method, im) && !type.IsSecurityCritical ()) {
							string ims = im.GetFullName ();
							// only add this if it's not something we already found before
							if (!methods.ContainsKey (ims)) {
								comment = String.Format ("Promoting {0}interface member to [SecurityCritical] because of '{1}'.", 
									im.IsVisible () ? "[VISIBLE] " : String.Empty, method);
								methods.Add (ims, comment);
							}
						}
					}
				}
			}
		}
	}
开发者ID:snorp,项目名称:moon,代码行数:101,代码来源:detect-sc.cs


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