void CheckAmbiguousVariableNames(Method node) { if (null == node.DeclaringType || null == node.DeclaringType.Entity) { return; } InternalClass klass = node.DeclaringType.Entity as InternalClass; if (null == klass || null == klass.BaseType) { return; } if (Parameters.DisabledWarnings.Contains("BCW0025")) { return; } klass = klass.BaseType as InternalClass; foreach (Local local in node.Locals) { if (null == local.Entity || ((InternalLocal)local.Entity).IsExplicit) { continue; } //check in the cache if variable is safe (the frequent case) if (_safeVars.Contains(local.Name)) { return; } //navigate down the base types bool safe = true; while (null != klass) { Field field = klass.TypeDefinition.Members[local.Name] as Field; if (null != field && field.IsPrivate) { safe = false; Warnings.Add(CompilerWarningFactory.AmbiguousVariableName(local, local.Name, klass.Name)); break; //no need to go further down } klass = klass.BaseType as InternalClass; } if (safe) //this var is safe for all methods of the current type { _safeVars.Add(local.Name); } } }