-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Update 'initialize member from parameter' to work with primary constructors. #69072
Update 'initialize member from parameter' to work with primary constructors. #69072
Conversation
@@ -56,55 +56,10 @@ protected override SyntaxNode GetBody(SyntaxNode functionDeclaration) | |||
=> InitializeParameterHelpers.GetBody(functionDeclaration); | |||
|
|||
protected override SyntaxNode? GetAccessorBody(IMethodSymbol accessor, CancellationToken cancellationToken) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to common helper locations.
@@ -314,19 +316,6 @@ internal abstract partial class AbstractInitializeMemberFromParameterCodeRefacto | |||
throw ExceptionUtilities.Unreachable(); | |||
} | |||
|
|||
private static string GenerateUniqueName(IParameterSymbol parameter, ImmutableArray<string> parameterNameParts, NamingRule rule) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to common helper location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same with the other deletions in the file
{ | ||
internal static class InitializeParameterHelpersCore | ||
{ | ||
public static ImmutableArray<(IParameterSymbol parameter, bool before)> GetSiblingParameters(IParameterSymbol parameter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are just moves of helpers.
@@ -138,5 +142,86 @@ public static bool IsExpressionBody(SyntaxNode body) | |||
_ => throw ExceptionUtilities.UnexpectedValue(body), | |||
}; | |||
} | |||
|
|||
public static SyntaxNode? GetAccessorBody(IMethodSymbol accessor, CancellationToken cancellationToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are just moves of helpers.
...izeParameter/CSharpInitializeMemberFromPrimaryConstructorParameterCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
...izeParameter/CSharpInitializeMemberFromPrimaryConstructorParameterCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
var outParameters = parameterList.Parameters | ||
.Select(p => semanticModel.GetRequiredDeclaredSymbol(p, cancellationToken)) | ||
.Where(p => p.RefKind == RefKind.Out) | ||
.ToImmutableArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cast removed as this now uses a typesafe extension.
Fixes #68817
Looks like this:
QOL for people using primary constructors. Just like witha normal constructor, we want to make it easy to be writing the constructor and then have the user go and create fields/props easily.
Fixes #68817