microsoft / microsoft/vs-threading
Cannot refer to a property/accessor in MainThreadAssertingMethods and hence VSTHRD010
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1k
- Forks
- 160
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 28
Description
Bug description
CPS/.NET Project System both use an interface shaped like below to access IVsXXX interfaces:
internal interface IVsUIService<T>
where T : class?
{
T Value { get; }
}
Dereferencing Value ensures that the caller is on the UI thread. Usage is as follows:
this.Solution.Value.GetProjrefOfItem(Hierarchy, unchecked((uint)node.Identity.ToInt32()), out projref))
I would want to indicate this in MainThreadAssertingMethods like so:
[Microsoft.VisualStudio.ProjectSystem.VS.Implementation.IVsUIService`1]::get_Value
-or-
[Microsoft.VisualStudio.ProjectSystem.VS.Implementation.IVsUIService`2]::Value
However, it appears that VSTHRD010 doesn't seem to consider property invocations as validating that we're on the UI thread:
Severity Code Description Project File Line Suppression State
Message VSTHRD010 Accessing "IVsSolution" should only be done on the main thread. Call Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread() first. Microsoft.VisualStudio.ProjectSystem.VS.Implementation C:\CPS\src\Microsoft.VisualStudio.ProjectSystem.VS.Implementation\Package\CopyPaste\VsStorageProjectItemsPackager.cs 108 Active
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating MainThreadAssertingMethods and the VSTHRD010 analyzer logic that matches asserted members. Reproduce the issue with the shown IVsUIService.Value accessor and the [IVsUIService`1]::get_Value or ::Value forms. Done means the configured property/accessor is recognized as a main-thread assertion and the diagnostic is no longer reported for the shown access.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100