NJsonSchema icon indicating copy to clipboard operation
NJsonSchema copied to clipboard

Infinite loop in RenamePropertyWithSameNameAsClass

Open cubed-it opened this issue 1 year ago • 0 comments

Hello, I've discovered an infinite loop in the CSharpGenerator.RenamePropertyWithSameNameAsClass method. The problem arises when a property shares the same name as its enclosing type and another property already bears a '1' suffix:

var number = 1;
var candidate = typeName + number;
while (propertyModels.Any(p => p.PropertyName == candidate))
{
    number++;
}

This loop will persist indefinitely under the described condition.

cubed-it avatar Jan 30 '24 11:01 cubed-it