Closed as not planned
Closed as not planned
Description
Version Used:
Version 17.11.0 Preview 1.0 [34804.211.main]
Steps to Reproduce:
using System.Collections;
MyCollection<object> c = new() { "Hello" };
class MyCollection<T> : IEnumerable<T[]>
{
public void Add(T item) { }
public IEnumerator<T[]> GetEnumerator() => throw new NotImplementedException();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
Diagnostic Id:
IDE0028
Expected Behavior:
No diagnostics.
Actual Behavior:
IDE0028 triggers and the fixer rewrites the new() { "Hello" }
to be ["Hello"]
, which then fails to compile with error CS0029: Cannot implicitly convert type 'string' to 'object[]'
.
cc: @CyrusNajmabadi
Metadata
Metadata
Assignees
Type
Projects
Status
Completed