From 6e6cf735a3921d1f4984d6f94c604ff61512ce87 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 27 Jan 2013 21:45:01 +0100 Subject: [PATCH] ParameterCanBeDemotedIssue: remove GetInheritanceDepth. It has the potential for a stack overflow when there's cyclic inheritance. The sorting already done by GetAllBaseTypes() should be good enough. --- .../ParameterCanBeDemotedIssue.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ParameterCanBeDemotedIssue/ParameterCanBeDemotedIssue.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ParameterCanBeDemotedIssue/ParameterCanBeDemotedIssue.cs index d9cc0c7297..66ce459bf6 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ParameterCanBeDemotedIssue/ParameterCanBeDemotedIssue.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ParameterCanBeDemotedIssue/ParameterCanBeDemotedIssue.cs @@ -145,7 +145,6 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring var validTypes = (from type in possibleTypes where !tryResolve || TypeChangeResolvesCorrectly(parameter, rootResolutionNode, type) - orderby GetInheritanceDepth(type) ascending select type).ToList(); if (validTypes.Any()) { // don't demote an array to IList @@ -185,16 +184,6 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring }); } } - - int GetInheritanceDepth(IType declaringType) - { - var depth = 0; - foreach (var baseType in declaringType.DirectBaseTypes) { - var newDepth = GetInheritanceDepth(baseType); - depth = Math.Max(depth, newDepth); - } - return depth; - } } class TypeChangeValidationNavigator : IResolveVisitorNavigator