Add ValueTask package reference to analyzer project
This commit is contained in:
Родитель
71278bf4b9
Коммит
be09861d89
|
@ -283,6 +283,23 @@ public class Test {
|
|||
Assert.False(refAssemblies.Any(a => a.Name.Equals("System.ValueTuple", StringComparison.OrdinalIgnoreCase)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that no reference to <see cref="ValueTask"/> exists,
|
||||
/// so we know the analyzers will work on .NET Framework versions that did not include it.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// We reference the assembly during compilation for convenient use of nameof.
|
||||
/// This unit test guards that we don't accidentally require the assembly
|
||||
/// at runtime.
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public void NoValueTaskReference()
|
||||
{
|
||||
var refAssemblies = typeof(VSTHRD001UseSwitchToMainThreadAsyncAnalyzer)
|
||||
.Assembly.GetReferencedAssemblies();
|
||||
Assert.False(refAssemblies.Any(a => a.Name.Equals("System.Threading.Tasks.Extensions", StringComparison.OrdinalIgnoreCase)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task NameOfUsedInAttributeArgument()
|
||||
{
|
||||
|
|
|
@ -60,7 +60,8 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="1.2.0" />
|
||||
<PackageReference Include="MicroBuild.VisualStudio" Version="$(MicroBuildVersion)" />
|
||||
<PackageReference Include="GitLink" Version="3.2.0-unstable0014" PrivateAssets="all" />
|
||||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.1" />
|
||||
<PackageReference Include="GitLink" Version="3.2.0-unstable0014" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Multilingual App Toolkit\Microsoft.Multilingual.ResxResources.targets" Label="MultilingualAppToolkit" Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\Multilingual App Toolkit\v$(MultilingualAppToolkitVersion)\Microsoft.Multilingual.ResxResources.targets')" />
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace Microsoft.VisualStudio.Threading.Analyzers
|
|||
|
||||
internal static class ValueTask
|
||||
{
|
||||
internal const string TypeName = "ValueTask";
|
||||
internal const string TypeName = nameof(ValueTask);
|
||||
|
||||
internal const string FullName = "System.Threading.Tasks." + TypeName;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
/// <summary>
|
||||
/// Finds await expressions on <see cref="Task"/> that do not use <see cref="Task.ConfigureAwait(bool)"/>.
|
||||
/// Also works on ValueTask.
|
||||
/// Also works on <see cref="ValueTask"/>.
|
||||
/// </summary>
|
||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||
public class VSTHRD111UseConfigureAwaitAnalyzer : DiagnosticAnalyzer
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace Microsoft.VisualStudio.Threading.Analyzers
|
|||
return;
|
||||
}
|
||||
|
||||
bool shouldEndWithAsync = (methodSymbol.ReturnType.Name == nameof(Task) || methodSymbol.ReturnType.Name == "ValueTask") &&
|
||||
bool shouldEndWithAsync = (methodSymbol.ReturnType.Name == nameof(Task) || methodSymbol.ReturnType.Name == nameof(ValueTask)) &&
|
||||
methodSymbol.ReturnType.BelongsToNamespace(Namespaces.SystemThreadingTasks);
|
||||
|
||||
// Skip entrypoint methods since they must be called Main.
|
||||
|
|
Загрузка…
Ссылка в новой задаче