-
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
[semi-auto-props]: Refactor and rename 'AccessingAutoPropertyFromConstructor' #58832
[semi-auto-props]: Refactor and rename 'AccessingAutoPropertyFromConstructor' #58832
Conversation
src/Compilers/CSharp/Portable/FlowAnalysis/DefiniteAssignment.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/FlowAnalysis/DefiniteAssignment.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/FlowAnalysis/DefiniteAssignment.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbolBase.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbolBase.cs
Outdated
Show resolved
Hide resolved
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.
@AlekseyTs Just to clarify, I renamed the method name per my understanding to the caller in Binder.ValueChecks.cs
For AbstractFlowPass
, I'm not sure how the method should behave. I tried to see if #58833 can help me understand more, but looks like there is no good test coverage? This is something I hope you can provide some explanation/hints for.
For DefiniteAssignment
, I haven't taken a look at all. Waiting for LDM decision around what behavior we want.
So if the name and implementation make sense for the caller in Binder.ValueChecks.cs
, we probably want other APIs for other callers?
Yes, it is very likely we will need to replace one API with several more specific abstractions. |
It looks like this helper is specifically used to examine write access. And it looks like it is deciding if the write access is equivalent to white access on a backing field. I think it would be good to reflect that in its name and the comment. Refers to: src/Compilers/CSharp/Portable/FlowAnalysis/AbstractFlowPass.cs:1911 in 6748146. [](commit_id = 6748146, deletion_comment = False) |
Done with review pass (commit 1) In reply to: 1012312365 |
@AlekseyTs Feedback around DefiniteAssignment isn't yet addressed. Other comments are "hopefully" addressed. |
sourceProperty.IsAutoPropertyWithGetAccessor && | ||
return propertySymbol is SourcePropertySymbolBase sourceProperty && | ||
// To be assigned through backing field, either SetMethod is null, or it's equivalent to backing field write | ||
// PROTOTYPE(semi-auto-props): TODO: Do we need to use `GetOwnOrInheritedSetMethod` instead of `SetMethod`? Add tests. |
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.
I tried to find a scenario that can be affected by this, but couldn't. @AlekseyTs Can you think of any? if not we can delete this prototype 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.
I tried to find a scenario that can be affected by this, but couldn't. Can you think of any? if not we can delete this prototype comment.
Legacy auto-properties are required to override all accessors. Therefore, we don't need to worry about an overriding case for them. If that invariant is "broken" for semi-auto properties, then I think we will need to strengthen the check, detect the presence of an inherited setter and return false for that case. Capturing this information in a PROTOTYPE comment would be useful.
src/Compilers/CSharp/Portable/FlowAnalysis/DefiniteAssignment.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenConstructorInitTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Semantic/Semantics/PropertyFieldKeywordTests.cs
Show resolved
Hide resolved
Done with review pass (commit 8) |
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.
LGTM (commit 10)
@333fred, @dotnet/roslyn-compiler For the second review. |
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.
Done review pass. Overall looks fine to me, just one question that could use your input @AlekseyTs.
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.
LGTM (commit 12)
@AlekseyTs I looked through the remaining
Should the next PR be one of those usages? or should it be around semantic model API tests? |
I would suggest one of those things. Public api is often best left to last, when the behavior of the feature is finalized. |
As a quick answer, I do not have a strong preference in terms of what PR should come first. Feel free to decide according to you preference. These issues look orthogonal (independent) to me and could be worked on in parallel in different PRs. One is test only, the other a refactoring in implementation. My preference is that we complete these work items before starting focusing on supporting new scenarios. |
Got some time today to get a small PR :)
Test plan: #57012