-
Notifications
You must be signed in to change notification settings - Fork 4.1k
In SDK 8.0.2xx IDE0300 (collection expression) uses loose type matching which should not happen according to documentation #72532
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
Comments
The docs are incorrect if they specify .net9. |
Forgot to add that it the issue does not appear in 8.0.1xx - exact type match is used here. Docs say:
|
Yeah. Looks like a doc bug. There's no association with this feature and version 9. |
@gewarren You added the wrong documentation in dotnet/docs#39199. Is this issue enough to get the documentation fixed or should we create a new issue in dotnet/docs? |
@gewarren Sorry for hijacking this issue, but I think there are a few other small issues with that EditorConfig setting documentation that could be fixed at the same time: a) IDE0302 doesn't mention the new options. I saw that you discussed this with @CyrusNajmabadi in dotnet/docs#39199 (review). But the current situation is not perfect either, because the page now mentions a wrong default value for the setting itself (even if that default value b) IDE0028 should also mention the additional option and changed default value. |
@genlu Can you transfer this to the dotnet/docs repo? |
What is the reason for |
Most code does not need the runtime type to be exactly the same. This also follows the default of nearly all our other fixers which will change semantics based on common patterns and normal user coding styles. Allowing the type to change also enables more compiler optimization possibilities. So this allows the majority of code to move over by default, while getting more succinct and faster, but with a small risk of an undesired change happening. Users who don't like that can opt into the stricter mode. |
Can someone please transfer this issue to the dotnet/docs repo? |
Version Used:
SDK 8.0.202
Steps to Reproduce:
Diagnostic Id:
IDE0300, but others that depend on
dotnet_style_prefer_collection_expression
probably behave the same.Expected Behavior:
The analyzer should not trigger. According to documentation at https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0300 loose type matching is behavior from .Net 9 and later. Unless 8.0.202 somehow is not .Net 8, it should default to exact match.
Of course it's also possible that the documentation is wrong.
Actual Behavior:
The analyzer triggers, see build output above.
The text was updated successfully, but these errors were encountered: