icsharpcode/ILSpy

foreach expected but while used instead

Open

#1603 opened on Jul 29, 2019

View on GitHub
 (3 comments) (0 reactions) (0 assignees)C# (25,162 stars) (3,645 forks)batch import
C#DecompilerEnhancementHelp Wanted

Description

ILSpy version 5.0.0.4970-preview3

method decompiled with while but foreach expected

protected CompositeDevices(SerializationInfo info, StreamingContext context)
	: base(info, context)
{
	SerializationInfoEnumerator enumerator = info.GetEnumerator();
	while (enumerator.MoveNext())
	{
		string name = enumerator.Current.Name;
		if (name != null && name == "AdditionalParameters")
		{
			AdditionalParameters = (Dictionary<string, string>)info.GetValue("AdditionalParameters", typeof(Dictionary<string, string>));
		}
	}
	base.CollectionChanged += OnCollectionChanged;
}

please also ref to very similar method CompositeDevices(IEnumerable col) that decompiled to foreach!

target: #1601

PS this assemlby has a lot of other locations that are decompiled to while loop instead of much more expected foreach!

Contributor guide