Skip to content

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #79156

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner June 26, 2025 19:09
// can take those constructor arguments and pass them along to the final collection by spreading them.
// If not, then we can't convert this to a collection expression.
var addMethods = this.GetAddMethods(cancellationToken);
if (!addMethods.Any(m => m.Parameters is [{ Type: var parameterType }] && Equals(parameterType, elementType)))
return false;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heuristic was too weak. have tightened it up.

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge June 26, 2025 20:24
@CyrusNajmabadi CyrusNajmabadi merged commit 6b00b6c into dotnet:main Jun 27, 2025
24 of 25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the useCollectionExprInvalidAdd branch June 27, 2025 00:20
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jun 27, 2025
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IDE0028 suggests uncompilable code for an enumerable type with a ctor featuring an optional string parameter
4 participants