Open cremor opened 6 months ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
Thanks for filing this issue.
```cs
block?Yes, I can still reproduce this with the latest preview versions of VS and the .NET SDK. I've updated the issue description to include this information. And I've also directly included the sample code as requested.
I'm not sure right now whether to classify as a compiler or IDE (suggest using collection-exprs) issue. I'll have to spend a little more time paging in what's going on to do so.
@RikkiGibson this is likely on hte IDE side. However, the core issue is that there are no APis the compiler exposes to know anything here. So we basically have had to reimplement all the logic aronud the rules in the language to know if somethign is a legal collectoin-expr type. that wasn't tenable originally, and it gets even harder as we add more complex and involved rules for collection types. As mentioned originally, the IDE needs apis to know if something is a legal collection expr type. Since that logic already exists in the compiler, we wouldn't have to duplicate it and we could defer directly to that to know if we can even bother offering collection exprs at all.
this is likely on hte IDE side
Aren't the error messages coming from the compiler?
Version Used:
Steps to Reproduce: See comments in the sample:
Sample in SharpLab
My actual project uses https://github.com/FluentValidation/FluentValidation. The sample contains simplified versions of the FluentValidation classes.
Diagnostic Id: Initially
"IDE0028: Collection initialization can be simplified"
. But the following error messages are shown if you modify the sample as explained in the comments:"CS1061: 'InlineValidator<DateTime>' does not contain a definition for 'Add' and no accessible extension method 'Add' accepting a first argument of type 'InlineValidator<DateTime>' could be found"
"CS0029: Cannot implicitly convert type 'int' to 'ConsoleApp1.IValidationRule"
Expected Behavior: I don't expect to see
"IDE0028: Collection initialization can be simplified"
fornew InlineValidator<DateTime>()
. I think this should only be shown if the parameter type of theAdd
method matches the collection type. I expect consistant parameter/element types shown in the error messages if you modify the sample as explained in the comments.Actual Behavior: See comments in the sample code.