public void VisitBegin(BeginMethod begin) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_method = begin.Info.Method; }
public void VisitBegin(BeginMethod method) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", method.Info.Instructions); // Loop through each try block, int offset = -1; for (int i = 0; i < method.Info.Instructions.TryCatchCollection.Length && offset < 0; ++i) { TryCatch tc = method.Info.Instructions.TryCatchCollection[i]; // and the associated catch blocks, for (int j = 0; j < tc.Catchers.Count && offset < 0; ++j) { CatchBlock cb = tc.Catchers[j]; // if the first instruction in a catch is a store local then the code // is storing a reference to the exception object and we need to check // to see if it's being rethrown. StoreLocal store = method.Info.Instructions[cb.Index] as StoreLocal; if (store != null) { offset = DoCheckCatch(method.Info.Instructions, cb, store.Variable); } } } if (offset >= 0) { Reporter.MethodFailed(method.Info.Method, CheckID, offset, string.Empty); } }
public void VisitMethodBegin(BeginMethod begin) { m_inDispose = false; if (m_disposable) { Log.DebugLine(this, "{0:F}", begin.Info.Instructions); MethodDefinition method = begin.Info.Method; if (method.Name == "Finalize") { MethodDefinition previous = method.GetBasestMethod(Cache); if (previous != null && previous != method) { Log.DebugLine(this, "finalizer overrides {0}", previous); m_hasFinalizer = true; } } if (method.Matches("System.Void", "Dispose")) { Log.DebugLine(this, "has Dispose()"); m_hasDispose = true; } if (method.Matches("System.Void", "Dispose", "System.Boolean")) { Log.DebugLine(this, "has Dispose(bool)"); m_disposeMethod = method; m_inDispose = true; } } }
public void VisitMethod(BeginMethod begin) { foreach (ParameterDefinition p in begin.Info.Method.Parameters) { DoAdd(p.Name); } }
public void VisitBegin(BeginMethod begin) { if (!begin.Info.Method.IsVirtual) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0}", begin.Info.Instructions); string details = string.Empty; List <MethodDefinition> methods = new List <MethodDefinition>(); if (begin.Info.Type.BaseType != null) { DoGetBaseMethods(begin.Info.Type.BaseType, begin.Info.Method, methods); } foreach (MethodDefinition method in methods) { if (DoLeftHidesRight(begin.Info.Method, method)) { details = string.Format("{0} hides {1}. {2}", begin.Info.Method, method, details); } } if (details.Length > 0) { Log.DebugLine(this, details); Reporter.MethodFailed(begin.Info.Method, CheckID, 0, details); } } }
public void VisitBegin(BeginMethod begin) { if (m_needsCheck) { m_failed = DoHasAssert(begin.Info.Method.SecurityDeclarations); } }
public void VisitBeginMethod(BeginMethod begin) { Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_info = begin.Info; m_offset = -1; }
public void VisitBegin(BeginMethod method) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", method.Info.Instructions); m_offset = -1; }
public void VisitBegin(BeginMethod begin) { m_offset = -1; m_info = begin.Info; m_badArg = null; m_needsCheck = OnNeedsCheck(m_info.Type) && OnNeedsCheck(m_info.Type, m_info.Method); m_table.Clear(); if (m_needsCheck) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); foreach (ParameterDefinition p in m_info.Method.Parameters) { if (!p.ParameterType.IsValueType) { Log.DebugLine(this, "{0} is a reference type", p.Name); m_table.Add(p.Name, false); } } } if (m_table.Count == 0) { m_needsCheck = false; } }
public void VisitBegin(BeginMethod begin) { Log.DebugLine(this, "checking {0}", begin.Info.Method); TypeReference type = begin.Info.Method.GetDeclaredIn(Cache); if (type != null) { TypeDefinition td = Cache.FindType(type); if (td != null && td.IsInterface && !td.IsPublic && !td.IsNestedPublic) { Log.DebugLine(this, " implements {0}", type); if (begin.Info.Type.ExternallyVisible(Cache)) { Log.DebugLine(this, " declaring type is externally visible"); if (begin.Info.Method.IsVirtual && !begin.Info.Method.IsFinal) { Log.DebugLine(this, " is virtual"); if (DoHasPublicCtor(begin.Info.Type)) { Log.DebugLine(this, " has public ctor"); string details = "Interface: " + type.FullName; Reporter.MethodFailed(begin.Info.Method, CheckID, 0, details); } } } } } }
public void VisitBegin(BeginMethod begin) { m_needsCheck = false; m_missingBaseCall = true; m_type = begin.Info.Type; m_method = begin.Info.Method; if (m_method.Name == "GetObjectData") { if (m_type.ExternallyVisible(Cache)) { if (m_type.BaseImplements("System.Runtime.Serialization.ISerializable", Cache)) { if (m_method.Parameters.Count == 2) { if (m_method.Parameters[0].ParameterType.FullName == "System.Runtime.Serialization.SerializationInfo" && m_method.Parameters[1].ParameterType.FullName == "System.Runtime.Serialization.StreamingContext") { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_needsCheck = true; } } } } } }
public void VisitBegin(BeginMethod begin) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_offset = DoHasBadDemand(begin.Info.Method) ? 0 : -1; }
public void VisitMethod(BeginMethod begin) { Log.DebugLine(this, "++++++++++++++++++++++++"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_type = begin.Info.Type; }
public void VisitMethodBegin(BeginMethod begin) { Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_equality = null; m_minfo = begin.Info; MethodDefinition method = begin.Info.Method; if (method.IsPublic) { if (method.Name.StartsWith("get_") && !method.IsStatic) { DoTrivialGetter(); } else if (method.Name.StartsWith("set_") && !method.IsStatic) { DoTrivialSetter(); } else if (method.Name == "Equals" || method.Name == "op_Equality") { // TODO: need to check for instance method calls as well m_equality = new EqualityMethod(method); } } }
public void VisitMethod(BeginMethod begin) { if (m_needsCheck) { MethodDefinition method = begin.Info.Method; if (method.IsConstructor) { m_method = null; } else if (method.Name == "Finalize") { m_method = null; } // else if (begin.Info.Instructions.Length <= 10) // m_method = null; else { m_method = method; } // if (m_method != null) // Log.DebugLine(this, "{0}", method); } }
public void VisitBegin(BeginMethod begin) { DBC.Pre(begin != null, "begin is null"); Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_info = begin.Info; MethodDefinition method = begin.Info.Method; if (method.Name == "Finalize") { Log.DebugLine(this, "found finalizer: {0}", method); m_threadRoots.Add(method); } else if (method.ReturnType.ReturnType.ToString() == "System.Void") { if (method.Parameters.Count == 1 && method.Parameters[0].ParameterType.FullName == "System.IAsyncResult") { Log.DebugLine(this, "found asynchronous thread function: {0}", method); m_threadRoots.Add(method); } } }
public void VisitBegin(BeginMethod begin) { m_isEmpty = false; m_notDisposable = false; m_checkThrows = false; m_doesThrow = false; MethodDefinition method = begin.Info.Method; if (method.Matches("System.Void", "Finalize") && !begin.Info.Type.IsCompilerGenerated()) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "checking {0:F}", begin.Info.Instructions); if (begin.Info.Instructions.Length == 0 || begin.Info.Instructions[0].Untyped.OpCode.Code == Code.Leave) { m_isEmpty = true; } if (!begin.Info.Type.TypeOrBaseImplements("System.IDisposable", Cache)) { m_notDisposable = true; } m_checkThrows = begin.Info.Instructions.TryCatchCollection.Length <= 1; // normally a try/finally block generated by the compiler } }
public void VisitBegin(BeginMethod begin) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_needsCheck = !begin.Info.Type.Name.Contains("Permission"); m_offset = -1; }
public void VisitBegin(BeginMethod begin) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_newOffsets.Clear(); m_setCount = 0; }
public void VisitBegin(BeginMethod begin) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_offset = -1; m_numUnboxes = 0; }
public void VisitMethod(BeginMethod begin) { if (m_table.TryGetValue(begin.Info.Method, out m_entry)) { Log.DebugLine(this, "{0}", begin.Info.Method); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); } }
public void VisitBegin(BeginMethod begin) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_offset = -1; m_details = string.Empty; }
public void VisitBegin(BeginMethod begin) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_needsCheck = begin.Info.Method.Name.StartsWith("set_"); m_found1 = false; m_found2 = false; }
public void VisitBegin(BeginMethod begin) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_offset = -1; m_foundCtor = false; m_foundLocale = false; }
public void VisitBegin(BeginMethod begin) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_offset = -1; m_bad = null; m_info = begin.Info; }
public void VisitBegin(BeginMethod begin) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_offset = -1; m_bad = null; m_info = begin.Info; m_needsCheck = !begin.Info.Method.IsCompilerGenerated(); // TODO: why are we even called for these? }
public void VisitMethod(BeginMethod begin) { if (m_fields.Count > 0) { Log.DebugLine(this, "----------"); Log.DebugLine(this, "{0:F}", begin.Info.Instructions); m_info = begin.Info; } }
private ParameterDescriptor[] LazilyFetchParametersCollection() { return(DescriptorUtil.LazilyFetchOrCreate <ParameterInfo, ParameterDescriptor>( ref _parametersCache /* cacheLocation */, () => { ParameterInfo[] parameters = BeginMethod.GetParameters(); return parameters.Take(parameters.Length - 2); // leave off the AsyncCallback + state parameters } /* intializer */, parameterInfo => new ReflectedParameterDescriptor(parameterInfo, this) /* converter */)); }
public void VisitBegin(BeginMethod method) { Log.DebugLine(this, "-----------------------------------"); Log.DebugLine(this, "{0:F}", method.Info.Instructions); m_max = DoIsIFormattableToString(method.Info.Method) ? 1 : 0; Log.DebugLine(this, "m_max = {0}", m_max); m_offset = -1; m_count = 0; }
protected override bool OnNeedsCheck(BeginMethod method) { bool needs = false; if (method.Info.Method.DeclaringType.IsValueType) { needs = base.OnNeedsCheck(method); } return(needs); }