├── .prettierrc.yaml
├── azure-pipelines
├── no_strongname.txt
├── no_authenticode.txt
├── BuildStageVariables.yml
├── NuGetSbom.props
├── release-deployment-prep.yml
├── GlobalVariables.yml
├── TSAOptions.json
├── microbuild.after.yml
├── vs-insertion-script.ps1
├── PoliCheckExclusions.xml
├── Get-InsertionPRId.ps1
├── microbuild.before.yml
├── publish-codecoverage.yml
├── WIFtoPATauth.yml
├── install-dependencies.yml
├── publish_artifacts.ps1
└── PostPRMessage.ps1
├── docfx
├── .gitignore
├── images
│ ├── fsa.png
│ ├── blocked_time.png
│ ├── blocked_time_callers.png
│ ├── vs_threadpoolstarvation_event.jpg
│ └── cpu_stacks_showing_threadpool_starvation.png
├── toc.yml
├── docs
│ ├── toc.yml
│ ├── getting-started.md
│ ├── features.md
│ └── testing_vs.md
├── index.md
├── analyzers
│ ├── fsa.md
│ ├── toc.yml
│ ├── VSTHRD107.md
│ ├── VSTHRD114.md
│ ├── VSTHRD109.md
│ ├── VSTHRD012.md
│ ├── VSTHRD004.md
│ ├── VSTHRD104.md
│ ├── VSTHRD106.md
│ ├── VSTHRD103.md
│ ├── VSTHRD200.md
│ ├── VSTHRD113.md
│ ├── VSTHRD002.md
│ ├── VSTHRD102.md
│ ├── VSTHRD100.md
│ ├── VSTHRD115.md
│ ├── VSTHRD108.md
│ └── VSTHRD011.md
└── docfx.json
├── tools
├── variables
│ ├── ShouldSkipOptimize.ps1
│ ├── SymbolsFeatureName.ps1
│ ├── BusinessGroupName.ps1
│ ├── InsertTargetBranch.ps1
│ ├── VstsDropNames.ps1
│ ├── DotNetSdkVersion.ps1
│ ├── LocLanguages.ps1
│ ├── ProfilingInputsPropsName.ps1
│ ├── ProfilingInputsDropName.ps1
│ ├── InsertVersionsValues.ps1
│ ├── InsertPropsValues.ps1
│ ├── _all.ps1
│ ├── InsertJsonValues.ps1
│ └── _define.ps1
├── dirs.proj
├── artifacts
│ ├── projectAssetsJson.ps1
│ ├── test_symbols.ps1
│ ├── build_logs.ps1
│ ├── symbols.ps1
│ ├── testResults.ps1
│ ├── APIScanInputs.ps1
│ ├── LocBin.ps1
│ ├── deployables.ps1
│ ├── coverageResults.ps1
│ ├── VSInsertion.ps1
│ └── Variables.ps1
├── Get-TempToolsPath.ps1
├── Get-ArtifactsStagingDirectory.ps1
├── Get-ProcDump.ps1
├── Get-NuGetTool.ps1
├── Get-LibTemplateBasis.ps1
├── publish-CodeCov.ps1
├── Check-DotNetSdk.ps1
├── Check-DotNetRuntime.ps1
├── Prepare-Legacy-Symbols.ps1
└── Convert-PDB.ps1
├── .github
├── .editorconfig
├── ISSUE_TEMPLATE
│ ├── Bug_report.md
│ └── Feature_request.md
├── renovate.json
├── copilot-instructions.md
└── workflows
│ ├── docs_validate.yml
│ ├── docs.yml
│ └── copilot-setup-steps.yml
├── CodeQL.yml
├── test
├── Microsoft.VisualStudio.Threading.Tests
│ ├── .gitignore
│ ├── xunit.runner.json
│ ├── .editorconfig
│ ├── Usings.cs
│ ├── AssemblyInfo.cs
│ ├── App.config
│ ├── ValidityTests.cs
│ ├── GenericParameterHelper.cs
│ ├── ReentrantSemaphoreNonJTFTests.cs
│ ├── TestUtilitiesTests.cs
│ ├── AssertEx.cs
│ └── InternalUtilitiesTests.cs
├── Microsoft.VisualStudio.Threading.Analyzers.Tests
│ ├── AdditionalFiles
│ │ ├── vs-threading.MainThreadSwitchingMethods.mocks.txt
│ │ ├── vs-threading.SyncMethodsToExcludeFromVSTHRD103.mocks.txt
│ │ ├── vs-threading.MainThreadAssertingMethods.mocks.txt
│ │ ├── vs-threading.LegacyThreadSwitchingMembers.mocks.txt
│ │ └── vs-threading.MembersRequiringMainThread.mocks.txt
│ ├── xunit.runner.json
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Usings.cs
│ ├── VSTHRD100AsyncVoidMethodCodeFixTests.cs
│ └── Helpers
│ │ ├── CSharpCodeFixVerifier`2.cs
│ │ └── VisualBasicCodeFixVerifier`2.cs
├── NativeAOTCompatibility.Test
│ ├── Program.cs
│ └── NativeAOTCompatibility.Test.csproj
├── IsolatedTestHost
│ ├── IsolatedTestHost.csproj
│ ├── App.config
│ ├── TestOutputHelper.cs
│ └── ExitCode.cs
├── Microsoft.VisualStudio.Threading.Tests.Win7RegistryWatcher
│ ├── App.config
│ ├── Microsoft.VisualStudio.Threading.Tests.Win7RegistryWatcher.csproj
│ └── Program.cs
├── dirs.proj
├── Directory.Build.props
├── AOT.props
├── Directory.Build.targets
└── Directory.Packages.props
├── settings.VisualStudio.json
├── src
├── PackageIcon.png
├── Microsoft.VisualStudio.Threading
│ ├── NativeMethods.txt
│ ├── GlobalSuppressions.cs
│ ├── CustomDictionary.xml
│ ├── Reasons.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── EmptyStruct.cs
│ ├── SemaphoreFaultedException.cs
│ ├── IAsyncDisposable.cs
│ ├── IHangReportContributor.cs
│ ├── IllegalSemaphoreUsageException.cs
│ ├── Boxed.cs
│ ├── RoslynDebug.cs
│ ├── IPendingExecutionRequestState.cs
│ ├── JoinableTaskCreationOptions.cs
│ ├── AsyncEventHandler.cs
│ ├── AsyncLocal`1.cs
│ ├── LightUps.cs
│ ├── README.md
│ ├── RegistryChangeNotificationFilters.cs
│ ├── InternalUtilities.cs
│ ├── NullableHelpers.cs
│ ├── JoinableTaskInternals.cs
│ ├── IJoinableTaskDependent.cs
│ └── JoinableTaskContextException.cs
├── Microsoft.VisualStudio.Threading.Analyzers.CodeFixes
│ ├── buildTransitive
│ │ ├── AdditionalFiles
│ │ │ ├── vs-threading.MembersRequiringMainThread.txt
│ │ │ ├── vs-threading.MainThreadAssertingMethods.txt
│ │ │ ├── vs-threading.MainThreadSwitchingMethods.txt
│ │ │ └── vs-threading.LegacyThreadSwitchingMembers.txt
│ │ └── Microsoft.VisualStudio.Threading.Analyzers.targets
│ ├── version.json
│ ├── README.md
│ ├── AssemblyInfo.cs
│ ├── NullableHelpers.cs
│ └── tools
│ │ ├── install.ps1
│ │ └── uninstall.ps1
├── dirs.proj
├── Microsoft.VisualStudio.Threading.Analyzers
│ ├── Usings.cs
│ ├── version.json
│ ├── AssemblyInfo.cs
│ ├── Microsoft.VisualStudio.Threading.Analyzers.csproj
│ └── LanguageUtils.cs
├── Microsoft.VisualStudio.Threading.Analyzers.CSharp
│ ├── version.json
│ ├── AssemblyInfo.cs
│ ├── CSharpVSTHRD011UseAsyncLazyAnalyzer.cs
│ ├── CSharpVSTHRD012SpecifyJtfWhereAllowed.cs
│ ├── CSharpVSTHRD114AvoidReturningNullTaskAnalyzer.cs
│ ├── CSharpVSTHRD109AvoidAssertInAsyncMethodsAnalyzer.cs
│ ├── CSharpVSTHRD110ObserveResultOfAsyncCallsAnalyzer.cs
│ ├── CSharpVSTHRD001UseSwitchToMainThreadAsyncAnalyzer.cs
│ ├── CSharpVSTHRD004AwaitSwitchToMainThreadAsyncAnalyzer.cs
│ ├── CSharpVSTHRD108AssertThreadRequirementUnconditionally.cs
│ ├── CSharpVSTHRD105AvoidImplicitTaskSchedulerCurrentAnalyzer.cs
│ ├── CSharpVSTHRD112ImplementSystemIAsyncDisposableAnalyzer.cs
│ └── Microsoft.VisualStudio.Threading.Analyzers.CSharp.csproj
├── Microsoft.VisualStudio.Threading.Analyzers.VisualBasic
│ ├── version.json
│ ├── AssemblyInfo.cs
│ ├── VisualBasicVSTHRD011UseAsyncLazyAnalyzer.cs
│ ├── VisualBasicVSTHRD012SpecifyJtfWhereAllowed.cs
│ ├── VisualBasicVSTHRD114AvoidReturningNullTaskAnalyzer.cs
│ ├── VisualBasicVSTHRD109AvoidAssertInAsyncMethodsAnalyzer.cs
│ ├── VisualBasicVSTHRD110ObserveResultOfAsyncCallsAnalyzer.cs
│ ├── VisualBasicVSTHRD001UseSwitchToMainThreadAsyncAnalyzer.cs
│ ├── VisualBasicVSTHRD004AwaitSwitchToMainThreadAsyncAnalyzer.cs
│ ├── VisualBasicVSTHRD108AssertThreadRequirementUnconditionally.cs
│ ├── VisualBasicVSTHRD112ImplementSystemIAsyncDisposableAnalyzer.cs
│ ├── VisualBasicVSTHRD105AvoidImplicitTaskSchedulerCurrentAnalyzer.cs
│ └── Microsoft.VisualStudio.Threading.Analyzers.VisualBasic.csproj
├── AssemblyInfo.cs
├── AssemblyInfo.vb
├── SosThreadingTools
│ ├── ICommandHandler.cs
│ ├── GalleryManifest.xml
│ ├── ExtensionContext.cs
│ ├── Commands.cs
│ └── SosThreadingTools.csproj
├── Directory.Build.targets
├── .editorconfig
├── OptProf.targets
├── LibraryNuspecProperties.props
├── Directory.Build.props
└── Microsoft.VisualStudio.Threading.JointPackage
│ └── Microsoft.VisualStudio.Threading.JointPackage.csproj
├── doc
├── editorconfigs
│ ├── SharedLibrary.editorconfig
│ ├── Tests.editorconfig
│ ├── JTFFocusedLibrary.editorconfig
│ ├── AppWithMainThread.editorconfig
│ └── AppWithoutMainThread.editorconfig
└── analyzers
│ ├── VSTHRD001.md
│ ├── VSTHRD002.md
│ ├── VSTHRD003.md
│ ├── VSTHRD004.md
│ ├── VSTHRD010.md
│ ├── VSTHRD011.md
│ ├── VSTHRD012.md
│ ├── VSTHRD100.md
│ ├── VSTHRD101.md
│ ├── VSTHRD102.md
│ ├── VSTHRD103.md
│ ├── VSTHRD104.md
│ ├── VSTHRD105.md
│ ├── VSTHRD106.md
│ ├── VSTHRD107.md
│ ├── VSTHRD108.md
│ ├── VSTHRD109.md
│ ├── VSTHRD110.md
│ ├── VSTHRD111.md
│ ├── VSTHRD112.md
│ ├── VSTHRD113.md
│ ├── VSTHRD114.md
│ ├── VSTHRD115.md
│ └── VSTHRD200.md
├── .azuredevops
└── dependabot.yml
├── loc
└── lci
│ ├── SosThreadingToolsManaged.dll.lci
│ ├── Microsoft.VisualStudio.Threading.dll.lci
│ └── Microsoft.VisualStudio.Threading.Analyzers.dll.lci
├── version.json
├── global.json
├── azurepipelines-coverage.yml
├── Directory.Build.targets
├── .vscode
├── tasks.json
├── launch.json
├── extensions.json
└── settings.json
├── nuget.config
├── init.cmd
├── stylecop.json
├── azure-pipelines.yml
├── Directory.Build.rsp
├── .config
└── dotnet-tools.json
├── SUPPORT.md
├── Directory.Traversal.targets
├── LICENSE
├── samples
├── samples.csproj
├── ApiSamples.cs
└── .editorconfig
└── README.md
/.prettierrc.yaml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/azure-pipelines/no_strongname.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docfx/.gitignore:
--------------------------------------------------------------------------------
1 | _site/
2 | api/
3 |
--------------------------------------------------------------------------------
/tools/variables/ShouldSkipOptimize.ps1:
--------------------------------------------------------------------------------
1 | 'false'
2 |
--------------------------------------------------------------------------------
/tools/variables/SymbolsFeatureName.ps1:
--------------------------------------------------------------------------------
1 | 'MS.VS.Threading'
2 |
--------------------------------------------------------------------------------
/.github/.editorconfig:
--------------------------------------------------------------------------------
1 | [renovate.json*]
2 | indent_style = tab
3 |
--------------------------------------------------------------------------------
/CodeQL.yml:
--------------------------------------------------------------------------------
1 | path_classifiers:
2 | library:
3 | - 'test/**'
4 |
--------------------------------------------------------------------------------
/tools/variables/BusinessGroupName.ps1:
--------------------------------------------------------------------------------
1 | 'Visual Studio - VS Core'
2 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Tests/.gitignore:
--------------------------------------------------------------------------------
1 | FakesAssemblies
2 | Fakes
3 |
--------------------------------------------------------------------------------
/settings.VisualStudio.json:
--------------------------------------------------------------------------------
1 | {
2 | "textEditor.codeCleanup.profile": "profile1"
3 | }
4 |
--------------------------------------------------------------------------------
/docfx/images/fsa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/vs-threading/HEAD/docfx/images/fsa.png
--------------------------------------------------------------------------------
/src/PackageIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/vs-threading/HEAD/src/PackageIcon.png
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading/NativeMethods.txt:
--------------------------------------------------------------------------------
1 | WaitForMultipleObjects
2 | RegNotifyChangeKeyValue
3 |
--------------------------------------------------------------------------------
/docfx/images/blocked_time.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/vs-threading/HEAD/docfx/images/blocked_time.png
--------------------------------------------------------------------------------
/docfx/images/blocked_time_callers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/vs-threading/HEAD/docfx/images/blocked_time_callers.png
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/buildTransitive/AdditionalFiles/vs-threading.MembersRequiringMainThread.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tools/variables/InsertTargetBranch.ps1:
--------------------------------------------------------------------------------
1 | # This is the default branch of the VS repo that we will use to insert into VS.
2 | 'main'
3 |
--------------------------------------------------------------------------------
/doc/editorconfigs/SharedLibrary.editorconfig:
--------------------------------------------------------------------------------
1 | # VSTHRD111: Use .ConfigureAwait(bool)
2 | dotnet_diagnostic.VSTHRD111.severity = warning
3 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD001.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD001.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD002.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD002.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD003.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD003.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD004.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD004.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD010.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD010.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD011.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD011.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD012.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD012.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD100.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD100.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD101.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD101.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD102.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD102.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD103.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD103.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD104.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD104.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD105.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD105.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD106.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD106.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD107.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD107.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD108.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD108.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD109.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD109.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD110.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD110.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD111.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD111.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD112.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD112.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD113.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD113.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD114.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD114.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD115.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD115.html).
2 |
--------------------------------------------------------------------------------
/doc/analyzers/VSTHRD200.md:
--------------------------------------------------------------------------------
1 | This content has been moved to [GitHub Pages](https://microsoft.github.io/vs-threading/analyzers/VSTHRD200.html).
2 |
--------------------------------------------------------------------------------
/tools/variables/VstsDropNames.ps1:
--------------------------------------------------------------------------------
1 | "Products/$env:SYSTEM_TEAMPROJECT/$env:BUILD_REPOSITORY_NAME/$env:BUILD_SOURCEBRANCHNAME/$env:BUILD_BUILDID"
2 |
--------------------------------------------------------------------------------
/docfx/images/vs_threadpoolstarvation_event.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/vs-threading/HEAD/docfx/images/vs_threadpoolstarvation_event.jpg
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/AdditionalFiles/vs-threading.MainThreadSwitchingMethods.mocks.txt:
--------------------------------------------------------------------------------
1 | [Test]::MySwitchingMethodAsync
2 |
--------------------------------------------------------------------------------
/tools/variables/DotNetSdkVersion.ps1:
--------------------------------------------------------------------------------
1 | $globalJson = Get-Content -LiteralPath "$PSScriptRoot\..\..\global.json" | ConvertFrom-Json
2 | $globalJson.sdk.version
3 |
--------------------------------------------------------------------------------
/docfx/images/cpu_stacks_showing_threadpool_starvation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/vs-threading/HEAD/docfx/images/cpu_stacks_showing_threadpool_starvation.png
--------------------------------------------------------------------------------
/azure-pipelines/no_authenticode.txt:
--------------------------------------------------------------------------------
1 | bin\packages\release\vsix\_manifest\manifest.cat,sbom signed
2 | bin\packages\release\vsix\_manifest\spdx_2.2\manifest.cat,sbom signed
3 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/vs-threading/HEAD/src/Microsoft.VisualStudio.Threading/GlobalSuppressions.cs
--------------------------------------------------------------------------------
/src/dirs.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/buildTransitive/AdditionalFiles/vs-threading.MainThreadAssertingMethods.txt:
--------------------------------------------------------------------------------
1 | [System.Windows.Threading.Dispatcher]::VerifyAccess
2 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/xunit.runner.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
3 | "shadowCopy": false
4 | }
5 |
--------------------------------------------------------------------------------
/doc/editorconfigs/Tests.editorconfig:
--------------------------------------------------------------------------------
1 | # These settings are appropriate for test projects.
2 |
3 | # VSTHRD200: Use `Async` naming convention
4 | dotnet_diagnostic.VSTHRD200.severity = none
5 |
--------------------------------------------------------------------------------
/azure-pipelines/BuildStageVariables.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
3 | BuildConfiguration: Release
4 | NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages/
5 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/AdditionalFiles/vs-threading.SyncMethodsToExcludeFromVSTHRD103.mocks.txt:
--------------------------------------------------------------------------------
1 | # Test exclusions for VSTHRD103 analyzer
2 | [TestNamespace.TestClass]::SlowSyncMethod
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Tests/xunit.runner.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
3 | "shadowCopy": false,
4 | "methodDisplay": "method"
5 | }
6 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/buildTransitive/AdditionalFiles/vs-threading.MainThreadSwitchingMethods.txt:
--------------------------------------------------------------------------------
1 | [Microsoft.VisualStudio.Threading.JoinableTaskFactory]::SwitchToMainThreadAsync
2 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/AdditionalFiles/vs-threading.MainThreadAssertingMethods.mocks.txt:
--------------------------------------------------------------------------------
1 | [Test]::VerifyOnUIThread
2 | [Microsoft.VisualStudio.Shell.ThreadHelper]::ThrowIfNotOnUIThread
3 |
--------------------------------------------------------------------------------
/docfx/toc.yml:
--------------------------------------------------------------------------------
1 | items:
2 | - name: Docs
3 | href: docs/
4 | - name: Analyzers
5 | href: analyzers/
6 | - name: API
7 | href: api/
8 | - name: GitHub
9 | href: https://github.com/microsoft/vs-threading
10 |
--------------------------------------------------------------------------------
/tools/variables/LocLanguages.ps1:
--------------------------------------------------------------------------------
1 | ## For faster PR/CI builds localize only for 2 languages, ENU and JPN provide good enough coverage
2 | if ($env:BUILD_REASON -eq 'PullRequest') {
3 | 'ENU,JPN'
4 | } else {
5 | 'VS'
6 | }
7 |
--------------------------------------------------------------------------------
/azure-pipelines/NuGetSbom.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 | 2
5 |
6 |
7 |
--------------------------------------------------------------------------------
/tools/dirs.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/doc/editorconfigs/JTFFocusedLibrary.editorconfig:
--------------------------------------------------------------------------------
1 | # These settings are appropriate for libraries that always run within a process that follows the JoinableTaskFactory rules.
2 |
3 | # VSTHRD111: Use .ConfigureAwait(bool)
4 | dotnet_diagnostic.VSTHRD111.severity = silent
5 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers/Usings.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | global using System.Collections.Immutable;
5 |
--------------------------------------------------------------------------------
/tools/artifacts/projectAssetsJson.ps1:
--------------------------------------------------------------------------------
1 | $ObjRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\obj")
2 |
3 | if (!(Test-Path $ObjRoot)) { return }
4 |
5 | @{
6 | "$ObjRoot" = (
7 | (Get-ChildItem "$ObjRoot\project.assets.json" -Recurse)
8 | );
9 | }
10 |
--------------------------------------------------------------------------------
/tools/artifacts/test_symbols.ps1:
--------------------------------------------------------------------------------
1 | $BinPath = [System.IO.Path]::GetFullPath("$PSScriptRoot/../../bin")
2 | if (!(Test-Path $BinPath)) { return }
3 | $symbolfiles = & "$PSScriptRoot/../Get-SymbolFiles.ps1" -Path $BinPath -Tests | Get-Unique
4 |
5 | @{
6 | "$BinPath" = $SymbolFiles;
7 | }
8 |
--------------------------------------------------------------------------------
/azure-pipelines/release-deployment-prep.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - download: CI
3 | artifact: Variables-Windows
4 | displayName: 🔻 Download Variables-Windows artifact
5 | - powershell: $(Pipeline.Workspace)/CI/Variables-Windows/_define.ps1
6 | displayName: ⚙️ Set pipeline variables based on artifacts
7 |
--------------------------------------------------------------------------------
/doc/editorconfigs/AppWithMainThread.editorconfig:
--------------------------------------------------------------------------------
1 | # This file applies to applications with a main thread, and libraries that may run in them.
2 |
3 | # This file is intentionally empty because the default severity levels for the threading analyzers
4 | # are optimized for these types of projects.
5 |
--------------------------------------------------------------------------------
/docfx/docs/toc.yml:
--------------------------------------------------------------------------------
1 | items:
2 | - href: getting-started.md
3 | - href: features.md
4 | - href: threading_rules.md
5 | - href: cookbook_vs.md
6 | - href: testing_vs.md
7 | - href: library_with_jtf.md
8 | - href: threadpool_starvation.md
9 | - href: async_hang.md
10 | - href: dumpasync.md
11 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers/version.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3 | "inherit": true,
4 | "assemblyVersion": {
5 | "precision": "revision"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/AdditionalFiles/vs-threading.LegacyThreadSwitchingMembers.mocks.txt:
--------------------------------------------------------------------------------
1 | [Microsoft.VisualStudio.Shell.ThreadHelper]::Invoke
2 | [Microsoft.VisualStudio.Shell.ThreadHelper]::InvokeAsync
3 | [Microsoft.VisualStudio.Shell.ThreadHelper]::BeginInvoke
4 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Tests/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 | # xUnit1030: Test methods should not call ConfigureAwait(false)
3 | dotnet_diagnostic.xUnit1030.severity = none
4 | # xUnit1031: Test methods should not use blocking task operations
5 | dotnet_diagnostic.xUnit1031.severity = none
6 |
--------------------------------------------------------------------------------
/.azuredevops/dependabot.yml:
--------------------------------------------------------------------------------
1 | # Please see the documentation for all configuration options:
2 | # https://eng.ms/docs/products/dependabot/configuration/version_updates
3 |
4 | version: 2
5 | updates:
6 | - package-ecosystem: nuget
7 | directory: /
8 | schedule:
9 | interval: monthly
10 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/version.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3 | "inherit": true,
4 | "assemblyVersion": {
5 | "precision": "revision"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Tests/Usings.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | global using Microsoft.VisualStudio.Threading;
5 | global using Xunit;
6 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/version.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3 | "inherit": true,
4 | "assemblyVersion": {
5 | "precision": "revision"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/version.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3 | "inherit": true,
4 | "assemblyVersion": {
5 | "precision": "revision"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/tools/artifacts/build_logs.ps1:
--------------------------------------------------------------------------------
1 | $ArtifactStagingFolder = & "$PSScriptRoot/../Get-ArtifactsStagingDirectory.ps1"
2 |
3 | if (!(Test-Path $ArtifactStagingFolder/build_logs)) { return }
4 |
5 | @{
6 | "$ArtifactStagingFolder/build_logs" = (Get-ChildItem -Recurse "$ArtifactStagingFolder/build_logs")
7 | }
8 |
--------------------------------------------------------------------------------
/docfx/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | _layout: landing
3 | ---
4 |
5 | # Overview
6 |
7 | This is the documentation site for the Microsoft.VisualStudio.Threading library and analyzers.
8 |
9 | Click the Docs or Analyzers heading on the top to read the docs.
10 | Or click the API heading to see API-level documentation.
11 |
--------------------------------------------------------------------------------
/src/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.InteropServices;
5 |
6 | [assembly: DefaultDllImportSearchPaths(DllImportSearchPath.SafeDirectories)]
7 |
--------------------------------------------------------------------------------
/src/AssemblyInfo.vb:
--------------------------------------------------------------------------------
1 | ' Copyright (c) Microsoft Corporation. All rights reserved.
2 | ' Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | Imports System.Runtime.InteropServices
5 |
6 |
7 |
--------------------------------------------------------------------------------
/tools/variables/ProfilingInputsPropsName.ps1:
--------------------------------------------------------------------------------
1 | if ($env:SYSTEM_TEAMPROJECT) {
2 | $repoName = $env:BUILD_REPOSITORY_NAME.Replace('/', '.')
3 | "$env:SYSTEM_TEAMPROJECT.$repoName.props"
4 | } else {
5 | Write-Warning "No Azure Pipelines build detected. No Azure Pipelines drop name will be computed."
6 | }
7 |
--------------------------------------------------------------------------------
/tools/variables/ProfilingInputsDropName.ps1:
--------------------------------------------------------------------------------
1 | if ($env:SYSTEM_TEAMPROJECT) {
2 | "ProfilingInputs/$env:SYSTEM_TEAMPROJECT/$env:BUILD_REPOSITORY_NAME/$env:BUILD_SOURCEBRANCHNAME/$env:BUILD_BUILDID"
3 | } else {
4 | Write-Warning "No Azure Pipelines build detected. No Azure Pipelines drop name will be computed."
5 | }
6 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft.VisualStudio.Threading.Analyzers
2 |
3 | Static code analyzers to detect common mistakes or potential issues regarding threading and async coding.
4 |
5 | [Diagnostic analyzer rules](https://microsoft.github.io/vs-threading/analyzers/index.html).
6 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.InteropServices;
5 |
6 | [assembly: ComVisible(false)]
7 |
--------------------------------------------------------------------------------
/src/SosThreadingTools/ICommandHandler.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace CpsDbg;
5 |
6 | internal interface ICommandHandler
7 | {
8 | void Execute(string args);
9 | }
10 |
--------------------------------------------------------------------------------
/azure-pipelines/GlobalVariables.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | # These variables are required for MicroBuild tasks
3 | TeamName: VS Core - Special Projects
4 | TeamEmail: andarno@microsoft.com
5 | # These variables influence insertion pipelines
6 | ContainsVsix: false # This should be true when the repo builds a VSIX that should be inserted to VS.
7 |
--------------------------------------------------------------------------------
/test/NativeAOTCompatibility.Test/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | System.Console.WriteLine("This test is run by \"dotnet publish -c release -r [RID]-x64\" rather than by executing the program.");
5 |
--------------------------------------------------------------------------------
/loc/lci/SosThreadingToolsManaged.dll.lci:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading/CustomDictionary.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | awaiter
6 | awaiters
7 | awaitable
8 | dequeued
9 | enqueued
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/loc/lci/Microsoft.VisualStudio.Threading.dll.lci:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/version.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
3 | "version": "18.0",
4 | "publicReleaseRefSpec": [
5 | "^refs/heads/main$",
6 | "^refs/heads/v\\d+(?:\\.\\d+)?$"
7 | ],
8 | "cloudBuild": {
9 | "setVersionVariables": false
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/tools/variables/InsertVersionsValues.ps1:
--------------------------------------------------------------------------------
1 | $MacroName = 'MicrosoftVisualStudioThreadingVersion'
2 | $SampleProject = "$PSScriptRoot\..\..\src\Microsoft.VisualStudio.Threading"
3 | [string]::join(',',(@{
4 | ($MacroName) = & { (dotnet nbgv get-version --project $SampleProject --format json | ConvertFrom-Json).AssemblyVersion };
5 | }.GetEnumerator() |% { "$($_.key)=$($_.value)" }))
6 |
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "10.0.101",
4 | "rollForward": "patch",
5 | "allowPrerelease": false
6 | },
7 | "test": {
8 | "runner": "Microsoft.Testing.Platform"
9 | },
10 | "msbuild-sdks": {
11 | "MSBuild.Sdk.Extras": "3.0.44",
12 | "Microsoft.Build.NoTargets": "3.7.134",
13 | "Microsoft.Build.Traversal": "4.1.82"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/loc/lci/Microsoft.VisualStudio.Threading.Analyzers.dll.lci:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/buildTransitive/AdditionalFiles/vs-threading.LegacyThreadSwitchingMembers.txt:
--------------------------------------------------------------------------------
1 | [System.Windows.Threading.Dispatcher]::Invoke
2 | [System.Windows.Threading.Dispatcher]::InvokeAsync
3 | [System.Windows.Threading.Dispatcher]::BeginInvoke
4 | [System.Threading.SynchronizationContext]::Send
5 | [System.Threading.SynchronizationContext]::Post
6 |
--------------------------------------------------------------------------------
/azurepipelines-coverage.yml:
--------------------------------------------------------------------------------
1 | # https://learn.microsoft.com/azure/devops/pipelines/test/codecoverage-for-pullrequests
2 | coverage:
3 | status:
4 | comments: on # add comment to PRs reporting diff in coverage of modified files
5 | diff: # diff coverage is code coverage only for the lines changed in a pull request.
6 | target: 70% # set this to a desired %. Default is 70%
7 |
--------------------------------------------------------------------------------
/docfx/docs/getting-started.md:
--------------------------------------------------------------------------------
1 | # Getting Started
2 |
3 | ## Installation
4 |
5 | Consume this library via its NuGet Package.
6 | Click on the badge to find its latest version and the instructions for consuming it that best apply to your project.
7 |
8 | [](https://www.nuget.org/packages/Microsoft.VisualStudio.Threading)
9 |
--------------------------------------------------------------------------------
/tools/Get-TempToolsPath.ps1:
--------------------------------------------------------------------------------
1 | if ($env:AGENT_TEMPDIRECTORY) {
2 | $path = "$env:AGENT_TEMPDIRECTORY\$env:BUILD_BUILDID"
3 | } elseif ($env:localappdata) {
4 | $path = "$env:localappdata\gitrepos\tools"
5 | } else {
6 | $path = "$PSScriptRoot\..\obj\tools"
7 | }
8 |
9 | if (!(Test-Path $path)) {
10 | New-Item -ItemType Directory -Path $Path | Out-Null
11 | }
12 |
13 | (Resolve-Path $path).Path
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/buildTransitive/Microsoft.VisualStudio.Threading.Analyzers.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | false
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/test/IsolatedTestHost/IsolatedTestHost.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net472
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Tests/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | // Some of our tests measure stress, GC pressure, etc.
5 | // It messes with reliable test results when other threads are doing random stuff.
6 | [assembly: CollectionBehavior(DisableTestParallelization = true)]
7 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Tests.Win7RegistryWatcher/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/doc/editorconfigs/AppWithoutMainThread.editorconfig:
--------------------------------------------------------------------------------
1 | # These settings are appropriate for most projects that *never* run inside a process with a main thread and `SynchronizationContext`.
2 | # Examples of such applications are ASP.NET Core and console applications.
3 |
4 | # VSTHRD012: Provide JoinableTaskFactory where allowed
5 | dotnet_diagnostic.VSTHRD012.severity = none
6 |
7 | # VSTHRD003: Avoid awaiting foreign Tasks
8 | dotnet_diagnostic.VSTHRD003.severity = none
9 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Usings.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | global using System.Threading.Tasks;
5 | global using Microsoft;
6 | global using Microsoft.CodeAnalysis;
7 | global using Microsoft.CodeAnalysis.Testing;
8 | global using Microsoft.VisualStudio.Threading.Analyzers;
9 | global using Xunit;
10 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Tests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/tools/artifacts/symbols.ps1:
--------------------------------------------------------------------------------
1 | $BinPath = [System.IO.Path]::GetFullPath("$PSScriptRoot/../../bin")
2 | $ExternalPath = [System.IO.Path]::GetFullPath("$PSScriptRoot/../../obj/SymbolsPackages")
3 | if (!(Test-Path $BinPath)) { return }
4 | $symbolfiles = & "$PSScriptRoot/../Get-SymbolFiles.ps1" -Path $BinPath | Get-Unique
5 | $ExternalFiles = & "$PSScriptRoot/../Get-ExternalSymbolFiles.ps1"
6 |
7 | @{
8 | "$BinPath" = $SymbolFiles;
9 | "$ExternalPath" = $ExternalFiles;
10 | }
11 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Resources;
6 | using System.Runtime.CompilerServices;
7 | using System.Runtime.InteropServices;
8 |
9 | [assembly: CLSCompliant(false)]
10 | [assembly: ComVisible(false)]
11 |
12 | [assembly: NeutralResourcesLanguage("en-US")]
13 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading/Reasons.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.VisualStudio.Threading;
5 |
6 | internal static class Reasons
7 | {
8 | internal const string DiagnosticAnalysisOnly = "This API performs analysis of runtime objects for diagnostic purposes only, and isn't required for correct functionality.";
9 | }
10 |
--------------------------------------------------------------------------------
/tools/variables/InsertPropsValues.ps1:
--------------------------------------------------------------------------------
1 | $InsertedPkgs = (& "$PSScriptRoot\..\artifacts\VSInsertion.ps1")
2 |
3 | $icv=@()
4 | foreach ($kvp in $InsertedPkgs.GetEnumerator()) {
5 | $kvp.Value |% {
6 | if ($_.Name -match "^(.*?)\.(\d+\.\d+\.\d+(?:\.\d+)?(?:-.*?)?)(?:\.symbols)?\.nupkg$") {
7 | $id = $Matches[1]
8 | $version = $Matches[2]
9 | $icv += "$id=$version"
10 | }
11 | }
12 | }
13 |
14 | Write-Output ([string]::join(',',$icv))
15 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Resources;
6 | using System.Runtime.InteropServices;
7 |
8 | [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]
9 |
10 | [assembly: CLSCompliant(true)]
11 | [assembly: ComVisible(false)]
12 |
--------------------------------------------------------------------------------
/tools/variables/_all.ps1:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pwsh
2 |
3 | <#
4 | .SYNOPSIS
5 | This script returns a hashtable of build variables that should be set
6 | at the start of a build or release definition's execution.
7 | #>
8 |
9 | [CmdletBinding(SupportsShouldProcess = $true)]
10 | param (
11 | )
12 |
13 | $vars = @{}
14 |
15 | Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" |% {
16 | Write-Host "Computing $($_.BaseName) variable"
17 | $vars[$_.BaseName] = & $_
18 | }
19 |
20 | $vars
21 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Resources;
6 | using System.Runtime.CompilerServices;
7 | using System.Runtime.InteropServices;
8 |
9 | [assembly: CLSCompliant(false)]
10 | [assembly: ComVisible(false)]
11 |
12 | [assembly: NeutralResourcesLanguage("en-US")]
13 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Resources;
6 | using System.Runtime.CompilerServices;
7 | using System.Runtime.InteropServices;
8 |
9 | [assembly: CLSCompliant(false)]
10 | [assembly: ComVisible(false)]
11 |
12 | [assembly: NeutralResourcesLanguage("en-US")]
13 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Resources;
6 | using System.Runtime.CompilerServices;
7 | using System.Runtime.InteropServices;
8 |
9 | [assembly: CLSCompliant(false)]
10 | [assembly: ComVisible(false)]
11 |
12 | [assembly: NeutralResourcesLanguage("en-US")]
13 |
--------------------------------------------------------------------------------
/test/IsolatedTestHost/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Tests.Win7RegistryWatcher/Microsoft.VisualStudio.Threading.Tests.Win7RegistryWatcher.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net472
4 | Exe
5 | false
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/.editorconfig:
--------------------------------------------------------------------------------
1 | [Microsoft.VisualStudio.Threading.Analyzers*/*.cs]
2 |
3 | # CS1591: Missing XML comment for publicly visible type or member
4 | dotnet_diagnostic.CS1591.severity = suggestion
5 |
6 | # CA1062: Validate arguments of public methods
7 | dotnet_diagnostic.CA1062.severity = none
8 |
9 | # CA2007: Consider calling ConfigureAwait on the awaited task
10 | dotnet_diagnostic.CA2007.severity = silent
11 |
12 | # RS2008: Enable analyzer release tracking
13 | dotnet_diagnostic.RS2008.severity = suggestion
14 |
--------------------------------------------------------------------------------
/test/dirs.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Attach",
9 | "type": "coreclr",
10 | "request": "attach",
11 | "processId": "${command:pickProcess}"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/tools/artifacts/testResults.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding()]
2 | Param(
3 | )
4 |
5 | $result = @{}
6 |
7 | $RepoRoot = Resolve-Path "$PSScriptRoot\..\.."
8 | $testRoot = Join-Path $RepoRoot test
9 | $result[$testRoot] = (Get-ChildItem "$testRoot\TestResults" -Recurse -Directory | Get-ChildItem -Recurse -File)
10 |
11 | $artifactStaging = & "$PSScriptRoot/../Get-ArtifactsStagingDirectory.ps1"
12 | $testlogsPath = Join-Path $artifactStaging "test_logs"
13 | if (Test-Path $testlogsPath) {
14 | $result[$testlogsPath] = Get-ChildItem $testlogsPath -Recurse;
15 | }
16 |
17 | $result
18 |
--------------------------------------------------------------------------------
/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/tools/Get-ArtifactsStagingDirectory.ps1:
--------------------------------------------------------------------------------
1 | Param(
2 | [switch]$CleanIfLocal
3 | )
4 | if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) {
5 | $ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY
6 | } elseif ($env:RUNNER_TEMP) {
7 | $ArtifactStagingFolder = Join-Path $env:RUNNER_TEMP _artifacts
8 | } else {
9 | $ArtifactStagingFolder = [System.IO.Path]::GetFullPath("$PSScriptRoot/../obj/_artifacts")
10 | if ($CleanIfLocal -and (Test-Path $ArtifactStagingFolder)) {
11 | Remove-Item $ArtifactStagingFolder -Recurse -Force
12 | }
13 | }
14 |
15 | $ArtifactStagingFolder
16 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/Bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 |
5 | ---
6 |
7 | #### Bug description
8 | A clear and concise description of what the bug is.
9 |
10 | #### Repro steps
11 | Code to reproduce the behavior.
12 |
13 | #### Expected behavior
14 | A clear and concise description of what you expected to happen.
15 |
16 | #### Actual behavior
17 | What happened instead of what you expected.
18 |
19 | - Version used:
20 | - Application (if applicable):
21 |
22 | #### Additional context
23 | Add any other context about the problem here.
24 |
--------------------------------------------------------------------------------
/test/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | false
7 | true
8 | true
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Analyzers.Tests/AdditionalFiles/vs-threading.MembersRequiringMainThread.mocks.txt:
--------------------------------------------------------------------------------
1 | [TestNS.*]
2 | [TestNS.SomeStruct]
3 | ![TestNS.FreeThreadedType]
4 | ![TestNS2.FreeThreadedType]
5 | [TestNS2.*]
6 | [Microsoft.VisualStudio.Shell.Interop.*]
7 | [Microsoft.VisualStudio.OLE.Interop.*]
8 | [Microsoft.Internal.VisualStudio.Shell.Interop.*]
9 | ![Microsoft.VisualStudio.Shell.Interop.IAsyncServiceProvider]
10 | [Microsoft.VisualStudio.Shell.Package]::GetService
11 | [Microsoft.VisualStudio.Shell.ServiceProvider]
12 | ![TestNS2.A]::FreeThreadedMethod
13 | [A]::UIPropertyName
14 |
--------------------------------------------------------------------------------
/azure-pipelines/TSAOptions.json:
--------------------------------------------------------------------------------
1 | {
2 | "tsaVersion": "TsaV2",
3 | "codebase": "NewOrUpdate",
4 | "codebaseName": "Microsoft.VisualStudio.Threading",
5 | "tsaStamp": "DevDiv",
6 | "tsaEnvironment": "PROD",
7 | "notificationAliases": [
8 | "andarno@microsoft.com"
9 | ],
10 | "codebaseAdmins": [
11 | "REDMOND\\andarno"
12 | ],
13 | "instanceUrl": "https://devdiv.visualstudio.com",
14 | "projectName": "DevDiv",
15 | "areaPath": "DevDiv\\VS Core\\Special Projects\\vs-threading",
16 | "iterationPath": "DevDiv",
17 | "alltools": true,
18 | "repositoryName": "vs-threading"
19 | }
20 |
--------------------------------------------------------------------------------
/azure-pipelines/microbuild.after.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | - name: SkipCodesignVerify
3 | type: boolean
4 |
5 | steps:
6 | - ${{ if not(parameters.SkipCodesignVerify) }}:
7 | - task: MicroBuildCodesignVerify@3
8 | displayName: 🔍 Verify Signed Files
9 | inputs:
10 | ApprovalListPathForSigs: $(Build.SourcesDirectory)\azure-pipelines\no_strongname.txt
11 | ApprovalListPathForCerts: $(Build.SourcesDirectory)\azure-pipelines\no_authenticode.txt
12 | TargetFolders: |
13 | $(Build.SourcesDirectory)/bin/Packages/$(BuildConfiguration)
14 | condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
15 |
--------------------------------------------------------------------------------
/tools/artifacts/APIScanInputs.ps1:
--------------------------------------------------------------------------------
1 | $inputs = & "$PSScriptRoot/symbols.ps1"
2 |
3 | if (!$inputs) { return }
4 |
5 | # Filter out specific files that target OS's that are not subject to APIScan.
6 | # Files that are subject but are not supported must be scanned and an SEL exception filed.
7 | $outputs = @{}
8 | $forbiddenSubPaths = @(
9 | , 'linux-*'
10 | , 'osx*'
11 | )
12 |
13 | $inputs.GetEnumerator() | % {
14 | $list = $_.Value | ? {
15 | $path = $_.Replace('\', '/')
16 | return !($forbiddenSubPaths | ? { $path -like "*/$_/*" })
17 | }
18 | $outputs[$_.Key] = $list
19 | }
20 |
21 |
22 | $outputs
23 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/CSharpVSTHRD011UseAsyncLazyAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
10 | public sealed class CSharpVSTHRD011UseAsyncLazyAnalyzer : AbstractVSTHRD011UseAsyncLazyAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => CSharpUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/CSharpVSTHRD012SpecifyJtfWhereAllowed.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
10 | public sealed class CSharpVSTHRD012SpecifyJtfWhereAllowed : AbstractVSTHRD012SpecifyJtfWhereAllowed
11 | {
12 | protected override LanguageUtils LanguageUtils => CSharpUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/tools/artifacts/LocBin.ps1:
--------------------------------------------------------------------------------
1 | # Identify LCE files and the binary files they describe
2 | $BinRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\bin")
3 | if (!(Test-Path $BinRoot)) { return }
4 |
5 | $FilesToCopy = @()
6 | $FilesToCopy += Get-ChildItem -Recurse -File -Path $BinRoot |? { $_.FullName -match '\\Localize\\' }
7 |
8 | Get-ChildItem -rec "$BinRoot\*.lce" -File | % {
9 | $FilesToCopy += $_
10 | $FilesToCopy += $_.FullName.SubString(0, $_.FullName.Length - 4)
11 | }
12 |
13 | $FilesToCopy += Get-ChildItem -rec "$BinRoot\*.lcg" -File | % { [xml](Get-Content $_) } | % { $_.lcx.name }
14 |
15 | @{
16 | "$BinRoot" = $FilesToCopy;
17 | }
18 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/Feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 |
5 | ---
6 |
7 | #### Is your feature request related to a problem? Please describe.
8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9 |
10 | #### Describe the solution you'd like
11 | A clear and concise description of what you want to happen.
12 |
13 | #### Describe alternatives you've considered
14 | A clear and concise description of any alternative solutions or features you've considered.
15 |
16 | #### Additional context
17 | Add any other context or screenshots about the feature request here.
18 |
--------------------------------------------------------------------------------
/tools/Get-ProcDump.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Downloads 32-bit and 64-bit procdump executables and returns the path to where they were installed.
4 | #>
5 | $version = '0.0.1'
6 | $baseDir = "$PSScriptRoot\..\obj\tools"
7 | $procDumpToolPath = "$baseDir\procdump.$version\bin"
8 | if (-not (Test-Path $procDumpToolPath)) {
9 | if (-not (Test-Path $baseDir)) { New-Item -Type Directory -Path $baseDir | Out-Null }
10 | $baseDir = (Resolve-Path $baseDir).Path # Normalize it
11 | & (& $PSScriptRoot\Get-NuGetTool.ps1) install procdump -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir | Out-Null
12 | }
13 |
14 | (Resolve-Path $procDumpToolPath).Path
15 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/VisualBasicVSTHRD011UseAsyncLazyAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.VisualBasic)]
10 | public sealed class VisualBasicVSTHRD011UseAsyncLazyAnalyzer : AbstractVSTHRD011UseAsyncLazyAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => VisualBasicUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/CSharpVSTHRD114AvoidReturningNullTaskAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
10 | public sealed class CSharpVSTHRD114AvoidReturningNullTaskAnalyzer : AbstractVSTHRD114AvoidReturningNullTaskAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => CSharpUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/VisualBasicVSTHRD012SpecifyJtfWhereAllowed.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.VisualBasic)]
10 | public sealed class VisualBasicVSTHRD012SpecifyJtfWhereAllowed : AbstractVSTHRD012SpecifyJtfWhereAllowed
11 | {
12 | protected override LanguageUtils LanguageUtils => VisualBasicUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/OptProf.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | IBC
5 | Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Threading.17.x\$(TargetFileName)
6 | /ExeConfig:"%VisualStudio.InstallationUnderTest.Path%\Common7\IDE\vsn.exe"
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/CSharpVSTHRD109AvoidAssertInAsyncMethodsAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
10 | public sealed class CSharpVSTHRD109AvoidAssertInAsyncMethodsAnalyzer : AbstractVSTHRD109AvoidAssertInAsyncMethodsAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => CSharpUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/CSharpVSTHRD110ObserveResultOfAsyncCallsAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
10 | public sealed class CSharpVSTHRD110ObserveResultOfAsyncCallsAnalyzer : AbstractVSTHRD110ObserveResultOfAsyncCallsAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => CSharpUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/docfx/analyzers/fsa.md:
--------------------------------------------------------------------------------
1 | # Full Solution Analysis
2 |
3 | Analyzers that require Full Solution Analysis produce diagnostics that may not always be visible in Visual Studio.
4 |
5 | Diagnostics reported by such an analyzer will appear in a full build log. They may also appear in Visual Studio's Error List after a full build. But these diagnostics may disappear when the document they refer to is opened in the editor.
6 |
7 | To ensure the diagnostics are always visible, even when documents are open, select the "Enable full Solution Analysis" option, as shown below:
8 |
9 | 
10 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/CSharpVSTHRD001UseSwitchToMainThreadAsyncAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
10 | public sealed class CSharpVSTHRD001UseSwitchToMainThreadAsyncAnalyzer : AbstractVSTHRD001UseSwitchToMainThreadAsyncAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => CSharpUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/CSharpVSTHRD004AwaitSwitchToMainThreadAsyncAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
10 | public sealed class CSharpVSTHRD004AwaitSwitchToMainThreadAsyncAnalyzer : AbstractVSTHRD004AwaitSwitchToMainThreadAsyncAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => CSharpUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/LibraryNuspecProperties.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0;net8.0;net472
4 | $(TargetFrameworks);net8.0-windows
5 |
6 | Async synchronization primitives, async collections, TPL and dataflow extensions.
7 | The JoinableTaskFactory allows synchronously blocking the UI thread for async work. This
8 | package is applicable to any .NET application (not just Visual Studio).
9 |
10 | Threading Async Lock Synchronization Threadsafe
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/CSharpVSTHRD108AssertThreadRequirementUnconditionally.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
10 | public sealed class CSharpVSTHRD108AssertThreadRequirementUnconditionally : AbstractVSTHRD108AssertThreadRequirementUnconditionally
11 | {
12 | protected override LanguageUtils LanguageUtils => CSharpUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/test/AOT.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | Exe
4 | true
5 | true
6 | true
7 | $(AvailableRuntimeIdentifiers)
8 | $(DefaultRuntimeIdentifier)
9 |
10 |
11 |
12 |
13 | RuntimeIdentifier
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/VisualBasicVSTHRD114AvoidReturningNullTaskAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.VisualBasic)]
10 | public sealed class VisualBasicVSTHRD114AvoidReturningNullTaskAnalyzer : AbstractVSTHRD114AvoidReturningNullTaskAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => VisualBasicUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/CSharpVSTHRD105AvoidImplicitTaskSchedulerCurrentAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
10 | public sealed class CSharpVSTHRD105AvoidImplicitTaskSchedulerCurrentAnalyzer : AbstractVSTHRD105AvoidImplicitTaskSchedulerCurrentAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => CSharpUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/VisualBasicVSTHRD109AvoidAssertInAsyncMethodsAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.VisualBasic)]
10 | public sealed class VisualBasicVSTHRD109AvoidAssertInAsyncMethodsAnalyzer : AbstractVSTHRD109AvoidAssertInAsyncMethodsAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => VisualBasicUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/VisualBasicVSTHRD110ObserveResultOfAsyncCallsAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.VisualBasic)]
10 | public sealed class VisualBasicVSTHRD110ObserveResultOfAsyncCallsAnalyzer : AbstractVSTHRD110ObserveResultOfAsyncCallsAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => VisualBasicUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/VisualBasicVSTHRD001UseSwitchToMainThreadAsyncAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.VisualBasic)]
10 | public sealed class VisualBasicVSTHRD001UseSwitchToMainThreadAsyncAnalyzer : AbstractVSTHRD001UseSwitchToMainThreadAsyncAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => VisualBasicUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/VisualBasicVSTHRD004AwaitSwitchToMainThreadAsyncAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.VisualBasic)]
10 | public sealed class VisualBasicVSTHRD004AwaitSwitchToMainThreadAsyncAnalyzer : AbstractVSTHRD004AwaitSwitchToMainThreadAsyncAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => VisualBasicUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/VisualBasicVSTHRD108AssertThreadRequirementUnconditionally.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.VisualBasic)]
10 | public sealed class VisualBasicVSTHRD108AssertThreadRequirementUnconditionally : AbstractVSTHRD108AssertThreadRequirementUnconditionally
11 | {
12 | protected override LanguageUtils LanguageUtils => VisualBasicUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/CSharpVSTHRD112ImplementSystemIAsyncDisposableAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers
8 | {
9 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
10 | public sealed class CSharpVSTHRD112ImplementSystemIAsyncDisposableAnalyzer : AbstractVSTHRD112ImplementSystemIAsyncDisposableAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => CSharpUtils.Instance;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/VisualBasicVSTHRD112ImplementSystemIAsyncDisposableAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.VisualBasic)]
10 | public sealed class VisualBasicVSTHRD112ImplementSystemIAsyncDisposableAnalyzer : AbstractVSTHRD112ImplementSystemIAsyncDisposableAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => VisualBasicUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/init.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | SETLOCAL
3 | set PS1UnderCmd=1
4 |
5 | :: Get the datetime in a format that can go in a filename.
6 | set _my_datetime=%date%_%time%
7 | set _my_datetime=%_my_datetime: =_%
8 | set _my_datetime=%_my_datetime::=%
9 | set _my_datetime=%_my_datetime:/=_%
10 | set _my_datetime=%_my_datetime:.=_%
11 | set CmdEnvScriptPath=%temp%\envvarscript_%_my_datetime%.cmd
12 |
13 | powershell.exe -NoProfile -NoLogo -ExecutionPolicy bypass -Command "try { & '%~dpn0.ps1' %*; exit $LASTEXITCODE } catch { write-host $_; exit 1 }"
14 |
15 | :: Set environment variables in the parent cmd.exe process.
16 | IF EXIST "%CmdEnvScriptPath%" (
17 | ENDLOCAL
18 | CALL "%CmdEnvScriptPath%"
19 | DEL "%CmdEnvScriptPath%"
20 | )
21 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/VisualBasicVSTHRD105AvoidImplicitTaskSchedulerCurrentAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Diagnostics;
6 |
7 | namespace Microsoft.VisualStudio.Threading.Analyzers;
8 |
9 | [DiagnosticAnalyzer(LanguageNames.VisualBasic)]
10 | public sealed class VisualBasicVSTHRD105AvoidImplicitTaskSchedulerCurrentAnalyzer : AbstractVSTHRD105AvoidImplicitTaskSchedulerCurrentAnalyzer
11 | {
12 | protected override LanguageUtils LanguageUtils => VisualBasicUtils.Instance;
13 | }
14 |
--------------------------------------------------------------------------------
/docfx/analyzers/toc.yml:
--------------------------------------------------------------------------------
1 | items:
2 | - href: index.md
3 | - href: configuration.md
4 | - href: fsa.md
5 | - href: installation.md
6 | - href: VSTHRD001.md
7 | - href: VSTHRD002.md
8 | - href: VSTHRD003.md
9 | - href: VSTHRD004.md
10 | - href: VSTHRD010.md
11 | - href: VSTHRD011.md
12 | - href: VSTHRD012.md
13 | - href: VSTHRD100.md
14 | - href: VSTHRD101.md
15 | - href: VSTHRD102.md
16 | - href: VSTHRD103.md
17 | - href: VSTHRD104.md
18 | - href: VSTHRD105.md
19 | - href: VSTHRD106.md
20 | - href: VSTHRD107.md
21 | - href: VSTHRD108.md
22 | - href: VSTHRD109.md
23 | - href: VSTHRD110.md
24 | - href: VSTHRD111.md
25 | - href: VSTHRD112.md
26 | - href: VSTHRD113.md
27 | - href: VSTHRD114.md
28 | - href: VSTHRD115.md
29 | - href: VSTHRD200.md
30 |
--------------------------------------------------------------------------------
/docfx/analyzers/VSTHRD107.md:
--------------------------------------------------------------------------------
1 | # VSTHRD107 Await Task within using expression
2 |
3 | The C# `using` statement requires that the used expression implement `IDisposable`.
4 | Because `Task` implements `IDisposable`, one may accidentally omit an `await` operator
5 | and `Dispose` of the `Task` instead of the `T` result itself when `T` derives from `IDisposable`.
6 |
7 | ## Examples of patterns that are flagged by this analyzer
8 |
9 | ```csharp
10 | AsyncSemaphore lck;
11 | using (lck.EnterAsync())
12 | {
13 | // ...
14 | }
15 | ```
16 |
17 | ## Solution
18 |
19 | Add the `await` operator within the `using` expression.
20 |
21 | ```csharp
22 | AsyncSemaphore lck;
23 | using (await lck.EnterAsync())
24 | {
25 | // ...
26 | }
27 | ```
28 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading/EmptyStruct.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.VisualStudio.Threading;
5 |
6 | ///
7 | /// An empty struct.
8 | ///
9 | ///
10 | /// This can save 4 bytes over System.Object when a type argument is required for a generic type, but entirely unused.
11 | ///
12 | internal readonly struct EmptyStruct
13 | {
14 | ///
15 | /// Gets an instance of the empty struct.
16 | ///
17 | internal static EmptyStruct Instance
18 | {
19 | get { return default(EmptyStruct); }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/test/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/NativeAOTCompatibility.Test/NativeAOTCompatibility.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net10.0
5 | false
6 |
7 |
8 | $(TargetFrameworks);net10.0-windows
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading/SemaphoreFaultedException.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.VisualStudio.Threading;
7 |
8 | ///
9 | /// Exception thrown when a is in a faulted state.
10 | ///
11 | public class SemaphoreFaultedException : InvalidOperationException
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | public SemaphoreFaultedException()
17 | : base(Strings.SemaphoreMisused)
18 | {
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/stylecop.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3 | "settings": {
4 | "documentationRules": {
5 | "companyName": "Microsoft Corporation",
6 | "copyrightText": "Copyright (c) {companyName}. All rights reserved.\nLicensed under the {licenseName} license. See {licenseFile} file in the project root for full license information.",
7 | "variables": {
8 | "licenseName": "MIT",
9 | "licenseFile": "LICENSE"
10 | },
11 | "fileNamingConvention": "metadata",
12 | "xmlHeader": false
13 | },
14 | "orderingRules": {
15 | "usingDirectivesPlacement": "outsideNamespace"
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/azure-pipelines/vs-insertion-script.ps1:
--------------------------------------------------------------------------------
1 | # List of build artifact files [Source => Destination] to be committed into the VS repo.
2 | $FilesToCommit = @{
3 | "$env:PROFILINGINPUTSPROPSNAME" = "src/Tests/config/runsettings/Official/OptProf/External/$env:PROFILINGINPUTSPROPSNAME";
4 | }
5 |
6 | foreach ($File in $FilesToCommit.GetEnumerator()) {
7 | $SourcePath = Join-Path $PSScriptRoot $File.Key
8 | if (Test-Path $SourcePath) {
9 | $DestinationPath = Join-Path (Get-Location) $File.Value
10 | Write-Host "Copying $SourcePath to $DestinationPath"
11 | Copy-Item -Path $SourcePath -Destination $DestinationPath
12 | git add $DestinationPath
13 | }
14 | else {
15 | Write-Host "$SourcePath is not present, skipping"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/azure-pipelines/PoliCheckExclusions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | NODE_MODULES|.STORE
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/Directory.Packages.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 4.13.0
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading/IAsyncDisposable.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Threading.Tasks;
5 |
6 | namespace Microsoft.VisualStudio.Threading;
7 |
8 | ///
9 | /// Defines an asynchronous method to release allocated resources.
10 | ///
11 | ///
12 | /// Consider implementing instead.
13 | ///
14 | public interface IAsyncDisposable
15 | {
16 | ///
17 | /// Performs application-defined tasks associated with freeing,
18 | /// releasing, or resetting unmanaged resources asynchronously.
19 | ///
20 | Task DisposeAsync();
21 | }
22 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading/IHangReportContributor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Diagnostics.CodeAnalysis;
5 |
6 | namespace Microsoft.VisualStudio.Threading;
7 |
8 | ///
9 | /// Provides a facility to produce reports that may be useful when analyzing hangs.
10 | ///
11 | public interface IHangReportContributor
12 | {
13 | ///
14 | /// Contributes data for a hang report.
15 | ///
16 | /// The hang report contribution. Null values should be ignored.
17 | [RequiresUnreferencedCode(Reasons.DiagnosticAnalysisOnly)]
18 | HangReportContribution GetHangReport();
19 | }
20 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Tests/ValidityTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Reflection;
5 |
6 | public class ValidityTests
7 | {
8 | ///
9 | /// Verifies that the library we're testing is not in the GAC, since if it is,
10 | /// we're almost certainly not testing what was just built.
11 | ///
12 | [Fact]
13 | public void ProductNotInGac()
14 | {
15 | Assert.False(
16 | typeof(AsyncBarrier).GetTypeInfo().Assembly.Location.Contains("GAC"),
17 | $"{typeof(AsyncBarrier).GetTypeInfo().Assembly.GetName().Name} was loaded from the GAC. Run UnGac.cmd.");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | README.md
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | PackageIcon.png
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading/IllegalSemaphoreUsageException.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Globalization;
6 |
7 | namespace Microsoft.VisualStudio.Threading;
8 |
9 | ///
10 | /// Exception which is thrown when the contract of a is violated.
11 | ///
12 | public class IllegalSemaphoreUsageException : InvalidOperationException
13 | {
14 | ///
15 | /// Initializes a new instance of the class.
16 | ///
17 | public IllegalSemaphoreUsageException(string message)
18 | : base(message)
19 | {
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tools/Get-NuGetTool.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Downloads the NuGet.exe tool and returns the path to it.
4 | .PARAMETER NuGetVersion
5 | The version of the NuGet tool to acquire.
6 | #>
7 | Param(
8 | [Parameter()]
9 | [string]$NuGetVersion='6.14.0'
10 | )
11 |
12 | $toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1"
13 | $binaryToolsPath = Join-Path $toolsPath $NuGetVersion
14 | if (!(Test-Path $binaryToolsPath)) { $null = mkdir $binaryToolsPath }
15 | $nugetPath = Join-Path $binaryToolsPath nuget.exe
16 |
17 | if (!(Test-Path $nugetPath)) {
18 | Write-Host "Downloading nuget.exe $NuGetVersion..." -ForegroundColor Yellow
19 | (New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v$NuGetVersion/NuGet.exe", $nugetPath)
20 | }
21 |
22 | return (Resolve-Path $nugetPath).Path
23 |
--------------------------------------------------------------------------------
/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | trigger:
2 | batch: true
3 | branches:
4 | include:
5 | - main
6 | - 'v*.*'
7 | - 'validate/*'
8 | paths:
9 | exclude:
10 | - doc/
11 | - '*.md'
12 | - .vscode/
13 | - .github/
14 | - azure-pipelines/release.yml
15 |
16 | parameters:
17 | - name: EnableMacOSBuild
18 | displayName: Build on macOS
19 | type: boolean
20 | default: false # macOS is often bogged down in Azure Pipelines
21 | - name: RunTests
22 | displayName: Run tests
23 | type: boolean
24 | default: true
25 |
26 | variables:
27 | - template: /azure-pipelines/BuildStageVariables.yml@self
28 |
29 | jobs:
30 | - template: azure-pipelines/build.yml
31 | parameters:
32 | Is1ESPT: false
33 | EnableMacOSBuild: ${{ parameters.EnableMacOSBuild }}
34 | RunTests: ${{ parameters.RunTests }}
35 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Tests.Win7RegistryWatcher/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.Win32;
5 |
6 | namespace Microsoft.VisualStudio.Threading.Tests.Win7RegistryWatcher;
7 |
8 | internal static class Program
9 | {
10 | private static void Main()
11 | {
12 | // Watch a registry key. Then try to exit the program.
13 | // If in Win7 support mode we start a thread to monitor for registry changes,
14 | // this verifies that the thread is a *background* thread that won't keep the process running.
15 | RegistryKey? key = Registry.CurrentUser.OpenSubKey("SOFTWARE");
16 | key.WaitForChangeAsync();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers/Microsoft.VisualStudio.Threading.Analyzers.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 | true
5 | Microsoft.VisualStudio.Threading.Analyzers.Only
6 | false
7 | $(NoWarn);CS1591
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Directory.Build.rsp:
--------------------------------------------------------------------------------
1 | #------------------------------------------------------------------------------
2 | # This file contains command-line options that MSBuild will process as part of
3 | # every build, unless the "/noautoresponse" switch is specified.
4 | #
5 | # MSBuild processes the options in this file first, before processing the
6 | # options on the command line. As a result, options on the command line can
7 | # override the options in this file. However, depending on the options being
8 | # set, the overriding can also result in conflicts.
9 | #
10 | # NOTE: The "/noautoresponse" switch cannot be specified in this file, nor in
11 | # any response file that is referenced by this file.
12 | #------------------------------------------------------------------------------
13 | /nr:false
14 | /m
15 | /verbosity:minimal
16 | /clp:Summary;ForceNoAlign
17 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading/Boxed.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.VisualStudio.Threading;
5 |
6 | internal static class Boxed
7 | {
8 | ///
9 | /// Returns an object containing .
10 | ///
11 | public static readonly object True = true;
12 |
13 | ///
14 | /// Returns an object containing .
15 | ///
16 | public static readonly object False = false;
17 |
18 | ///
19 | /// Returns an object containing specified value.
20 | ///
21 | public static object Box(bool value)
22 | {
23 | return value ? True : False;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/Microsoft.VisualStudio.Threading.Analyzers.CSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 | Microsoft.VisualStudio.Threading.Analyzers
5 | true
6 | false
7 |
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.github/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "github>microsoft/vs-renovate-presets:microbuild",
5 | "github>microsoft/vs-renovate-presets:vs_main_dependencies",
6 | "github>microsoft/vs-renovate-presets:dotnet_packages_LTS",
7 | "github>microsoft/vs-renovate-presets:xunitv2"
8 | ],
9 | "packageRules": [
10 | {
11 | "matchJsonata": ["sharedVariableName='CodeAnalysisVersion'"],
12 | "enabled": false
13 | }
14 | ],
15 | "customManagers": [
16 | {
17 | "customType": "regex",
18 | "datasourceTemplate": "nuget",
19 | "managerFilePatterns": [
20 | "test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Helpers/ReferencesHelper.cs"
21 | ],
22 | "matchStrings": [
23 | "PackageIdentity\\(\"(?[^\"]+)\", \"(?[^\"]+)\"\\)"
24 | ]
25 | }
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 | Microsoft.VisualStudio.Threading.Analyzers
5 | true
6 | false
7 |
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.config/dotnet-tools.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "isRoot": true,
4 | "tools": {
5 | "powershell": {
6 | "version": "7.5.4",
7 | "commands": [
8 | "pwsh"
9 | ],
10 | "rollForward": false
11 | },
12 | "dotnet-coverage": {
13 | "version": "18.1.0",
14 | "commands": [
15 | "dotnet-coverage"
16 | ],
17 | "rollForward": false
18 | },
19 | "nbgv": {
20 | "version": "3.9.50",
21 | "commands": [
22 | "nbgv"
23 | ],
24 | "rollForward": false
25 | },
26 | "docfx": {
27 | "version": "2.78.4",
28 | "commands": [
29 | "docfx"
30 | ],
31 | "rollForward": false
32 | },
33 | "nerdbank.dotnetrepotools": {
34 | "version": "1.0.92",
35 | "commands": [
36 | "repo"
37 | ],
38 | "rollForward": false
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 | // List of extensions which should be recommended for users of this workspace.
5 | "recommendations": [
6 | "ms-azure-devops.azure-pipelines",
7 | "ms-dotnettools.csharp",
8 | "k--kato.docomment",
9 | "editorconfig.editorconfig",
10 | "esbenp.prettier-vscode",
11 | "pflannery.vscode-versionlens",
12 | "davidanson.vscode-markdownlint",
13 | "dotjoshjohnson.xml",
14 | "ms-vscode-remote.remote-containers",
15 | "ms-azuretools.vscode-docker",
16 | "tintoy.msbuild-project-tools"
17 | ],
18 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
19 | "unwantedRecommendations": []
20 | }
21 |
--------------------------------------------------------------------------------
/test/Microsoft.VisualStudio.Threading.Tests/GenericParameterHelper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | public class GenericParameterHelper
7 | {
8 | public GenericParameterHelper()
9 | {
10 | this.Data = new Random().Next();
11 | }
12 |
13 | public GenericParameterHelper(int data)
14 | {
15 | this.Data = data;
16 | }
17 |
18 | public int Data { get; set; }
19 |
20 | public override bool Equals(object? obj)
21 | {
22 | if (obj is GenericParameterHelper other)
23 | {
24 | return this.Data == other.Data;
25 | }
26 |
27 | return false;
28 | }
29 |
30 | public override int GetHashCode()
31 | {
32 | return this.Data;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/docfx/analyzers/VSTHRD114.md:
--------------------------------------------------------------------------------
1 | # VSTHRD114 Avoid returning a null Task
2 |
3 | Returning `null` from a non-async `Task`/`Task` method will cause a `NullReferenceException` at runtime. This problem can be avoided by returning `Task.CompletedTask`, `Task.FromResult(null)` or `Task.FromResult(default(T))` instead.
4 |
5 | ## Examples of patterns that are flagged by this analyzer
6 |
7 | Any non-async `Task` returning method with an explicit `return null;` will be flagged.
8 |
9 | ```csharp
10 | Task DoAsync() {
11 | return null;
12 | }
13 |
14 | Task