vs-threading icon indicating copy to clipboard operation
vs-threading copied to clipboard

Cannot refer to a property/accessor in MainThreadAssertingMethods and hence VSTHRD010

Open davkean opened this issue 5 years ago • 0 comments

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

davkean avatar Oct 08 '20 07:10 davkean