Version Used: '4.9.0-2.23578.7 (984df16)'. Language version: 12.0
Steps to Reproduce:
The actual use case is using Xunit.TheoryData<T>, but here's a small repro
public class UnitTest1
{
void A()
{
Sample<string> a = new Sample<string> // IDE0028: Collection expression can be simplified
{
"test",
};
// After applying the fix
Sample<string> a =
[
"test", // CS0029 Cannot implicitly convert type 'string' to 'object[]'
];
}
}
class Sample<T> : IEnumerable<object[]>
{
public void Add(T p) => throw null;
IEnumerator IEnumerable.GetEnumerator() => throw null;
IEnumerator<object[]> IEnumerable<object[]>.GetEnumerator() => throw null;
}
Diagnostic Id: IDE0028
Expected Behavior: The code is valid after applying the code fix
Actual Behavior: The build fails
Version Used: '4.9.0-2.23578.7 (984df16)'. Language version: 12.0
Steps to Reproduce:
The actual use case is using
Xunit.TheoryData<T>, but here's a small reproDiagnostic Id: IDE0028
Expected Behavior: The code is valid after applying the code fix
Actual Behavior: The build fails