diff --git a/Directory.Packages.props b/Directory.Packages.props
index 02d061f10c2..99c94963728 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -117,14 +117,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/eng/imports/UnitTests.targets b/eng/imports/UnitTests.targets
index 69d0ec46ccd..be59e9ff22c 100644
--- a/eng/imports/UnitTests.targets
+++ b/eng/imports/UnitTests.targets
@@ -43,7 +43,7 @@
-
+
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.TestServices/AssertEx.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.TestServices/AssertEx.cs
index 32d1dc89940..2d5f7d844c3 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.TestServices/AssertEx.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.TestServices/AssertEx.cs
@@ -13,7 +13,7 @@ public static void CollectionLength(IEnumerable collection, int expectedCo
if (actualCount != expectedCount)
{
- throw new CollectionException(collection, expectedCount, actualCount);
+ throw CollectionException.ForMismatchedItemCount(expectedCount, actualCount, "Collection lengths not equal.");
}
}
@@ -42,7 +42,7 @@ public static void SequenceSame(IEnumerable expected, IEnumerable actua
}
else
{
- throw new XunitException("Sequences have different lengths");
+ throw new XunitException("Sequences have different lengths.");
}
}
}
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Build/BuildUtilitiesTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Build/BuildUtilitiesTests.cs
index 3b555b48938..cb4cf0d58bb 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Build/BuildUtilitiesTests.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Build/BuildUtilitiesTests.cs
@@ -44,7 +44,8 @@ public void GetProperty_ExistentProperty()
public void GetPropertyValues_SingleValue()
{
var values = BuildUtilities.GetPropertyValues("MyPropertyValue");
- Assert.Collection(values, firstValue => Assert.Equal("MyPropertyValue", firstValue));
+ var firstValue = Assert.Single(values);
+ Assert.Equal("MyPropertyValue", firstValue);
}
[Fact]
@@ -89,9 +90,9 @@ public void GetOrAddProperty_NoGroups()
var project = ProjectRootElementFactory.Create();
BuildUtilities.GetOrAddProperty(project, "MyProperty");
Assert.Single(project.Properties);
- Assert.Collection(project.PropertyGroups,
- group => Assert.Collection(group.Properties,
- firstProperty => Assert.Equal(string.Empty, firstProperty.Value)));
+ var group = Assert.Single(project.PropertyGroups);
+ var property = Assert.Single(group.Properties);
+ Assert.Equal(string.Empty, property.Value);
}
[Fact]
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/IProjectPropertiesFactory.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/IProjectPropertiesFactory.cs
index 0893f4253a9..5c77f468625 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/IProjectPropertiesFactory.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/IProjectPropertiesFactory.cs
@@ -21,7 +21,7 @@ public static Mock MockWithProperties(IEnumerable pr
return mock;
}
- public static Mock MockWithPropertyAndValue(string propertyName, string setValue)
+ public static Mock MockWithPropertyAndValue(string propertyName, string? setValue)
{
return MockWithPropertiesAndValues(new Dictionary() { { propertyName, setValue } });
}
@@ -72,7 +72,7 @@ public static Mock MockWithPropertiesAndValues(IDictionary MockWithProperty(propertyName).Object;
- public static IProjectProperties CreateWithPropertyAndValue(string propertyName, string setValue)
+ public static IProjectProperties CreateWithPropertyAndValue(string propertyName, string? setValue)
=> MockWithPropertyAndValue(propertyName, setValue).Object;
public static IProjectProperties CreateWithPropertiesAndValues(IDictionary propertyNameAndValues, HashSet? inheritedPropertyNames = null)
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Build/StartupProjectSingleTargetGlobalBuildPropertyProviderTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Build/StartupProjectSingleTargetGlobalBuildPropertyProviderTests.cs
index 2b7505e0a48..a8278fcba85 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Build/StartupProjectSingleTargetGlobalBuildPropertyProviderTests.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Build/StartupProjectSingleTargetGlobalBuildPropertyProviderTests.cs
@@ -58,7 +58,7 @@ public async Task VerifyExpectedBehaviors(string projectPath, bool crossTargetin
if (expectTargetFrameworkSet)
{
- Assert.Equal(expected: 1, actual: globalProperties.Count);
+ Assert.Single(globalProperties);
Assert.Equal(expected: "myFramework1.0", actual: globalProperties[ConfigurationGeneral.TargetFrameworkProperty]);
}
else
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Build/TargetFrameworkGlobalBuildPropertyProviderTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Build/TargetFrameworkGlobalBuildPropertyProviderTests.cs
index 33f6a17515f..1b121aa3a7f 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Build/TargetFrameworkGlobalBuildPropertyProviderTests.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Build/TargetFrameworkGlobalBuildPropertyProviderTests.cs
@@ -36,7 +36,7 @@ public async Task VerifyNoTargetFrameworkOverrideForRegularBuild()
var provider = new TargetFrameworkGlobalBuildPropertyProvider(projectService, configuredProject);
var properties = await provider.GetGlobalPropertiesAsync(CancellationToken.None);
- Assert.Equal(0, properties.Count);
+ Assert.Empty(properties);
}
}
}
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Debug/DebugTokenReplacerTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Debug/DebugTokenReplacerTests.cs
index 331cb5d1a44..0e63854c12c 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Debug/DebugTokenReplacerTests.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Debug/DebugTokenReplacerTests.cs
@@ -68,12 +68,12 @@ public async Task ReplaceTokensInProfileTests()
[InlineData("this is msbuild: %env3% $(msbuildProperty2) $(msbuildProperty3)", "this is msbuild: Property6 Property2 Property3", true)]
[InlineData(null, null, true)]
[InlineData(" ", " ", true)]
- public async Task ReplaceTokensInStringTests(string input, string expected, bool expandEnvVars)
+ public async Task ReplaceTokensInStringTests(string? input, string? expected, bool expandEnvVars)
{
var replacer = CreateInstance();
- // Test msbuild vars
- string result = await replacer.ReplaceTokensInStringAsync(input, expandEnvVars);
+ // Test MSBuild vars
+ string? result = await replacer.ReplaceTokensInStringAsync(input!, expandEnvVars);
Assert.Equal(expected, result);
}
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/FileItemServicesTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/FileItemServicesTests.cs
index 1a5be0fd802..e1a21a83fed 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/FileItemServicesTests.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/FileItemServicesTests.cs
@@ -75,7 +75,7 @@ public void GetLogicalFolderNames_EmptyAsFullPath_ThrowsArgument()
[InlineData("C:\\Folder\\Project", "C:\\Folder\\Project\\Source.cs", "Folder\\..\\..\\Source.cs", null)]
[InlineData("C:\\Folder\\Project", "C:\\Folder\\Project\\Source.cs", "D:\\Folder\\Source.cs", null)]
[InlineData("C:\\Folder\\Project", "C:\\Folder\\Project\\Source.cs", "C:\\Folder\\Project\\Source.cs", null)]
- public void GetLogicalFolderNames_Returns(string basePath, string fullPath, string link, params string[] expected)
+ public void GetLogicalFolderNames_Returns(string basePath, string fullPath, string? link, params string?[] expected)
{
var metadata = ImmutableDictionary.Empty;
if (link is not null)
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/OnceInitializedOnceDisposedUnderLockAsyncTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/OnceInitializedOnceDisposedUnderLockAsyncTests.cs
index 8be8b0a67ec..ec2b57651e3 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/OnceInitializedOnceDisposedUnderLockAsyncTests.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/OnceInitializedOnceDisposedUnderLockAsyncTests.cs
@@ -7,22 +7,22 @@ namespace Microsoft.VisualStudio.ProjectSystem
public class OnceInitializedOnceDisposedUnderLockAsyncTests
{
[Fact]
- public void ExecuteUnderLockAsync_NullAsAction_ThrowsArgumentNullException()
+ public async Task ExecuteUnderLockAsync_NullAsAction_ThrowsArgumentNullException()
{
var instance = CreateInstance();
- Assert.ThrowsAsync(() =>
+ await Assert.ThrowsAsync(() =>
{
return instance.ExecuteUnderLockAsync(null!, CancellationToken.None);
});
}
[Fact]
- public void ExecuteUnderLockAsyncOfT_NullAsAction_ThrowsArgumentNullException()
+ public async Task ExecuteUnderLockAsyncOfT_NullAsAction_ThrowsArgumentNullException()
{
var instance = CreateInstance();
- Assert.ThrowsAsync(() =>
+ await Assert.ThrowsAsync(() =>
{
return instance.ExecuteUnderLockAsync(null!, CancellationToken.None);
});
@@ -364,7 +364,7 @@ private static async Task AssertNoOverlap(Func firstAction, Func sec
{
// Run first task and wait until we've entered it
var firstTask = firstAction();
- await firstEntered.WaitAsync();
+ await firstEntered.WaitAsync().WithTimeout(TimeSpan.FromSeconds(30));
// Run second task, we should never enter it
var secondTask = secondAction();
@@ -374,7 +374,7 @@ private static async Task AssertNoOverlap(Func firstAction, Func sec
firstRelease.Set();
// Now we should enter first one
- await secondEntered.WaitAsync();
+ await secondEntered.WaitAsync().WithTimeout(TimeSpan.FromSeconds(30));
await Task.WhenAll(firstTask, secondTask);
}
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/AssemblyInfoPropertiesProviderTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/AssemblyInfoPropertiesProviderTests.cs
index 8a17017d21c..12b3b8ea757 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/AssemblyInfoPropertiesProviderTests.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/AssemblyInfoPropertiesProviderTests.cs
@@ -70,7 +70,7 @@ private static TestProjectFileOrAssemblyInfoPropertiesProvider CreateProviderFor
private static TestProjectFileOrAssemblyInfoPropertiesProvider CreateProviderForProjectFileValidation(
string code,
string propertyName,
- string propertyValueInProjectFile,
+ string? propertyValueInProjectFile,
out Workspace workspace,
Lazy? interceptingProvider = null,
Dictionary? additionalProps = null)
@@ -151,7 +151,7 @@ public async Task SourceFileProperties_GetEvaluatedPropertyAsync(string code, st
[InlineData("""[assembly: System.Reflection.AssemblyDescriptionAttribute(true)]""", "Description", "MyDescription", "MyDescription")]
[InlineData("""[assembly: System.Reflection.AssemblyDescriptionAttribute("MyDescription"]""", "Description", "", "")]
[InlineData("""[assembly: System.Reflection.AssemblyDescriptionAttribute("MyDescription"]""", "Description", null, "")]
- public async Task ProjectFileProperties_GetEvaluatedPropertyAsync(string code, string propertyName, string propertyValueInProjectFile, string expectedValue)
+ public async Task ProjectFileProperties_GetEvaluatedPropertyAsync(string code, string propertyName, string? propertyValueInProjectFile, string expectedValue)
{
var provider = CreateProviderForProjectFileValidation(code, propertyName, propertyValueInProjectFile, out Workspace workspace);
var projectFilePath = workspace.CurrentSolution.Projects.First().FilePath;
@@ -278,7 +278,7 @@ public async Task ProjectFileProperties_GetUnevaluatedPropertyAsync(string code,
[InlineData("""[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2.0.0")]""", "Version", "2.0.0", null)]
[InlineData("""[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2.0.1-beta1")]""", "Version", "2.0.1-beta1", null)]
[InlineData("""[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2016.2")]""", "Version", "2016.2", null)]
- internal async Task SourceFileProperties_DefaultValues_GetEvaluatedPropertyAsync(string code, string propertyName, string expectedValue, Type interceptingProviderType)
+ internal async Task SourceFileProperties_DefaultValues_GetEvaluatedPropertyAsync(string code, string propertyName, string expectedValue, Type? interceptingProviderType)
{
var interceptingProvider = interceptingProviderType is not null
? new Lazy(
@@ -308,7 +308,7 @@ internal async Task SourceFileProperties_DefaultValues_GetEvaluatedPropertyAsync
[InlineData("MyApp", "Product", null, "")]
[InlineData("MyApp", "Product", "", "")]
[InlineData("MyApp", "Product", "ExistingValue", "ExistingValue")]
- internal async Task ProjectFileProperties_DefaultValues_GetEvaluatedPropertyAsync(string assemblyName, string propertyName, string existingPropertyValue, string expectedValue)
+ internal async Task ProjectFileProperties_DefaultValues_GetEvaluatedPropertyAsync(string assemblyName, string propertyName, string? existingPropertyValue, string expectedValue)
{
var additionalProps = new Dictionary() { { "AssemblyName", assemblyName } };
@@ -352,7 +352,7 @@ internal async Task ProjectFileProperties_DefaultValues_GetEvaluatedPropertyAsyn
[InlineData("Version", "1.1.1", "1.0.0.0", "1.0.0.0", null)]
[InlineData("Version", "1.0.0", "1.0.0.0", "1.0.0.0", null)]
[InlineData("Version", null, "2016.2", "2016.2", null)]
- internal async Task ProjectFileProperties_WithInterception_SetEvaluatedPropertyAsync(string propertyName, string existingPropertyValue, string propertyValueToSet, string expectedValue, Type interceptingProviderType)
+ internal async Task ProjectFileProperties_WithInterception_SetEvaluatedPropertyAsync(string propertyName, string? existingPropertyValue, string propertyValueToSet, string expectedValue, Type? interceptingProviderType)
{
var interceptingProvider = interceptingProviderType is not null
? new Lazy(
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/InterceptingProjectProperties/ApplicationManifestValueProviderTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/InterceptingProjectProperties/ApplicationManifestValueProviderTests.cs
index 5ecff98cdf5..0b2c550ceab 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/InterceptingProjectProperties/ApplicationManifestValueProviderTests.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/InterceptingProjectProperties/ApplicationManifestValueProviderTests.cs
@@ -11,7 +11,7 @@ public class ApplicationManifestValueProviderTests
[InlineData("", "TRue", "NoManifest")]
[InlineData("", "false", "DefaultManifest")]
[InlineData("", null, "DefaultManifest")]
- public async Task GetApplicationManifest(string appManifestPropValue, string noManifestValue, string expectedValue)
+ public async Task GetApplicationManifest(string appManifestPropValue, string? noManifestValue, string expectedValue)
{
var provider = new ApplicationManifestValueProvider(UnconfiguredProjectFactory.Create());
var defaultProperties = IProjectPropertiesFactory.CreateWithPropertyAndValue("NoWin32Manifest", noManifestValue);
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/LaunchProfiles/LaunchProfilesProjectItemProviderTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/LaunchProfiles/LaunchProfilesProjectItemProviderTests.cs
index 049864acb21..d04013dbb67 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/LaunchProfiles/LaunchProfilesProjectItemProviderTests.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/LaunchProfiles/LaunchProfilesProjectItemProviderTests.cs
@@ -103,8 +103,8 @@ public async Task WhenAskedForLaunchProfileItemTypes_GetItemsAsyncReturnsAnItemF
items = await itemProvider.GetItemsAsync(LaunchProfileProjectItemProvider.ItemType, "Profile2");
- Assert.Collection(items,
- item => Assert.Equal("Profile2", item.EvaluatedInclude));
+ var item = Assert.Single(items);
+ Assert.Equal("Profile2", item.EvaluatedInclude);
}
[Fact]
diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/References/AlwaysAllowValidProjectReferenceCheckerTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/References/AlwaysAllowValidProjectReferenceCheckerTests.cs
index e56e4480795..fb406de0b2f 100644
--- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/References/AlwaysAllowValidProjectReferenceCheckerTests.cs
+++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/References/AlwaysAllowValidProjectReferenceCheckerTests.cs
@@ -5,44 +5,44 @@ namespace Microsoft.VisualStudio.ProjectSystem.References
public class AlwaysAllowValidProjectReferenceCheckerTests
{
[Fact]
- public void CanAddProjectReferenceAsync_NullAsReferencedProject_ThrowsArgumentNull()
+ public async Task CanAddProjectReferenceAsync_NullAsReferencedProject_ThrowsArgumentNull()
{
var checker = CreateInstance();
- Assert.ThrowsAsync("referencedProject", () =>
+ await Assert.ThrowsAsync("referencedProject", () =>
{
return checker.CanAddProjectReferenceAsync(null!);
});
}
[Fact]
- public void CanAddProjectReferencesAsync_NullAsReferencedProjects_ThrowsArgumentNull()
+ public async Task CanAddProjectReferencesAsync_NullAsReferencedProjects_ThrowsArgumentNull()
{
var checker = CreateInstance();
- Assert.ThrowsAsync("referencedProjects", () =>
+ await Assert.ThrowsAsync("referencedProjects", () =>
{
return checker.CanAddProjectReferencesAsync(null!);
});
}
[Fact]
- public void CanAddProjectReferencesAsync_EmptyAsReferencedProjects_ThrowsArgument()
+ public async Task CanAddProjectReferencesAsync_EmptyAsReferencedProjects_ThrowsArgument()
{
var checker = CreateInstance();
- Assert.ThrowsAsync("referencedProjects", () =>
+ await Assert.ThrowsAsync("referencedProjects", () =>
{
return checker.CanAddProjectReferencesAsync(ImmutableHashSet