Esempio n. 1
0
			public bool TryGetLocation (string methodStr, string typeFullName, int offset, bool isOffsetIL, uint methodIndex, out Location location)
			{
				location = default (Location);
				if (symbolFile == null)
					return false;

				var type = assembly.GetTypes().FirstOrDefault (t => t.FullName == typeFullName);
				if (type == null)
					return false;

				var bindingflags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
				var method = type.GetMethods(bindingflags).FirstOrDefault (m => GetMethodFullName (m) == methodStr);
				if (method == null)
					return false;

				int ilOffset = (isOffsetIL)? offset : GetILOffsetFromFile (method.MetadataToken, methodIndex, offset);
				if (ilOffset < 0)
					return false;

				var methodSymbol = symbolFile.Methods [(method.MetadataToken & 0x00ffffff) - 1];

				var lineNumbers = methodSymbol.GetLineNumberTable ().LineNumbers;
				var lineNumber = lineNumbers.FirstOrDefault (l => l.Offset >= ilOffset) ?? lineNumbers.Last ();

				location.FileName = symbolFile.Sources [lineNumber.File-1].FileName;
				location.Line = lineNumber.Row;
				return true;
			}
Esempio n. 2
0
			public bool TryGetLocation (string methodFullName, string[] methodParamsTypes, int offset, bool isOffsetIL, out Location location)
			{
				location = default (Location);
				if (symbolFile == null)
					return false;

				var typeNameEnd = methodFullName.LastIndexOf (".");
				var typeName = methodFullName.Substring (0, typeNameEnd);
				var methodName = methodFullName.Substring (typeNameEnd + 1, methodFullName.Length - typeNameEnd - 1);

				var type = assembly.MainModule.Types.FirstOrDefault (t => t.FullName == typeName);
				if (type == null)
					return false;

				var method = type.Methods.FirstOrDefault (m => {
					if (m.Name != methodName)
						return false;

					if (m.Parameters.Count != methodParamsTypes.Length)
						return false;

					for (var i = 0; i < methodParamsTypes.Length; i++) {
						var paramType = m.Parameters[i].ParameterType;
						if (paramType.Name != methodParamsTypes[i])
							return false;
					}

					return true;
				});

				if (method == null)
					return false;

				int ilOffset = (isOffsetIL)? offset : GetILOffsetFromFile (method.MetadataToken.ToInt32 (), offset);
				if (ilOffset < 0)
					return false;

				var methodSymbol = symbolFile.Methods [method.MetadataToken.RID-1];

				foreach (var lineNumber in methodSymbol.GetLineNumberTable ().LineNumbers) {
					if (lineNumber.Offset < ilOffset)
						continue;

					location.FileName = symbolFile.Sources [lineNumber.File-1].FileName;
					location.Line = lineNumber.Row;
					return true;
				}

				return false;
			}
Esempio n. 3
0
		public bool TryGetLocation (string method, string typeFullName, int offset, bool isOffsetIL, uint methodIndex, out Location location)
		{
			location = default (Location);
			foreach (var assembly in assemblies.Values) {
				if (assembly.TryGetLocation (method, typeFullName, offset, isOffsetIL, methodIndex, out location))
					return true;
			}

			return false;
		}
Esempio n. 4
0
		public bool TryGetLocation (string methodName, string[] methodParams, int ilOffset, out Location location)
		{
			location = default (Location);
			foreach (var assembly in assemblies.Values) {
				if (assembly.TryGetLocation (methodName, methodParams, ilOffset, out location))
					return true;
			}

			return false;
		}