You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VSTHRD012 wrongly reported on private/internal members #1111
To address the issue where VSTHRD012 is reported when there is a private overload of a method with a JTF (JoinableTaskFactory) parameter, you can follow these steps:
Identify the Problem: The issue seems to be related to the naming conflict between the public and private methods. When both methods have the same name, it triggers VSTHRD012.
Rename the Private Method: To resolve this issue, you should rename the private method to something that does not conflict with the public method. Here's an example of how you can modify your code:
Update the Usage: After renaming the private method, you'll need to update any usage of the private method with the new name. In this case, you should change OnMainThread to RunOnMainThread:
Extensions.RunOnMainThread(()=>{})// This should no longer report VSTHRD012
Test and Verify: Ensure that the code now works as expected and that VSTHRD012 is no longer reported.
By renaming the private method to something distinct from the public method, you avoid the naming conflict that was triggering the VSTHRD012 warning. This should resolve the issue as expected.
Activity
sujitmahapatra commentedon Oct 3, 2023
To address the issue where VSTHRD012 is reported when there is a private overload of a method with a JTF (JoinableTaskFactory) parameter, you can follow these steps:
Identify the Problem: The issue seems to be related to the naming conflict between the public and private methods. When both methods have the same name, it triggers VSTHRD012.
Rename the Private Method: To resolve this issue, you should rename the private method to something that does not conflict with the public method. Here's an example of how you can modify your code:
OnMainThreadtoRunOnMainThread:By renaming the private method to something distinct from the public method, you avoid the naming conflict that was triggering the VSTHRD012 warning. This should resolve the issue as expected.
Fix VSTHRD012 false positive due to inaccessible overloads