-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Implement control flow graph for Lock object feature #71987
Implement control flow graph for Lock object feature #71987
Conversation
src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.cs
Outdated
Show resolved
Hide resolved
Done with review pass (commit 1). |
src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/IOperation/IOperation/IOperationTests_ILockStatement.cs
Outdated
Show resolved
Hide resolved
src/Compilers/VisualBasic/Test/IOperation/IOperation/IOperationTests_ILockStatement.vb
Show resolved
Hide resolved
Done with review pass (commit 17) |
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 17), assuming CI is passing.
} | ||
|
||
[Fact, CompilerTrait(CompilerFeature.IOperation, CompilerFeature.Dataflow)] | ||
public void LockFlow_LockObject_Conditional_Object() |
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.
We should also have tests with conditional flow inside the body of the lock itself. #Resolved
if (!(scopeType is INamedTypeSymbol { Name: WellKnownMemberNames.LockScopeTypeName, Arity: 0, IsValueType: true, IsRefLikeType: true, DeclaredAccessibility: Accessibility.Public } && | ||
lockType.Equals(scopeType.ContainingType, SymbolEqualityComparer.ConsiderEverything))) |
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.
Please either do the DeMorgan's expansion, or indent the second line of this if
so it doesn't imply that the Equals
call is outside the parens.
if (!(scopeType is INamedTypeSymbol { Name: WellKnownMemberNames.LockScopeTypeName, Arity: 0, IsValueType: true, IsRefLikeType: true, DeclaredAccessibility: Accessibility.Public } && | |
lockType.Equals(scopeType.ContainingType, SymbolEqualityComparer.ConsiderEverything))) | |
if (scopeType is not INamedTypeSymbol { Name: WellKnownMemberNames.LockScopeTypeName, Arity: 0, IsValueType: true, IsRefLikeType: true, DeclaredAccessibility: Accessibility.Public } || | |
!lockType.Equals(scopeType.ContainingType, SymbolEqualityComparer.ConsiderEverything)) | |
``` #Resolved |
internal const string LockTypeName = "Lock"; | ||
internal const string EnterLockScopeMethodName = "EnterLockScope"; | ||
internal const string LockScopeTypeName = "Scope"; |
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.
We'll probably want to see if API review wants these to be public.
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.
We'll probably want to see if API review wants these to be public.
We can certainly consider that, but we don't have to make them public "by default".
<value>A value of type 'System.Threading.Lock' in SyncLock will use likely unintended monitor-based locking. Consider manually calling 'Enter' and 'Exit' methods in a Try/Finally block instead.</value> | ||
</data> | ||
<data name="WRN_LockTypeUnsupported_Title" xml:space="preserve"> | ||
<data name="ERR_LockTypeUnsupported" xml:space="preserve"> | ||
<value>A value of type 'System.Threading.Lock' in SyncLock will use likely unintended monitor-based locking. Consider manually calling 'Enter' and 'Exit' methods in a Try/Finally block instead.</value> |
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 error should be reworded, since it should no longer imply that Lock
is supported, but a warning. #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.
Would something like this work? "A value of type 'System.Threading.Lock' is not supported in SyncLock. Consider manually calling 'Enter' and 'Exit' methods in a Try/Finally block instead."
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 error should be reworded, since it should no longer imply that Lock is supported, but a warning.
What wording do you suggest?
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.
Something like what @jjonescz suggested would work.
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 20)
Test plan: #71888