Skip to content

Commit 3395dff

Browse files
committed
Fix 12595: Add do...while loop in the SetValue method of SerializationResourceManager.cs until resourceName is unique
1 parent 8732cfb commit 3395dff

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.SerializationResourceManager.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,10 +778,17 @@ public string SetValue(IDesignerSerializationManager manager, ExpressionContext?
778778

779779
// Only append the number when appendCount is set or if there is already a count.
780780
int count = 0;
781-
if (appendCount || _nameTable.TryGetValue(nameBase, out count))
781+
782+
if (appendCount || _nameTable.ContainsKey(resourceName))
782783
{
783-
count++;
784-
resourceName = $"{nameBase}{count}";
784+
_nameTable.TryGetValue(nameBase, out count);
785+
786+
do
787+
{
788+
resourceName = $"{nameBase}{count}";
789+
count++;
790+
}
791+
while (_nameTable.ContainsKey(resourceName));
785792
}
786793

787794
// Now that we have a name, write out the resource.

0 commit comments

Comments
 (0)