Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type cannot be used in 'foreach' statement because it neither implements 'IEnumerable' or 'IEnumerable<T>', nor has suitable 'GetEnumerator' method which return type has 'Current' property and 'MoveNext' method #2395

Closed
marwie opened this issue May 5, 2021 · 0 comments
Labels
Bug Decompiler The decompiler engine itself

Comments

@marwie
Copy link
Contributor

marwie commented May 5, 2021

Input code

Please see #2389

Erroneous output

<UnityEditor>\UnityEditor\ProfilerWindow.cs:20670 Type 'UnityEditor.Profiling.DynamicProfilerModule.SerializedDataCollection' cannot be used in 'foreach' statement because it neither implements 'IEnumerable' or 'IEnumerable<T>', nor has suitable 'GetEnumerator' method which return type has 'Current' property and 'MoveNext' method

private void InstantiateDynamicProfilerModules(List<ProfilerModuleBase> outModules)
{
	string @string = EditorPrefs.GetString("ProfilerWindow.DynamicModules");
	DynamicProfilerModule.SerializedDataCollection serializedDataCollection = JsonUtility.FromJson<DynamicProfilerModule.SerializedDataCollection>(@string);
	if (serializedDataCollection != null)
	{
		foreach (DynamicProfilerModule.SerializedData serializedData in serializedDataCollection)
		{
			DynamicProfilerModule item = DynamicProfilerModule.CreateFromSerializedData(serializedData, m_ProfilerWindowControllerProxy);
			outModules.Add(item);
		}
	}
}
[Serializable]
public class SerializedDataCollection
{
	public List<SerializedData> m_Modules = new List<SerializedData>();
	public int Length => m_Modules.Count;
	public SerializedData this[int index] => m_Modules[index];
        [...]

image

Details

Please see #2389

@marwie marwie added Bug Decompiler The decompiler engine itself labels May 5, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
ElektroKill pushed a commit to dnSpyEx/ILSpy that referenced this issue Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

1 participant