Browse Source

Fix NullReferenceException in IterateViaForeachAction.

newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
3eb4ea84f8
  1. 5
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IterateViaForeachAction.cs

5
ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IterateViaForeachAction.cs

@ -149,11 +149,10 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
{ {
IType collectionType = null; IType collectionType = null;
foreach (var baseType in type.GetAllBaseTypes()) { foreach (var baseType in type.GetAllBaseTypes()) {
var baseTypeDefinition = baseType.GetDefinition(); if (baseType.IsKnownType(KnownTypeCode.IEnumerableOfT)) {
if (baseTypeDefinition.IsKnownType(KnownTypeCode.IEnumerableOfT)) {
collectionType = baseType; collectionType = baseType;
break; break;
} else if (baseTypeDefinition.IsKnownType(KnownTypeCode.IEnumerable)) { } else if (baseType.IsKnownType(KnownTypeCode.IEnumerable)) {
collectionType = baseType; collectionType = baseType;
// Don't break, continue in case type implements IEnumerable<T> // Don't break, continue in case type implements IEnumerable<T>
} }

Loading…
Cancel
Save