- Notifications
You must be signed in to change notification settings - Fork4.2k
Treat record positional parameters as properties#48329
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Treat record positional parameters as properties#48329
Uh oh!
There was an error while loading.Please reload this page.
Conversation
...Portable/Completion/CompletionProviders/DeclarationNameCompletionProvider.DeclarationInfo.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
davidwengier left a comment
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.
May be a nit, but in my opinion it would be nicer to add anIsPrimaryConstructorParameter 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.
Youssef1313 commentedOct 6, 2020
@davidwengier I think I'd still need the lambda parameter if I will rely on |
davidwengier commentedOct 7, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@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 |
Youssef1313 commentedOct 7, 2020
@davidwengier I made it as a separate method as you suggested and relied on calling |
| privatestaticboolIsPrimaryConstructorParameter(SyntaxTokentoken,SemanticModelsemanticModel, | ||
| CancellationTokencancellationToken,outNameDeclarationInforesult) | ||
| { | ||
| result=IsLastTokenOfType<ParameterSyntax>( |
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.
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 tob5732e9Compare| cancellationToken); | ||
| returnresult.Type!=null&& | ||
| token.GetAncestor<ParameterSyntax>().Parent.IsParentKind(SyntaxKind.RecordDeclaration); |
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.
This check should come first, andresult should be default if it fails.
Youssef1313 commentedNov 4, 2020
Closing/re-opening for fresh build. |
Youssef1313 commentedDec 10, 2020
@davidwengier for reviewing after applying review feedback |
davidwengier left a comment
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.
Thanks!
* 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 fromhttps://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