Treat record positional parameters as properties#48329
Treat record positional parameters as properties#48329davidwengier merged 6 commits intodotnet:masterfrom
Conversation
...Portable/Completion/CompletionProviders/DeclarationNameCompletionProvider.DeclarationInfo.cs
Outdated
Show resolved
Hide resolved
davidwengier
left a comment
There was a problem hiding this comment.
May be a nit, but in my opinion it would be nicer to add an IsPrimaryConstructorParameter method to handle this case, and save having to add a parameter to the lambda in this way. It would also make the resulting code self documenting.
|
@davidwengier I think I'd still need the lambda parameter if I will rely on |
|
@Youssef1313 I haven't thought it through completely, so if you think its not possible, or any better, that's cool, I just pictured something like the tuple handling (see |
|
@davidwengier I made it as a separate method as you suggested and relied on calling |
| private static bool IsPrimaryConstructorParameter(SyntaxToken token, SemanticModel semanticModel, | ||
| CancellationToken cancellationToken, out NameDeclarationInfo result) | ||
| { | ||
| result = IsLastTokenOfType<ParameterSyntax>( |
There was a problem hiding this comment.
By the way, the method name here is very confusing. The name suggests that it returns a bool, but it doesn't.
I would suggest an analyzer to warn for things like this.
Would this be an IDExxxx rule or a CAxxxx rule?
347d428 to
b5732e9
Compare
| cancellationToken); | ||
|
|
||
| return result.Type != null && | ||
| token.GetAncestor<ParameterSyntax>().Parent.IsParentKind(SyntaxKind.RecordDeclaration); |
There was a problem hiding this comment.
This check should come first, and result should be default if it fails.
|
Closing/re-opening for fresh build. |
|
@davidwengier for reviewing after applying review feedback |
* upstream/master: (241 commits) Allow pattern matching `null` against pointer types when the pointer types contain nested type parameters (dotnet#49915) Remove document extension method and convert usages to use the text buffer extension method. VB: Strengthen implementation of `PropertySymbol.IsWritable` against NullReferenceException (dotnet#49962) Add switch to skip nullable analysis (dotnet#49876) Update dependencies from https://github.com/dotnet/roslyn build 20201211.16 (dotnet#49958) Treat record positional parameters as properties (dotnet#48329) [master] Update dependencies from dotnet/roslyn (dotnet#49395) VB: Ensure array access indexes undergo conversion to integer even when there is a mismatch with array rank. (dotnet#49907) Disable OOP when running as cloud environment client VS instance Rename workspace context method (and unify impls) to better represent the condition being checked Report non-Const locals used in an expression that must have a constant value. (dotnet#49912) Add support for more ServiceAudience values (dotnet#49914) Handle ref-containing structs returned by value from function-pointers (dotnet#49883) Fix error on out param of extern local function (dotnet#49860) Fix constructor exit warnings for generic NotNull (dotnet#49841) Loc updates Prefer more specific path map key (dotnet#49670) Rename `_availablelocalFunctionOrdinal` to `_availableLocalFunctionOrdinal` (dotnet#49901) Fix namespace so that external access wrapper type can be accessed from UT. XamlProjectService fixes (dotnet#49711) ...
Fixes #48310