/// <summary> /// Check the given field reference. /// </summary> private void Check(FieldReference field, string context) { if (!Check(field.DeclaringType, context)) { return; } var error = false; try { var fieldDef = field.Resolve(); error = (fieldDef == null); } catch (Exception) { error = true; } CheckResolveData data; var key = field.FullName; if (!resolveErrorFieldNames.TryGetValue(key, out data)) { data = new CheckResolveData { IsAvailable = !error }; resolveErrorFieldNames.Add(key, data); if (error) { Error(MessageTypes.MissingField, Format(field), field.DeclaringType.Scope, context); } } data.CheckCount++; }
/// <summary> /// Check the given method reference. /// </summary> private void Check(MethodReference method, string context) { if (!Check(method.DeclaringType, context)) { return; } var error = false; try { if (method.IsGenericInstance) { Check((GenericInstanceMethod)method, context); } else { var typeDef = method.DeclaringType.GetElementType().Resolve(); var emethod = method.GetElementMethod(); var methodDef = (typeDef != null) ? typeDef.Methods.FirstOrDefault(x => x.AreSameExcludingGenericArguments(emethod, null)) : null; error = (methodDef == null); } } catch (Exception) { error = true; } CheckResolveData data; var key = method.FullName; if (!resolveErrorMethodNames.TryGetValue(key, out data)) { data = new CheckResolveData { IsAvailable = !error }; resolveErrorMethodNames.Add(key, data); if (error) { Error(MessageTypes.MissingMethod, Format(method, false), method.DeclaringType.Scope, context); } } data.CheckCount++; }
/// <summary> /// Check the given type reference. /// </summary> /// <returns>True on success, false otherwise</returns> private bool Check(TypeReference type, string context) { bool error; try { if (type.IsGenericInstance) { return Check((GenericInstanceType)type, context); } if (type.IsGenericParameter) { return Check((GenericParameter)type, context); } if (type.IsArray) { return Check((ArrayType)type, context); } if (type.IsByReference) { return Check((ByReferenceType) type, context); } if (type.IsFunctionPointer) { Error(MessageTypes.UnsupportedFeature, type.FullName, type.Scope, "Function pointer types are not supported (in {0})", context); return false; } if (type.IsPinned) { Error(MessageTypes.UnsupportedFeature, type.FullName, type.Scope, "Pinned are not supported ({0})", context); return false; } if (type.IsOptionalModifier) { Error(MessageTypes.UnsupportedFeature, type.FullName, type.Scope, "Optional modifier types are not supported (in {0})", context); return false; } if (type.IsRequiredModifier) { Error(MessageTypes.UnsupportedFeature, type.FullName, type.Scope, "Required modifier types are not supported (in {0})", context); return false; } var typeDef = type.Resolve(); error = (typeDef == null); } catch (Exception) { error = true; } CheckResolveData data; var key = type.FullName; if (!resolveErrorTypeNames.TryGetValue(key, out data)) { data = new CheckResolveData { IsAvailable = !error }; resolveErrorTypeNames.Add(key, data); if (error) { Error(MessageTypes.MissingType, CecilFormat.GetTypeName(type), type.Scope, context); } } data.CheckCount++; return !error; }
/// <summary> /// Check the given method reference. /// </summary> private void Check(MethodReference method, string context) { if (!Check(method.DeclaringType, context)) return; var error = false; try { if (method.IsGenericInstance) { Check((GenericInstanceMethod)method, context); } else { var typeDef = method.DeclaringType.GetElementType().Resolve(); var emethod = method.GetElementMethod(); var methodDef = (typeDef != null) ? typeDef.Methods.FirstOrDefault(x => x.AreSameExcludingGenericArguments(emethod, null)) : null; error = (methodDef == null); } } catch (Exception) { error = true; } CheckResolveData data; var key = method.FullName; if (!resolveErrorMethodNames.TryGetValue(key, out data)) { data = new CheckResolveData { IsAvailable = !error }; resolveErrorMethodNames.Add(key, data); if (error) { Error(MessageTypes.MissingMethod, Format(method, false), method.DeclaringType.Scope, context); } } data.CheckCount++; }
/// <summary> /// Check the given field reference. /// </summary> private void Check(FieldReference field, string context) { if (!Check(field.DeclaringType, context)) return; var error = false; try { var fieldDef = field.Resolve(); error = (fieldDef == null); } catch (Exception) { error = true; } CheckResolveData data; var key = field.FullName; if (!resolveErrorFieldNames.TryGetValue(key, out data)) { data = new CheckResolveData { IsAvailable = !error }; resolveErrorFieldNames.Add(key, data); if (error) { Error(MessageTypes.MissingField, Format(field), field.DeclaringType.Scope, context); } } data.CheckCount++; }
/// <summary> /// Check the given type reference. /// </summary> /// <returns>True on success, false otherwise</returns> private bool Check(TypeReference type, string context) { bool error; try { if (type.IsGenericInstance) { return(Check((GenericInstanceType)type, context)); } if (type.IsGenericParameter) { return(Check((GenericParameter)type, context)); } if (type.IsArray) { return(Check((ArrayType)type, context)); } if (type.IsByReference) { return(Check((ByReferenceType)type, context)); } if (type.IsFunctionPointer) { Error(MessageTypes.UnsupportedFeature, type.FullName, type.Scope, "Function pointer types are not supported (in {0})", context); return(false); } if (type.IsPinned) { Error(MessageTypes.UnsupportedFeature, type.FullName, type.Scope, "Pinned are not supported ({0})", context); return(false); } if (type.IsOptionalModifier) { Error(MessageTypes.UnsupportedFeature, type.FullName, type.Scope, "Optional modifier types are not supported (in {0})", context); return(false); } if (type.IsRequiredModifier) { Error(MessageTypes.UnsupportedFeature, type.FullName, type.Scope, "Required modifier types are not supported (in {0})", context); return(false); } var typeDef = type.Resolve(); error = (typeDef == null); } catch (Exception) { error = true; } CheckResolveData data; var key = type.FullName; if (!resolveErrorTypeNames.TryGetValue(key, out data)) { data = new CheckResolveData { IsAvailable = !error }; resolveErrorTypeNames.Add(key, data); if (error) { Error(MessageTypes.MissingType, CecilFormat.GetTypeName(type), type.Scope, context); } } data.CheckCount++; return(!error); }