Skip to content

Support modifiers with simple lambda parameters.#75400

Merged
CyrusNajmabadi merged 126 commits intodotnet:mainfrom
CyrusNajmabadi:refLambdas
Jan 16, 2025
Merged

Support modifiers with simple lambda parameters.#75400
CyrusNajmabadi merged 126 commits intodotnet:mainfrom
CyrusNajmabadi:refLambdas

Conversation

@CyrusNajmabadi
Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi commented Oct 4, 2024

@ghost ghost added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 4, 2024
var isAnonymousMethod = syntax.IsKind(SyntaxKind.AnonymousMethodExpression);
if (p.Default != null)
{
if (firstDefault == -1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this logic moved from teh caller. no need for it to do a secondary pass to report errors when it can just do that here.


var lambda = AnalyzeAnonymousFunction(syntax, diagnostics);
var data = lambda.Data;
if (data.HasExplicitlyTypedParameterList)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this logic moved into AnalyzeAnonymousFunction. In particular, we want check parameters unilaterally even if there are types or no types (since we want to check modifier usage in the latter case). so the HasExplicitlyTypedParameterList had to go.

if (lambdaParameterType.IsErrorType())
{
continue;
}
Copy link
Contributor Author

@CyrusNajmabadi CyrusNajmabadi Oct 5, 2024

Choose a reason for hiding this comment

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

this waas already checked above on line 2107. no need to check again.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner January 15, 2025 21:54
@CyrusNajmabadi CyrusNajmabadi enabled auto-merge (squash) January 15, 2025 21:57
Assert.Equal(MethodKind.LambdaMethod, symbol.MethodKind);
Assert.Equal(RefKind.RefReadOnlyParameter, symbol.Parameters.Single().RefKind);
Assert.Equal(SpecialType.System_Int32, symbol.Parameters.Single().Type.SpecialType);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

}

Consider testing:

delegate void D(ref readonly int x);

D d = (ref x) => { };

<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedMembers\CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\CSharpUseCollectionInitializerDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseImplicitlyTypedLambdaExpression\UseImplicitlyTypedLambdaExpressionDiagnosticAnalyzer.cs" />
Copy link
Contributor

Choose a reason for hiding this comment

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

UseImplicitlyTypedLambdaExpressionDiagnosticAnalyzer.cs

Is this file included in the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no. this was for anotehr branch. removing.

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge (squash) January 15, 2025 22:36
@CyrusNajmabadi CyrusNajmabadi merged commit 8c05cc8 into dotnet:main Jan 16, 2025
24 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jan 16, 2025
@CyrusNajmabadi CyrusNajmabadi deleted the refLambdas branch January 16, 2025 01:39
333fred added a commit to 333fred/roslyn that referenced this pull request Jan 16, 2025
* upstream/main: (172 commits)
  Move impl of ILspWorkpace to EditorTestWorkspace/LspTestWorkspace (dotnet#76753)
  Field-backed properties: report diagnostic for variable named field declared in accessor (dotnet#76671)
  Add more tests
  Update 'use nameof instead of typeof' to support generic types
  Update dependencies from https://github.com/dotnet/arcade build 20250115.2
  Add docs
  invert
  Update src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems
  Update options
  Fixup tests
  fixup options
  Update tests
  Add test
  Fix trivia
  Handle params
  Support modifiers with simple lambda parameters. (dotnet#75400)
  Handle params
  Use helper
  Add fixes
  Flesh out
  ...
@dibarbet dibarbet modified the milestones: Next, 17.14 P1 Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants