From 021f67c7a56f6197e3293231c2db551919244721 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Wed, 11 Sep 2024 18:03:59 -0700 Subject: [PATCH 01/12] Upgrade xUnit One of our NuGet audit alerts was rooted in our xUnit packages as they only had `netstandard1.3` libraries. To resolve this alert I moved us to newer versions of the package which had `netstandard2.0` libraries. Upgrading the package revealed two problems in our code base: 1. The xUnit `Assert` APIs took advantage of the `unmanaged` constraint in a fwe places. That is not supported by Visual Basic and leads to errors on import. To work around this I inserted `AssertEx` thunks that our Visual Basic layer can call through. Longer term we will need to consider adding support for the constraint ([issue](https://github.com/dotnet/roslyn/issues/75063)) 2. The xUnit APIs significantly increased their nullable reference type annotations. This caught a number of places where the tests were passing potentially null values to APIs that don't accept null. There were enough hits that I added `AssertEx` methods that handle the nullable case. In a few places though I just suppressed the warning. The vulnerability: https://github.com/advisories/GHSA-cmhx-cq75-c4mj --- eng/Directory.Packages.props | 24 ++-- .../Semantic/Semantics/DelegateTypeTests.cs | 52 +++---- src/Compilers/Test/Core/Assert/AssertEx.cs | 72 ++++++++++ .../Emit/Attributes/AssemblyAttributes.vb | 28 ++-- .../Test/Emit/Attributes/AttributeTests.vb | 2 +- .../InternalsVisibleToAndStrongNameTests.vb | 6 +- .../Test/Emit/CodeGen/CodeGenTuples.vb | 14 +- .../Test/Emit/Emit/CompilationEmitTests.vb | 2 +- .../EditAndContinueStateMachineTests.vb | 14 +- .../BindingCollectionInitializerTests.vb | 2 +- .../Test/Semantic/Binding/LookupTests.vb | 66 ++++----- .../Compilation/CompilationAPITests.vb | 24 ++-- .../SemanticModelGetDeclaredSymbolAPITests.vb | 4 +- .../Semantic/FlowAnalysis/FlowTestBase.vb | 26 ++-- .../Test/Semantic/Semantics/ForeachTest.vb | 24 ++-- .../Test/Semantic/Semantics/GotoTests.vb | 18 +-- .../AnonymousTypesSemanticsTests.vb | 4 +- .../SymbolsTests/Source/BindingsTests.vb | 2 +- .../SymbolsTests/Source/SourceSymbolTests.vb | 4 +- .../Symbol/SymbolsTests/TypedConstantTests.vb | 5 +- .../Test/Syntax/Parser/XmlDocComments.vb | 18 +-- .../Updater/SettingsUpdaterTests.cs | 8 +- .../FindUsages/DefinitionItemFactoryTests.cs | 2 +- .../CodeLens/CSharpCodeLensTests.cs | 2 +- .../AdditionalFileDiagnosticsTests.cs | 10 +- .../Diagnostics/PullDiagnosticTests.cs | 128 +++++++++--------- .../WorkspaceProjectDiagnosticsTests.cs | 5 +- .../LspMetadataAsSourceWorkspaceTests.cs | 1 + .../SpellCheck/SpellCheckTests.cs | 12 +- .../Symbols/WorkspaceSymbolsTests.cs | 2 +- .../VSTypeScriptHandlerTests.cs | 2 +- src/Tools/TestDiscoveryWorker/Program.cs | 2 +- .../InProcess/InputInProcess.cs | 2 +- .../UtilityTest/SpecializedTasksTests.cs | 4 +- 34 files changed, 333 insertions(+), 258 deletions(-) diff --git a/eng/Directory.Packages.props b/eng/Directory.Packages.props index b84aafb249533..ca7bce510510f 100644 --- a/eng/Directory.Packages.props +++ b/eng/Directory.Packages.props @@ -12,7 +12,7 @@ 9.0.0-rc.2.24462.10 6.0.0-rtm.21518.12 7.0.0-alpha.1.22060.1 - 17.5.0 + 17.10.0 8.0.0 8.0.0 - 2.4.1 + <_xunitVersion>2.9.0 2.1.0 17.10.2079 @@ -276,17 +276,17 @@ - - - - - - - - + + + + + + + + - - + + diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs index 50b94c22b0db0..f75885a849cb9 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs @@ -1384,7 +1384,7 @@ static class B // https://github.com/dotnet/roslyn/issues/52870: GetSymbolInfo() should return resolved method from method group. Assert.Null(symbolInfo.Symbol); - Assert.Equal(["void System.Object.F(System.Object y)", "void System.Object.F(T y)"], + Assert.Equal((string[])["void System.Object.F(System.Object y)", "void System.Object.F(T y)"], model.GetMemberGroup(expr).ToTestDisplayStrings()); } @@ -1427,7 +1427,7 @@ static class B // https://github.com/dotnet/roslyn/issues/52870: GetSymbolInfo() should return resolved method from method group. Assert.Null(symbolInfo.Symbol); - Assert.Equal(["void System.Object.F()", "void System.Object.F()"], + Assert.Equal((string[])["void System.Object.F()", "void System.Object.F()"], model.GetMemberGroup(expr).ToTestDisplayStrings()); } @@ -2090,7 +2090,7 @@ public static void M(this C c, object o) Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2155,7 +2155,7 @@ public static void M(this C c, object o) { } // ignored Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal(["void C.M()", "void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()", "void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2218,7 +2218,7 @@ public static void M(this C c, object o) { } // ignored Assert.True(typeInfo.ConvertedType!.IsErrorType()); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal(["void C.M()", "void C.M(System.Object o)", "void C.M(System.Object o)"], + Assert.Equal((string[])["void C.M()", "void C.M(System.Object o)", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } @@ -2276,7 +2276,7 @@ public static void M(this C c, object o) { } // ignored Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2325,7 +2325,7 @@ public static void M(this C c) Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2365,7 +2365,7 @@ public static void M(this C c) Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); // https://github.com/dotnet/roslyn/issues/52870: GetSymbolInfo() should return resolved method from method group. Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2408,7 +2408,7 @@ public static void M(this C c) Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); // https://github.com/dotnet/roslyn/issues/52870: GetSymbolInfo() should return resolved method from method group. Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2459,7 +2459,7 @@ public static void M(this C c) { } Assert.Null(typeInfo.Type); Assert.True(typeInfo.ConvertedType!.IsErrorType()); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal(["void C.M(C c)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M(C c)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2500,7 +2500,7 @@ public static void M(this C c) Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2548,7 +2548,7 @@ public static class E2 Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2600,7 +2600,7 @@ public static class E2 Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2646,7 +2646,7 @@ public static void M(this C c) Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2694,7 +2694,7 @@ public static void M(this C c) Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2741,7 +2741,7 @@ public static class E Assert.Null(typeInfo.Type); Assert.True(typeInfo.ConvertedType!.IsErrorType()); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal(["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2785,7 +2785,7 @@ public static class DExt var memberAccess = GetSyntax(tree, "c.M"); // https://github.com/dotnet/roslyn/issues/52870: GetSymbolInfo() should return resolved method from method group. Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal(["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Fact, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2835,7 +2835,7 @@ public static void M(this T t) var model = comp.GetSemanticModel(tree); var memberAccess = GetSyntax(tree, "new object().M"); Assert.Equal("void System.Object.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void System.Object.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void System.Object.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69222")] @@ -2865,7 +2865,7 @@ public static void M(this C t) Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void C.M()"], + Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } @@ -2894,7 +2894,7 @@ public static void M(this C c) { } var model = comp.GetSemanticModel(tree); var memberAccess = GetSyntax(tree, "new C().M"); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69222")] @@ -2923,7 +2923,7 @@ public void M(object o) where T : class { } var memberAccess = GetSyntax(tree, "new C().M"); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void C.M()", "void C.M(System.Object o)"], + Assert.Equal((string[])["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } @@ -2954,7 +2954,7 @@ public void M(object o) where T : class { } var memberAccess = GetSyntax(tree, "new C().M"); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal(["void C.M()", "void C.M(System.Object o)"], + Assert.Equal((string[])["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } @@ -2986,7 +2986,7 @@ public void M() where T : class var model = comp.GetSemanticModel(tree); var memberAccess = GetSyntax(tree, "new C().M"); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69222")] @@ -3017,7 +3017,7 @@ public static void M(this T t, object ignored) where T : struct { } var model = comp.GetSemanticModel(tree); var memberAccess = GetSyntax(tree, "new object().M"); Assert.Equal("void System.Object.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void System.Object.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + Assert.Equal((string[])["void System.Object.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69222")] @@ -3049,7 +3049,7 @@ public static void M(this T t, object ignored) where T : struct { } var memberAccess = GetSyntax(tree, "new object().M"); Assert.Equal("void System.Object.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void System.Object.M()", "void System.Object.M(System.Object ignored)"], + Assert.Equal((string[])["void System.Object.M()", "void System.Object.M(System.Object ignored)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } @@ -3084,7 +3084,7 @@ static class A var memberAccess = GetSyntax(tree, "new object().F"); Assert.Equal("void System.Object.F()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal(["void System.Object.F()", "void System.Object.F()"], + Assert.Equal((string[])["void System.Object.F()", "void System.Object.F()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } diff --git a/src/Compilers/Test/Core/Assert/AssertEx.cs b/src/Compilers/Test/Core/Assert/AssertEx.cs index 244b92a4d6aa9..9e41149a8ee3e 100644 --- a/src/Compilers/Test/Core/Assert/AssertEx.cs +++ b/src/Compilers/Test/Core/Assert/AssertEx.cs @@ -19,6 +19,7 @@ using DiffPlex.Chunkers; using DiffPlex.DiffBuilder; using DiffPlex.DiffBuilder.Model; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Test.Utilities; using Xunit; @@ -864,6 +865,7 @@ public static void Empty(IEnumerable items, string message = "") } } + private sealed class LineComparer : IEqualityComparer { public static readonly LineComparer Instance = new LineComparer(); @@ -1013,5 +1015,75 @@ public static void Contains(IEnumerable collection, Predicate filter, F Fail("Filter does not match any item in the collection: " + Environment.NewLine + ToString(collection, itemSeparator ?? Environment.NewLine, itemInspector)); } + +#nullable enable + + /// + /// The xunit Assert.Equal method is not callable in Visual Basic due to the presence of + /// the unmanaged constraint. Need to indirect through C# here until we resolve this. + /// + /// https://github.com/dotnet/roslyn/issues/75063 + /// + public static void Equal(T[] expected, T[] actual) => + Assert.Equal(expected, actual); + + /// + /// The xunit Assert.Equal method is not callable in Visual Basic due to the presence of + /// the unmanaged constraint. Need to indirect through C# here until we resolve this. + /// + /// https://github.com/dotnet/roslyn/issues/75063 + /// + public static void Equal(T expected, T actual) => + Assert.Equal(expected, actual); + + /// + /// The xunit Assert.NotEqual method is not callable in Visual Basic due to the presence of + /// the unmanaged constraint. Need to indirect through C# here until we resolve this. + /// + /// https://github.com/dotnet/roslyn/issues/75063 + /// + public static void NotEqual(T expected, T actual) => + Assert.NotEqual(expected, actual); + + /// + /// This assert passes if the collection is not null and empty + /// + /// + /// The core is annotated to not accept null but many + /// of our call sites pass a potentially nullable value. + /// + public static void AssertEmpty(IEnumerable? collection) + { + Assert.NotNull(collection); + Assert.Empty(collection); + } + + /// + /// This assert passes if the collection is not null and has a single item. + /// + /// + /// The core is annotated to not accept null but many + /// of our call sites pass a potentially nullable value. + /// + public static T Single(IEnumerable? collection) + { + Assert.NotNull(collection); + return Assert.Single(collection); + } + + /// + /// Verify the collection is not null and all the items pass the action. + /// + /// + /// The core is annotated to not accept null but many + /// of our call sites pass a potentially nullable value. + /// + public static void All(IEnumerable? collection, Action action) + { + Assert.NotNull(collection); + Assert.All(collection, action); + } + +#nullable disable } } diff --git a/src/Compilers/VisualBasic/Test/Emit/Attributes/AssemblyAttributes.vb b/src/Compilers/VisualBasic/Test/Emit/Attributes/AssemblyAttributes.vb index 1dbe752231e70..e1ad88031f7e5 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Attributes/AssemblyAttributes.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Attributes/AssemblyAttributes.vb @@ -792,11 +792,11 @@ end class Assert.Equal(AssemblyHashAlgorithm.Sha1, assembly.HashAlgorithm) Dim file1 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(1)) - Assert.Equal(New Byte() {&H6C, &H9C, &H3E, &HDA, &H60, &HF, &H81, &H93, &H4A, &HC1, &HD, &H41, &HB3, &HE9, &HB2, &HB7, &H2D, &HEE, &H59, &HA8}, + AssertEx.Equal(New Byte() {&H6C, &H9C, &H3E, &HDA, &H60, &HF, &H81, &H93, &H4A, &HC1, &HD, &H41, &HB3, &HE9, &HB2, &HB7, &H2D, &HEE, &H59, &HA8}, reader.GetBlobBytes(file1.HashValue)) Dim file2 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(2)) - Assert.Equal(New Byte() {&H7F, &H28, &HEA, &HD1, &HF4, &HA1, &H7C, &HB8, &HC, &H14, &HC0, &H2E, &H8C, &HFF, &H10, &HEC, &HB3, &HC2, &HA5, &H1D}, + AssertEx.Equal(New Byte() {&H7F, &H28, &HEA, &HD1, &HF4, &HA1, &H7C, &HB8, &HC, &H14, &HC0, &H2E, &H8C, &HFF, &H10, &HEC, &HB3, &HC2, &HA5, &H1D}, reader.GetBlobBytes(file2.HashValue)) Assert.Null(peAssembly.ManifestModule.FindTargetAttributes(peAssembly.Handle, AttributeDescription.AssemblyAlgorithmIdAttribute)) @@ -823,11 +823,11 @@ end class Assert.Equal(AssemblyHashAlgorithm.None, assembly.HashAlgorithm) Dim file1 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(1)) - Assert.Equal(New Byte() {&H6C, &H9C, &H3E, &HDA, &H60, &HF, &H81, &H93, &H4A, &HC1, &HD, &H41, &HB3, &HE9, &HB2, &HB7, &H2D, &HEE, &H59, &HA8}, + AssertEx.Equal(New Byte() {&H6C, &H9C, &H3E, &HDA, &H60, &HF, &H81, &H93, &H4A, &HC1, &HD, &H41, &HB3, &HE9, &HB2, &HB7, &H2D, &HEE, &H59, &HA8}, reader.GetBlobBytes(file1.HashValue)) Dim file2 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(2)) - Assert.Equal(New Byte() {&H7F, &H28, &HEA, &HD1, &HF4, &HA1, &H7C, &HB8, &HC, &H14, &HC0, &H2E, &H8C, &HFF, &H10, &HEC, &HB3, &HC2, &HA5, &H1D}, + AssertEx.Equal(New Byte() {&H7F, &H28, &HEA, &HD1, &HF4, &HA1, &H7C, &HB8, &HC, &H14, &HC0, &H2E, &H8C, &HFF, &H10, &HEC, &HB3, &HC2, &HA5, &H1D}, reader.GetBlobBytes(file2.HashValue)) Assert.Null(peAssembly.ManifestModule.FindTargetAttributes(peAssembly.Handle, AttributeDescription.AssemblyAlgorithmIdAttribute)) @@ -854,11 +854,11 @@ end class Assert.Equal(AssemblyHashAlgorithm.MD5, assembly.HashAlgorithm) Dim file1 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(1)) - Assert.Equal(New Byte() {&H24, &H22, &H3, &HC3, &H94, &HD5, &HC2, &HD9, &H99, &HB3, &H6D, &H59, &HB2, &HCA, &H23, &HBC}, + AssertEx.Equal(New Byte() {&H24, &H22, &H3, &HC3, &H94, &HD5, &HC2, &HD9, &H99, &HB3, &H6D, &H59, &HB2, &HCA, &H23, &HBC}, reader.GetBlobBytes(file1.HashValue)) Dim file2 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(2)) - Assert.Equal(New Byte() {&H8D, &HFE, &HBF, &H49, &H8D, &H62, &H2A, &H88, &H89, &HD1, &HE, &H0, &H9E, &H29, &H72, &HF1}, + AssertEx.Equal(New Byte() {&H8D, &HFE, &HBF, &H49, &H8D, &H62, &H2A, &H88, &H89, &HD1, &HE, &H0, &H9E, &H29, &H72, &HF1}, reader.GetBlobBytes(file2.HashValue)) Assert.Null(peAssembly.ManifestModule.FindTargetAttributes(peAssembly.Handle, AttributeDescription.AssemblyAlgorithmIdAttribute)) @@ -885,11 +885,11 @@ end class Assert.Equal(AssemblyHashAlgorithm.Sha1, assembly.HashAlgorithm) Dim file1 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(1)) - Assert.Equal(New Byte() {&H6C, &H9C, &H3E, &HDA, &H60, &HF, &H81, &H93, &H4A, &HC1, &HD, &H41, &HB3, &HE9, &HB2, &HB7, &H2D, &HEE, &H59, &HA8}, + AssertEx.Equal(New Byte() {&H6C, &H9C, &H3E, &HDA, &H60, &HF, &H81, &H93, &H4A, &HC1, &HD, &H41, &HB3, &HE9, &HB2, &HB7, &H2D, &HEE, &H59, &HA8}, reader.GetBlobBytes(file1.HashValue)) Dim file2 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(2)) - Assert.Equal(New Byte() {&H7F, &H28, &HEA, &HD1, &HF4, &HA1, &H7C, &HB8, &HC, &H14, &HC0, &H2E, &H8C, &HFF, &H10, &HEC, &HB3, &HC2, &HA5, &H1D}, + AssertEx.Equal(New Byte() {&H7F, &H28, &HEA, &HD1, &HF4, &HA1, &H7C, &HB8, &HC, &H14, &HC0, &H2E, &H8C, &HFF, &H10, &HEC, &HB3, &HC2, &HA5, &H1D}, reader.GetBlobBytes(file2.HashValue)) Assert.Null(peAssembly.ManifestModule.FindTargetAttributes(peAssembly.Handle, AttributeDescription.AssemblyAlgorithmIdAttribute)) @@ -915,11 +915,11 @@ end class Assert.Equal(System.Configuration.Assemblies.AssemblyHashAlgorithm.SHA256, CType(assembly.HashAlgorithm, System.Configuration.Assemblies.AssemblyHashAlgorithm)) Dim file1 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(1)) - Assert.Equal(New Byte() {&HA2, &H32, &H3F, &HD, &HF4, &HB8, &HED, &H5A, &H1B, &H7B, &HBE, &H14, &H4F, &HEC, &HBF, &H88, &H23, &H61, &HEB, &H40, &HF7, &HF9, &H46, &HEF, &H68, &H3B, &H70, &H29, &HCF, &H12, &H5, &H35}, + AssertEx.Equal(New Byte() {&HA2, &H32, &H3F, &HD, &HF4, &HB8, &HED, &H5A, &H1B, &H7B, &HBE, &H14, &H4F, &HEC, &HBF, &H88, &H23, &H61, &HEB, &H40, &HF7, &HF9, &H46, &HEF, &H68, &H3B, &H70, &H29, &HCF, &H12, &H5, &H35}, reader.GetBlobBytes(file1.HashValue)) Dim file2 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(2)) - Assert.Equal(New Byte() {&HCC, &HAE, &HA0, &HB4, &H9E, &HAE, &H28, &HE0, &HA3, &H46, &HE9, &HCF, &HF3, &HEF, &HEA, &HF7, + AssertEx.Equal(New Byte() {&HCC, &HAE, &HA0, &HB4, &H9E, &HAE, &H28, &HE0, &HA3, &H46, &HE9, &HCF, &HF3, &HEF, &HEA, &HF7, &H1D, &HDE, &H62, &H8F, &HD6, &HF4, &H87, &H76, &H1A, &HC3, &H6F, &HAD, &H10, &H1C, &H10, &HAC}, reader.GetBlobBytes(file2.HashValue)) @@ -946,13 +946,13 @@ end class Assert.Equal(System.Configuration.Assemblies.AssemblyHashAlgorithm.SHA384, CType(assembly.HashAlgorithm, System.Configuration.Assemblies.AssemblyHashAlgorithm)) Dim file1 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(1)) - Assert.Equal(New Byte() {&HB6, &H35, &H9B, &HBE, &H82, &H89, &HFF, &H1, &H22, &H8B, &H56, &H5E, &H9B, &H15, &H5D, &H10, + AssertEx.Equal(New Byte() {&HB6, &H35, &H9B, &HBE, &H82, &H89, &HFF, &H1, &H22, &H8B, &H56, &H5E, &H9B, &H15, &H5D, &H10, &H68, &H83, &HF7, &H75, &H4E, &HA6, &H30, &HF7, &H8D, &H39, &H9A, &HB7, &HE8, &HB6, &H47, &H1F, &HF6, &HFD, &H1E, &H64, &H63, &H6B, &HE7, &HF4, &HBE, &HA7, &H21, &HED, &HFC, &H82, &H38, &H95}, reader.GetBlobBytes(file1.HashValue)) Dim file2 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(2)) - Assert.Equal(New Byte() {&H45, &H5, &H2E, &H90, &H9B, &H61, &HA3, &HF8, &H60, &HD2, &H86, &HCB, &H10, &H33, &HC9, &H86, + AssertEx.Equal(New Byte() {&H45, &H5, &H2E, &H90, &H9B, &H61, &HA3, &HF8, &H60, &HD2, &H86, &HCB, &H10, &H33, &HC9, &H86, &H68, &HA5, &HEE, &H4A, &HCF, &H21, &H10, &HA9, &H8F, &H14, &H62, &H8D, &H3E, &H7D, &HFD, &H7E, &HE6, &H23, &H6F, &H2D, &HBA, &H4, &HE7, &H13, &HE4, &H5E, &H8C, &HEB, &H80, &H68, &HA3, &H17}, reader.GetBlobBytes(file2.HashValue)) @@ -980,14 +980,14 @@ end class Assert.Equal(System.Configuration.Assemblies.AssemblyHashAlgorithm.SHA512, CType(assembly.HashAlgorithm, System.Configuration.Assemblies.AssemblyHashAlgorithm)) Dim file1 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(1)) - Assert.Equal(New Byte() {&H5F, &H4D, &H7E, &H63, &HC9, &H87, &HD9, &HEB, &H4F, &H5C, &HFD, &H96, &H3F, &H25, &H58, &H74, + AssertEx.Equal(New Byte() {&H5F, &H4D, &H7E, &H63, &HC9, &H87, &HD9, &HEB, &H4F, &H5C, &HFD, &H96, &H3F, &H25, &H58, &H74, &H86, &HDF, &H97, &H75, &H93, &HEE, &HC2, &H5F, &HFD, &H8A, &H40, &H5C, &H92, &H5E, &HB5, &H7, &HD6, &H12, &HE9, &H21, &H55, &HCE, &HD7, &HE5, &H15, &HF5, &HBA, &HBC, &H1B, &H31, &HAD, &H3C, &H5E, &HE0, &H91, &H98, &HC2, &HE0, &H96, &HBB, &HAD, &HD, &H4E, &HF4, &H91, &H53, &H3D, &H84}, reader.GetBlobBytes(file1.HashValue)) Dim file2 = reader.GetAssemblyFile(MetadataTokens.AssemblyFileHandle(2)) - Assert.Equal(New Byte() {&H79, &HFE, &H97, &HAB, &H8, &H8E, &HDF, &H74, &HC2, &HEF, &H84, &HBB, &HFC, &H74, &HAC, &H60, + AssertEx.Equal(New Byte() {&H79, &HFE, &H97, &HAB, &H8, &H8E, &HDF, &H74, &HC2, &HEF, &H84, &HBB, &HFC, &H74, &HAC, &H60, &H18, &H6E, &H1A, &HD2, &HC5, &H94, &HE0, &HDA, &HE0, &H45, &H33, &H43, &H99, &HF0, &HF3, &HF1, &H72, &H5, &H4B, &HF, &H37, &H50, &HC5, &HD9, &HCE, &H29, &H82, &H4C, &HF7, &HE6, &H94, &H5F, &HE5, &H7, &H2B, &H4A, &H18, &H9, &H56, &HC9, &H52, &H69, &H7D, &HC4, &H48, &H63, &H70, &HF2}, diff --git a/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests.vb b/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests.vb index a99bb6fdb3e90..3c64b76dadf01 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests.vb @@ -4393,7 +4393,7 @@ End Class Dim nullArray As Integer() = Nothing Dim emptyArray As Integer() = {} - Assert.NotEqual(nullArray, emptyArray) + AssertEx.NotEqual(nullArray, emptyArray) attrs(0).VerifyValue(0, TypedConstantKind.Array, nullArray) diff --git a/src/Compilers/VisualBasic/Test/Emit/Attributes/InternalsVisibleToAndStrongNameTests.vb b/src/Compilers/VisualBasic/Test/Emit/Attributes/InternalsVisibleToAndStrongNameTests.vb index fea12702c8e2c..4d90278dfd7f4 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Attributes/InternalsVisibleToAndStrongNameTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Attributes/InternalsVisibleToAndStrongNameTests.vb @@ -1140,7 +1140,7 @@ End Class Assert.True(comp.IsRealSigned) VerifySigned(comp) Assert.Equal(TestResources.General.snMaxSizePublicKey, comp.Assembly.Identity.PublicKey) - Assert.Equal(Of Byte)(pubKeyTokenBytes, comp.Assembly.Identity.PublicKeyToken) + AssertEx.Equal(Of Byte)(pubKeyTokenBytes, comp.Assembly.Identity.PublicKeyToken) Dim src = @@ -1158,14 +1158,14 @@ End Class CompileAndVerify(comp2, expectedOutput:="Called M") Assert.Equal(TestResources.General.snMaxSizePublicKey, comp2.Assembly.Identity.PublicKey) - Assert.Equal(Of Byte)(pubKeyTokenBytes, comp2.Assembly.Identity.PublicKeyToken) + AssertEx.Equal(Of Byte)(pubKeyTokenBytes, comp2.Assembly.Identity.PublicKeyToken) Dim comp3 = CreateCompilation(src, references:={comp.EmitToImageReference()}, options:=TestOptions.SigningReleaseExe.WithCryptoKeyFile(SigningTestHelpers.MaxSizeKeyFile), parseOptions:=parseOptions) CompileAndVerify(comp3, expectedOutput:="Called M") Assert.Equal(TestResources.General.snMaxSizePublicKey, comp3.Assembly.Identity.PublicKey) - Assert.Equal(Of Byte)(pubKeyTokenBytes, comp3.Assembly.Identity.PublicKeyToken) + AssertEx.Equal(Of Byte)(pubKeyTokenBytes, comp3.Assembly.Identity.PublicKeyToken) End Sub diff --git a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb index b1ae0b1ca9935..d67a719f84de7 100644 --- a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb +++ b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb @@ -14924,7 +14924,7 @@ options:=TestOptions.DebugExe, additionalRefs:=s_valueTupleRefs) "ReadOnly Property (System.Int32, System.Int32).System.ITupleInternal.Size As System.Int32" ) - Assert.Equal({ + AssertEx.Equal({ ".ctor", ".ctor", "CompareTo", @@ -14967,7 +14967,7 @@ options:=TestOptions.DebugExe, additionalRefs:=s_valueTupleRefs) "ReadOnly Property (a2 As System.Int32, b2 As System.Int32).System.ITupleInternal.Size As System.Int32" ) - Assert.Equal({ + AssertEx.Equal({ ".ctor", ".ctor", "CompareTo", @@ -15008,7 +15008,7 @@ options:=TestOptions.DebugExe, additionalRefs:=s_valueTupleRefs) "ReadOnly Property (Item1 As System.Int32, Item2 As System.Int32).System.ITupleInternal.Size As System.Int32" ) - Assert.Equal({ + AssertEx.Equal({ ".ctor", ".ctor", "CompareTo", @@ -15041,7 +15041,7 @@ options:=TestOptions.DebugExe, additionalRefs:=s_valueTupleRefs) Assert.Same(m1Tuple.TupleUnderlyingType.ContainingSymbol, m1Tuple.ContainingSymbol) Assert.Null(m1Tuple.EnumUnderlyingType) - Assert.Equal({ + AssertEx.Equal({ "Item1", "Item2", ".ctor", @@ -15059,7 +15059,7 @@ options:=TestOptions.DebugExe, additionalRefs:=s_valueTupleRefs) "System.ITupleInternal.Size"}, m1Tuple.MemberNames.ToArray()) - Assert.Equal({ + AssertEx.Equal({ "Item1", "a2", "Item2", @@ -16299,9 +16299,9 @@ options:=TestOptions.DebugExe) Assert.Same(m1Tuple.TupleUnderlyingType.ContainingSymbol, m1Tuple.ContainingSymbol) Assert.Null(m1Tuple.GetUseSiteErrorInfo()) Assert.Null(m1Tuple.EnumUnderlyingType) - Assert.Equal({".ctor", "Item1", "Item2", "ToString"}, + AssertEx.Equal({".ctor", "Item1", "Item2", "ToString"}, m1Tuple.MemberNames.ToArray()) - Assert.Equal({".ctor", "Item1", "a2", "Item2", "b2", "ToString"}, + AssertEx.Equal({".ctor", "Item1", "a2", "Item2", "b2", "ToString"}, m2Tuple.MemberNames.ToArray()) Assert.Equal(0, m1Tuple.Arity) Assert.True(m1Tuple.TypeParameters.IsEmpty) diff --git a/src/Compilers/VisualBasic/Test/Emit/Emit/CompilationEmitTests.vb b/src/Compilers/VisualBasic/Test/Emit/Emit/CompilationEmitTests.vb index 2e12ddfa1b02b..49cae4245eee9 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Emit/CompilationEmitTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Emit/CompilationEmitTests.vb @@ -2460,7 +2460,7 @@ Imports System Dim actualGlobalMembers = DirectCast(m, SourceModuleSymbol).GlobalNamespace.GetMembers().ToArray() Assert.NotNull(m.GlobalNamespace.ContainingModule) - Assert.Equal(Of String)("C.dll", m.GlobalNamespace.ContainingModule.ToString) + AssertEx.Equal(Of String)("C.dll", m.GlobalNamespace.ContainingModule.ToString) For i As Integer = 0 To Math.Max(expectedGlobalMembers.Length, actualGlobalMembers.Length) - 1 Assert.Equal(expectedGlobalMembers(i), actualGlobalMembers(i).Name) diff --git a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueStateMachineTests.vb b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueStateMachineTests.vb index d6977b593699d..895d83c23f315 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueStateMachineTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueStateMachineTests.vb @@ -3968,7 +3968,7 @@ End Class") Dim compilation1 = compilation0.WithSource(source1.Tree) Dim v0 = CompileAndVerify(compilation:=compilation0, symbolValidator:=Sub([module] As ModuleSymbol) - Assert.Equal( + AssertEx.Equal( { "$State: System.Int32", "$Current: System.Int32", @@ -3981,7 +3981,7 @@ End Class") End Sub) Dim v1 = CompileAndVerify(compilation:=compilation1, symbolValidator:=Sub([module] As ModuleSymbol) - Assert.Equal( + AssertEx.Equal( { "$State: System.Int32", "$Current: System.Int32", @@ -7027,7 +7027,7 @@ End Class") Dim h3 = compilation3.GetMember(Of MethodSymbol)("C.H") Dim v0 = CompileAndVerify(compilation:=compilation0, symbolValidator:=Sub([module] As ModuleSymbol) - Assert.Equal( + AssertEx.Equal( { "$State: System.Int32", "$Builder: System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of System.Int32)", @@ -7374,7 +7374,7 @@ End Class Dim compilation0 = CreateEmptyCompilationWithReferences(source0, references:=LatestVbReferences, options:=ComSafeDebugDll.WithMetadataImportOptions(MetadataImportOptions.All)) CompileAndVerify(compilation:=compilation0, symbolValidator:=Sub([module] As ModuleSymbol) - Assert.Equal( + AssertEx.Equal( { "$State: System.Int32", "$Builder: System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of System.Int32)", @@ -7383,7 +7383,7 @@ End Class "$A1: System.Runtime.CompilerServices.TaskAwaiter(Of System.Int32)" }, [module].GetFieldNamesAndTypes("C.VB$StateMachine_4_F")) - Assert.Equal( + AssertEx.Equal( { "$State: System.Int32", "$Builder: System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of System.Int32)", @@ -7528,7 +7528,7 @@ End Class") Dim v0 = CompileAndVerify(compilation:=compilation0, symbolValidator:= Sub([module] As ModuleSymbol) - Assert.Equal( + AssertEx.Equal( { "$State: System.Int32", "$Builder: System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of System.Int32)", @@ -8132,7 +8132,7 @@ End Class") Dim v0 = CompileAndVerify(compilation0, symbolValidator:= Sub([module]) - Assert.Equal( + AssertEx.Equal( { "$State: System.Int32", "$Builder: System.Runtime.CompilerServices.AsyncTaskMethodBuilder", diff --git a/src/Compilers/VisualBasic/Test/Semantic/Binding/BindingCollectionInitializerTests.vb b/src/Compilers/VisualBasic/Test/Semantic/Binding/BindingCollectionInitializerTests.vb index 077fb5968150b..51fac213420f2 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/Binding/BindingCollectionInitializerTests.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/Binding/BindingCollectionInitializerTests.vb @@ -1847,7 +1847,7 @@ End Class Assert.Null(symbolInfo.Symbol) Assert.Equal(CandidateReason.OverloadResolutionFailure, symbolInfo.CandidateReason) Assert.Equal(2, symbolInfo.CandidateSymbols.Length) - Assert.Equal({"Sub X.Add(x As System.Collections.Generic.List(Of System.Byte))", + AssertEx.Equal({"Sub X.Add(x As System.Collections.Generic.List(Of System.Byte))", "Sub X.Add(x As X)"}, (symbolInfo.CandidateSymbols.Select(Function(s) s.ToTestDisplayString()).Order()).ToArray()) End Sub diff --git a/src/Compilers/VisualBasic/Test/Semantic/Binding/LookupTests.vb b/src/Compilers/VisualBasic/Test/Semantic/Binding/LookupTests.vb index 0674d5b3c3701..839c36a9d8df2 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/Binding/LookupTests.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/Binding/LookupTests.vb @@ -1622,11 +1622,11 @@ End Module Assert.Equal(NamespaceKind.Module, ns.NamespaceKind) Assert.Equal("System.ComponentModel", ns.ToTestDisplayString()) - Assert.Equal({"System.ComponentModel", "System.Windows.Forms.ComponentModel"}, + AssertEx.Equal({"System.ComponentModel", "System.Windows.Forms.ComponentModel"}, semanticModel.LookupNamespacesAndTypes(node.Position, name:="ComponentModel").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"System.ComponentModel", "System.Windows.Forms.ComponentModel"}, + AssertEx.Equal({"System.ComponentModel", "System.Windows.Forms.ComponentModel"}, semanticModel.LookupSymbols(node.Position, name:="ComponentModel").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) End Sub @@ -1672,11 +1672,11 @@ BC30112: 'Diagnostics' is a namespace and cannot be used as an expression. Assert.Equal(NamespaceKind.Compilation, ns.NamespaceKind) Assert.Equal("System.Diagnostics", ns.ToTestDisplayString()) - Assert.Equal({"System.Diagnostics", "Windows.Foundation.Diagnostics"}, + AssertEx.Equal({"System.Diagnostics", "Windows.Foundation.Diagnostics"}, semanticModel.LookupNamespacesAndTypes(node.Position, name:="Diagnostics").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"System.Diagnostics", "Windows.Foundation.Diagnostics"}, + AssertEx.Equal({"System.Diagnostics", "Windows.Foundation.Diagnostics"}, semanticModel.LookupSymbols(node.Position, name:="Diagnostics").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) End Sub @@ -1741,11 +1741,11 @@ End Namespace Assert.Equal(NamespaceKind.Module, ns1.NamespaceKind) Assert.Equal("NS1.NS3", ns1.ToTestDisplayString()) - Assert.Equal({"NS1.NS3", "NS2.NS3"}, + AssertEx.Equal({"NS1.NS3", "NS2.NS3"}, semanticModel.LookupNamespacesAndTypes(node1.Position, name:="NS3").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"NS1.NS3", "NS2.NS3"}, + AssertEx.Equal({"NS1.NS3", "NS2.NS3"}, semanticModel.LookupSymbols(node1.Position, name:="NS3").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) End Sub @@ -1928,7 +1928,7 @@ BC37229: 'T1' is ambiguous between declarations in namespaces 'NS1.NS6.NS7, NS2. Assert.Null(info3.Symbol) Assert.Equal(CandidateReason.Ambiguous, info3.CandidateReason) ' Content of this list should determine content of lists below !!! - Assert.Equal({"NS1.NS6.NS7.T1", "NS2.NS6.NS7.T1", "NS4.NS6.NS7.T1", "NS5.NS6.NS7.T1"}, info3.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"NS1.NS6.NS7.T1", "NS2.NS6.NS7.T1", "NS4.NS6.NS7.T1", "NS5.NS6.NS7.T1"}, info3.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next For Each i In {2, 5, 8, 23} @@ -1936,7 +1936,7 @@ BC37229: 'T1' is ambiguous between declarations in namespaces 'NS1.NS6.NS7, NS2. Assert.Null(info2.Symbol) Assert.Equal(CandidateReason.Ambiguous, info2.CandidateReason) - Assert.Equal({"NS1.NS6.NS7", "NS2.NS6.NS7", "NS4.NS6.NS7", "NS5.NS6.NS7"}, info2.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"NS1.NS6.NS7", "NS2.NS6.NS7", "NS4.NS6.NS7", "NS5.NS6.NS7"}, info2.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next For Each i In {1, 4, 7, 22} @@ -1944,13 +1944,13 @@ BC37229: 'T1' is ambiguous between declarations in namespaces 'NS1.NS6.NS7, NS2. Assert.Null(info1.Symbol) Assert.Equal(CandidateReason.Ambiguous, info1.CandidateReason) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS4.NS6", "NS5.NS6"}, info1.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS4.NS6", "NS5.NS6"}, info1.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS4.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS4.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupNamespacesAndTypes(nodes(i).Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS4.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS4.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupSymbols(nodes(i).Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next @@ -1960,7 +1960,7 @@ BC37229: 'T1' is ambiguous between declarations in namespaces 'NS1.NS6.NS7, NS2. Assert.Null(info2.Symbol) Assert.Equal(If(i = 16, CandidateReason.Ambiguous, If(i = 19, CandidateReason.NotAnAttributeType, CandidateReason.NotATypeOrNamespace)), info2.CandidateReason) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS4.NS6", "NS5.NS6", "NS9.NS6"}, info2.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS4.NS6", "NS5.NS6", "NS9.NS6"}, info2.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next For Each i In {12, 15, 18, 21} @@ -1969,7 +1969,7 @@ BC37229: 'T1' is ambiguous between declarations in namespaces 'NS1.NS6.NS7, NS2. Assert.Null(info3.Symbol) Assert.Equal(If(i = 18, CandidateReason.Ambiguous, If(i = 21, CandidateReason.NotAnAttributeType, CandidateReason.NotATypeOrNamespace)), info3.CandidateReason) ' Content of this list should determine content of lists below !!! - Assert.Equal({"NS1.NS6.NS7", "NS2.NS6.NS7", "NS4.NS6.NS7", "NS5.NS6.NS7", "NS9.NS6.NS7"}, info3.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"NS1.NS6.NS7", "NS2.NS6.NS7", "NS4.NS6.NS7", "NS5.NS6.NS7", "NS9.NS6.NS7"}, info3.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next For Each i In {11, 14, 17, 20} @@ -1977,7 +1977,7 @@ BC37229: 'T1' is ambiguous between declarations in namespaces 'NS1.NS6.NS7, NS2. Assert.Null(info3.Symbol) Assert.Equal(CandidateReason.Ambiguous, info3.CandidateReason) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS4.NS6", "NS5.NS6", "NS9.NS6"}, info3.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS4.NS6", "NS5.NS6", "NS9.NS6"}, info3.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next End Sub @@ -2112,11 +2112,11 @@ End Namespace Assert.Equal("NS1.NS6", info1.Symbol.ToTestDisplayString()) Assert.Equal(NamespaceKind.Module, DirectCast(info1.Symbol, NamespaceSymbol).NamespaceKind) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS4.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS4.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupNamespacesAndTypes(nodes(i).Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS4.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS4.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupSymbols(nodes(i).Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next @@ -2240,27 +2240,27 @@ BC30002: Type 'NS6.NS7.M1' is not defined. Assert.Null(info3.Symbol) Assert.Equal(If(i = 3, CandidateReason.Ambiguous, CandidateReason.NotATypeOrNamespace), info3.CandidateReason) ' Content of this list should determine content of lists below !!! - Assert.Equal({"Sub NS1.NS6.NS7.T1.M1()", "Sub NS2.NS6.NS7.T1.M1()", "Sub NS5.NS6.NS7.T1.M1()"}, info3.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"Sub NS1.NS6.NS7.T1.M1()", "Sub NS2.NS6.NS7.T1.M1()", "Sub NS5.NS6.NS7.T1.M1()"}, info3.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next For Each i In {2, 5, 8, 11} Dim info2 = semanticModel.GetSymbolInfo(nodes(i)) Assert.Null(info2.Symbol) Assert.Equal(CandidateReason.Ambiguous, info2.CandidateReason) - Assert.Equal({"NS1.NS6.NS7", "NS2.NS6.NS7", "NS5.NS6.NS7"}, info2.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"NS1.NS6.NS7", "NS2.NS6.NS7", "NS5.NS6.NS7"}, info2.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next For Each i In {1, 4, 7, 10} Dim info1 = semanticModel.GetSymbolInfo(nodes(i)) Assert.Null(info1.Symbol) Assert.Equal(CandidateReason.Ambiguous, info1.CandidateReason) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS5.NS6"}, info1.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS5.NS6"}, info1.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupNamespacesAndTypes(nodes(i).Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupSymbols(nodes(i).Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next @@ -2353,7 +2353,7 @@ BC30516: Overload resolution failed because no accessible 'M1' accepts this numb Assert.Null(info3.Symbol) Assert.Equal(CandidateReason.OverloadResolutionFailure, info3.CandidateReason) - Assert.Equal({"Sub NS1.NS6.NS7.T1.M1(x As System.Int32)", "Sub NS1.NS6.NS7.T1.M1(x As System.Int64)"}, info3.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"Sub NS1.NS6.NS7.T1.M1(x As System.Int32)", "Sub NS1.NS6.NS7.T1.M1(x As System.Int64)"}, info3.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Dim node2 As IdentifierNameSyntax = CompilationUtils.FindBindingText(Of IdentifierNameSyntax)(compilation, "a.vb", 2) @@ -2367,11 +2367,11 @@ BC30516: Overload resolution failed because no accessible 'M1' accepts this numb Assert.Equal("NS1.NS6", info1.Symbol.ToTestDisplayString()) Assert.Equal(NamespaceKind.Module, DirectCast(info1.Symbol, NamespaceSymbol).NamespaceKind) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupNamespacesAndTypes(node1.Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupSymbols(node1.Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) End Sub @@ -2468,11 +2468,11 @@ End Namespace Assert.Equal("NS1.NS6", info1.Symbol.ToTestDisplayString()) Assert.Equal(NamespaceKind.Module, DirectCast(info1.Symbol, NamespaceSymbol).NamespaceKind) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupNamespacesAndTypes(node1.Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupSymbols(node1.Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) End Sub @@ -2598,27 +2598,27 @@ BC30562: 'T1' is ambiguous between declarations in Modules 'NS1.NS6.NS7.Module1, Assert.Null(info3.Symbol) Assert.Equal(CandidateReason.Ambiguous, info3.CandidateReason) ' Content of this list should determine content of lists below !!! - Assert.Equal({"NS1.NS6.NS7.Module1.T1", "NS2.NS6.NS7.Module1.T1", "NS5.NS6.NS7.Module1.T1"}, info3.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"NS1.NS6.NS7.Module1.T1", "NS2.NS6.NS7.Module1.T1", "NS5.NS6.NS7.Module1.T1"}, info3.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next For Each i In {2, 5, 8, 11} Dim info2 = semanticModel.GetSymbolInfo(nodes(i)) Assert.Null(info2.Symbol) Assert.Equal(CandidateReason.Ambiguous, info2.CandidateReason) - Assert.Equal({"NS1.NS6.NS7", "NS2.NS6.NS7", "NS5.NS6.NS7"}, info2.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"NS1.NS6.NS7", "NS2.NS6.NS7", "NS5.NS6.NS7"}, info2.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next For Each i In {1, 4, 7, 10} Dim info1 = semanticModel.GetSymbolInfo(nodes(i)) Assert.Null(info1.Symbol) Assert.Equal(CandidateReason.Ambiguous, info1.CandidateReason) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS5.NS6"}, info1.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS5.NS6"}, info1.CandidateSymbols.AsEnumerable().Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupNamespacesAndTypes(nodes(i).Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupSymbols(nodes(i).Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next @@ -2745,11 +2745,11 @@ BC30109: 'Module1.T1' is a class type and cannot be used as an expression. Assert.Equal("NS1.NS6", info1.Symbol.ToTestDisplayString()) Assert.Equal(NamespaceKind.Module, DirectCast(info1.Symbol, NamespaceSymbol).NamespaceKind) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupNamespacesAndTypes(nodes(i).Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) - Assert.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, + AssertEx.Equal({"NS1.NS6", "NS2.NS6", "NS3.NS6", "NS5.NS6", "NS9.NS6"}, semanticModel.LookupSymbols(nodes(i).Position, name:="NS6").AsEnumerable(). Select(Function(s) s.ToTestDisplayString()).OrderBy(Function(s) s).ToArray()) Next diff --git a/src/Compilers/VisualBasic/Test/Semantic/Compilation/CompilationAPITests.vb b/src/Compilers/VisualBasic/Test/Semantic/Compilation/CompilationAPITests.vb index 8ca31ea3b85b1..fa7e860d7c8c4 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/Compilation/CompilationAPITests.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/Compilation/CompilationAPITests.vb @@ -381,7 +381,7 @@ End Namespace comp = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(compilationDef) 'IsCaseSensitive - Assert.Equal(Of Boolean)(False, comp.IsCaseSensitive) + AssertEx.Equal(Of Boolean)(False, comp.IsCaseSensitive) Assert.Equal("D", comp.GetTypeByMetadataName("C+D").Name) Assert.Equal("E", comp.GetTypeByMetadataName("C+D+E").Name) @@ -561,19 +561,19 @@ End Namespace 'WithReferences Dim hs1 As New HashSet(Of MetadataReference) From {ref1, ref2, ref3} Dim compCollection1 = VisualBasicCompilation.Create("Compilation") - Assert.Equal(Of Integer)(0, Enumerable.Count(Of MetadataReference)(compCollection1.References)) + AssertEx.Equal(Of Integer)(0, Enumerable.Count(Of MetadataReference)(compCollection1.References)) Dim c2 As Compilation = compCollection1.WithReferences(hs1) - Assert.Equal(Of Integer)(3, Enumerable.Count(Of MetadataReference)(c2.References)) + AssertEx.Equal(Of Integer)(3, Enumerable.Count(Of MetadataReference)(c2.References)) 'WithReferences Dim compCollection2 = VisualBasicCompilation.Create("Compilation") - Assert.Equal(Of Integer)(0, Enumerable.Count(Of MetadataReference)(compCollection2.References)) + AssertEx.Equal(Of Integer)(0, Enumerable.Count(Of MetadataReference)(compCollection2.References)) Dim c3 As Compilation = compCollection1.WithReferences(ref1, ref2, ref3) - Assert.Equal(Of Integer)(3, Enumerable.Count(Of MetadataReference)(c3.References)) + AssertEx.Equal(Of Integer)(3, Enumerable.Count(Of MetadataReference)(c3.References)) 'ReferencedAssemblyNames Dim RefAsm_Names As IEnumerable(Of AssemblyIdentity) = c2.ReferencedAssemblyNames - Assert.Equal(Of Integer)(2, Enumerable.Count(Of AssemblyIdentity)(RefAsm_Names)) + AssertEx.Equal(Of Integer)(2, Enumerable.Count(Of AssemblyIdentity)(RefAsm_Names)) Dim ListNames As New List(Of String) Dim I As AssemblyIdentity For Each I In RefAsm_Names @@ -584,7 +584,7 @@ End Namespace 'RemoveAllReferences c2 = c2.RemoveAllReferences - Assert.Equal(Of Integer)(0, Enumerable.Count(Of MetadataReference)(c2.References)) + AssertEx.Equal(Of Integer)(0, Enumerable.Count(Of MetadataReference)(c2.References)) ' Overload with Hashset Dim hs = New HashSet(Of MetadataReference)() From {ref1, ref2, ref3} @@ -796,13 +796,13 @@ End Namespace 'ContainsSyntaxTree Dim b1 As Boolean = comp.ContainsSyntaxTree(t2) - Assert.Equal(Of Boolean)(False, b1) + AssertEx.Equal(Of Boolean)(False, b1) comp = comp.AddSyntaxTrees({t2}) b1 = comp.ContainsSyntaxTree(t2) - Assert.Equal(Of Boolean)(True, b1) + AssertEx.Equal(Of Boolean)(True, b1) Dim xt As SyntaxTree = Nothing - Assert.Equal(Of Boolean)(False, comp.ContainsSyntaxTree(xt)) + AssertEx.Equal(Of Boolean)(False, comp.ContainsSyntaxTree(xt)) comp = comp.RemoveSyntaxTrees({t2}) Assert.Equal(1, comp.SyntaxTrees.Length) @@ -813,8 +813,8 @@ End Namespace comp = comp.RemoveAllSyntaxTrees Assert.Equal(0, comp.SyntaxTrees.Length) comp = VisualBasicCompilation.Create("Compilation").AddSyntaxTrees(listSyntaxTree).RemoveSyntaxTrees({t2}) - Assert.Equal(Of Integer)(1, comp.SyntaxTrees.Length) - Assert.Equal(Of String)("Object", comp.ObjectType.Name) + AssertEx.Equal(Of Integer)(1, comp.SyntaxTrees.Length) + AssertEx.Equal(Of String)("Object", comp.ObjectType.Name) ' Remove mid SyntaxTree listSyntaxTree.Add(t3) diff --git a/src/Compilers/VisualBasic/Test/Semantic/Compilation/SemanticModelGetDeclaredSymbolAPITests.vb b/src/Compilers/VisualBasic/Test/Semantic/Compilation/SemanticModelGetDeclaredSymbolAPITests.vb index c3cbe9b56c90a..82518b12199b3 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/Compilation/SemanticModelGetDeclaredSymbolAPITests.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/Compilation/SemanticModelGetDeclaredSymbolAPITests.vb @@ -1939,7 +1939,7 @@ End Module Assert.False(symLabel.IsOverrides) Assert.False(symLabel.IsOverridable) Assert.False(symLabel.IsShared) - Assert.Equal(Of Accessibility)(Accessibility.NotApplicable, symLabel.DeclaredAccessibility) + AssertEx.Equal(Of Accessibility)(Accessibility.NotApplicable, symLabel.DeclaredAccessibility) Assert.Equal(1, symLabel.Locations.Length) Assert.Equal("Public Sub Main()", symLabel.ContainingSymbol.ToString) Assert.Equal("Public Sub Main()", symLabel.ContainingMethod.ToString) @@ -2625,7 +2625,7 @@ End Namespace Dim memSymbol = compilation.GlobalNamespace.GetMembers("System").Single() Assert.Equal(nsSymbolA.Locations.Length, memSymbol.Locations.Length) - Assert.Equal(Of ISymbol)(nsSymbolA, memSymbol) + AssertEx.Equal(Of ISymbol)(nsSymbolA, memSymbol) End Sub diff --git a/src/Compilers/VisualBasic/Test/Semantic/FlowAnalysis/FlowTestBase.vb b/src/Compilers/VisualBasic/Test/Semantic/FlowAnalysis/FlowTestBase.vb index c22508b3c9745..1717b4f1aa6c3 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/FlowAnalysis/FlowTestBase.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/FlowAnalysis/FlowTestBase.vb @@ -225,19 +225,19 @@ tryAgain: Dim analysis = CompileAndAnalyzeDataFlow(code) Assert.True(analysis.Succeeded) - Assert.Equal(If(alwaysAssigned, {}), analysis.AlwaysAssigned.Select(Function(s) s.Name).ToArray()) - Assert.Equal(If(captured, {}), analysis.Captured.Select(Function(s) s.Name).ToArray()) - Assert.Equal(If(dataFlowsIn, {}), analysis.DataFlowsIn.Select(Function(s) s.Name).ToArray()) - Assert.Equal(If(dataFlowsOut, {}), analysis.DataFlowsOut.Select(Function(s) s.Name).ToArray()) - Assert.Equal(If(definitelyAssignedOnEntry, {}), analysis.DefinitelyAssignedOnEntry.Select(Function(s) s.Name).ToArray()) - Assert.Equal(If(definitelyAssignedOnExit, {}), analysis.DefinitelyAssignedOnExit.Select(Function(s) s.Name).ToArray()) - Assert.Equal(If(readInside, {}), analysis.ReadInside.Select(Function(s) s.Name).ToArray()) - Assert.Equal(If(readOutside, {}), analysis.ReadOutside.Select(Function(s) s.Name).ToArray()) - Assert.Equal(If(variablesDeclared, {}), analysis.VariablesDeclared.Select(Function(s) s.Name).ToArray()) - Assert.Equal(If(writtenInside, {}), analysis.WrittenInside.Select(Function(s) s.Name).ToArray()) - Assert.Equal(If(writtenOutside, {}), analysis.WrittenOutside.Select(Function(s) s.Name).ToArray()) - Assert.Equal(If(capturedInside, {}), analysis.CapturedInside.Select(Function(s) s.Name).ToArray()) - Assert.Equal(If(capturedOutside, {}), analysis.CapturedOutside.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(alwaysAssigned, {}), analysis.AlwaysAssigned.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(captured, {}), analysis.Captured.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(dataFlowsIn, {}), analysis.DataFlowsIn.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(dataFlowsOut, {}), analysis.DataFlowsOut.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(definitelyAssignedOnEntry, {}), analysis.DefinitelyAssignedOnEntry.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(definitelyAssignedOnExit, {}), analysis.DefinitelyAssignedOnExit.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(readInside, {}), analysis.ReadInside.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(readOutside, {}), analysis.ReadOutside.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(variablesDeclared, {}), analysis.VariablesDeclared.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(writtenInside, {}), analysis.WrittenInside.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(writtenOutside, {}), analysis.WrittenOutside.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(capturedInside, {}), analysis.CapturedInside.Select(Function(s) s.Name).ToArray()) + AssertEx.Equal(If(capturedOutside, {}), analysis.CapturedOutside.Select(Function(s) s.Name).ToArray()) End Sub End Class diff --git a/src/Compilers/VisualBasic/Test/Semantic/Semantics/ForeachTest.vb b/src/Compilers/VisualBasic/Test/Semantic/Semantics/ForeachTest.vb index af8b346a6f7e3..29a41679c1bea 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/Semantics/ForeachTest.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/Semantics/ForeachTest.vb @@ -1158,10 +1158,10 @@ End Class Dim loopSyntax = tree.GetRoot().DescendantNodes().OfType(Of ForEachStatementSyntax)().Single() Dim loopInfo = model.GetForEachStatementInfo(loopSyntax) - Assert.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerable__GetEnumerator), loopInfo.GetEnumeratorMethod) - Assert.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerator__Current), loopInfo.CurrentProperty) - Assert.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerator__MoveNext), loopInfo.MoveNextMethod) - Assert.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_IDisposable__Dispose), loopInfo.DisposeMethod) + AssertEx.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerable__GetEnumerator), loopInfo.GetEnumeratorMethod) + AssertEx.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerator__Current), loopInfo.CurrentProperty) + AssertEx.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerator__MoveNext), loopInfo.MoveNextMethod) + AssertEx.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_IDisposable__Dispose), loopInfo.DisposeMethod) ' The spec says that the element type is object. ' Therefore, we should infer object for "var". @@ -1198,10 +1198,10 @@ End Class Dim loopSyntax = tree.GetRoot().DescendantNodes().OfType(Of ForEachStatementSyntax)().Single() Dim loopInfo = model.GetForEachStatementInfo(loopSyntax) - Assert.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerable__GetEnumerator), loopInfo.GetEnumeratorMethod) - Assert.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerator__Current), loopInfo.CurrentProperty) - Assert.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerator__MoveNext), loopInfo.MoveNextMethod) - Assert.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_IDisposable__Dispose), loopInfo.DisposeMethod) + AssertEx.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerable__GetEnumerator), loopInfo.GetEnumeratorMethod) + AssertEx.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerator__Current), loopInfo.CurrentProperty) + AssertEx.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerator__MoveNext), loopInfo.MoveNextMethod) + AssertEx.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_IDisposable__Dispose), loopInfo.DisposeMethod) ' The spec says that the element type is object. ' Therefore, we should infer object for "var". @@ -1254,15 +1254,15 @@ End Module Dim loopInfo0 = model.GetForEachStatementInfo(loopSyntaxes(0)) Assert.Equal(comp.GetSpecialType(SpecialType.System_Array), loopInfo0.GetEnumeratorMethod.ContainingType) ' Unlike C#, the spec doesn't say that arrays use IEnumerable - Assert.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerator__Current), loopInfo0.CurrentProperty) - Assert.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerator__MoveNext), loopInfo0.MoveNextMethod) - Assert.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_IDisposable__Dispose), loopInfo0.DisposeMethod) + AssertEx.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerator__Current), loopInfo0.CurrentProperty) + AssertEx.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerator__MoveNext), loopInfo0.MoveNextMethod) + AssertEx.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_IDisposable__Dispose), loopInfo0.DisposeMethod) Assert.Equal(SpecialType.System_String, loopInfo0.ElementType.SpecialType) Assert.Equal(udc, loopInfo0.ElementConversion.Method) Assert.Equal(ConversionKind.NarrowingReference, loopInfo0.CurrentConversion.Kind) Dim loopInfo1 = model.GetForEachStatementInfo(loopSyntaxes(1)) - Assert.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerable__GetEnumerator), loopInfo1.GetEnumeratorMethod) ' No longer using System.Array method. + AssertEx.Equal(Of ISymbol)(comp.GetSpecialTypeMember(SpecialMember.System_Collections_IEnumerable__GetEnumerator), loopInfo1.GetEnumeratorMethod) ' No longer using System.Array method. Assert.Equal(loopInfo0.CurrentProperty, loopInfo1.CurrentProperty) Assert.Equal(loopInfo0.MoveNextMethod, loopInfo1.MoveNextMethod) Assert.Equal(loopInfo0.DisposeMethod, loopInfo1.DisposeMethod) diff --git a/src/Compilers/VisualBasic/Test/Semantic/Semantics/GotoTests.vb b/src/Compilers/VisualBasic/Test/Semantic/Semantics/GotoTests.vb index 1f7eb08ae6f06..446c2937ed103 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/Semantics/GotoTests.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/Semantics/GotoTests.vb @@ -207,7 +207,7 @@ End Module Assert.Equal("lab1", semanticSummary.Symbol.ToTestDisplayString()) Assert.Equal(SymbolKind.Label, semanticSummary.Symbol.Kind) - Assert.Equal(Of ISymbol)(declaredSymbol, semanticSummary.Symbol) + AssertEx.Equal(Of ISymbol)(declaredSymbol, semanticSummary.Symbol) End Sub @@ -238,7 +238,7 @@ End Module Assert.Equal(ConversionKind.Identity, semanticSummary0.ImplicitConversion.Kind) Assert.Equal("lab1", semanticSummary0.Symbol.ToTestDisplayString()) Assert.Equal(SymbolKind.Label, semanticSummary0.Symbol.Kind) - Assert.Equal(Of ISymbol)(declaredSymbol0, semanticSummary0.Symbol) + AssertEx.Equal(Of ISymbol)(declaredSymbol0, semanticSummary0.Symbol) Dim declaredSymbol1 = model.GetDeclaredSymbol(labelStatementSyntaxArray(1)) Dim semanticSummary1 = CompilationUtils.GetSemanticInfoSummary(Compilation, gotoSyntaxArray(1).Label) @@ -247,7 +247,7 @@ End Module Assert.Equal(ConversionKind.Identity, semanticSummary1.ImplicitConversion.Kind) Assert.Equal("lab1", semanticSummary1.Symbol.ToTestDisplayString()) Assert.Equal(SymbolKind.Label, semanticSummary1.Symbol.Kind) - Assert.Equal(Of ISymbol)(declaredSymbol0, semanticSummary1.Symbol) + AssertEx.Equal(Of ISymbol)(declaredSymbol0, semanticSummary1.Symbol) Assert.NotEqual(declaredSymbol0, declaredSymbol1) Assert.Equal(semanticSummary0.Symbol, semanticSummary1.Symbol) @@ -281,7 +281,7 @@ End Module Assert.Equal("0", semanticSummary.Symbol.ToTestDisplayString()) Assert.Equal(SymbolKind.Label, semanticSummary.Symbol.Kind) - Assert.Equal(Of ISymbol)(declaredSymbol, semanticSummary.Symbol) + AssertEx.Equal(Of ISymbol)(declaredSymbol, semanticSummary.Symbol) End Sub @@ -315,8 +315,8 @@ End Module Assert.Equal("0", semanticSummary.Symbol.ToTestDisplayString()) Assert.Equal(SymbolKind.Label, semanticSummary.Symbol.Kind) - Assert.NotEqual(Of ISymbol)(declaredSymbolOuter, semanticSummary.Symbol) - Assert.Equal(Of ISymbol)(declaredSymbolInner, semanticSummary.Symbol) + AssertEx.NotEqual(Of ISymbol)(declaredSymbolOuter, semanticSummary.Symbol) + AssertEx.Equal(Of ISymbol)(declaredSymbolInner, semanticSummary.Symbol) End Sub @@ -354,7 +354,7 @@ End Module Assert.Equal("1", semanticSummary.Symbol.ToTestDisplayString()) Assert.Equal(SymbolKind.Label, semanticSummary.Symbol.Kind) - Assert.Equal(Of ISymbol)(declaredSymbol, semanticSummary.Symbol) + AssertEx.Equal(Of ISymbol)(declaredSymbol, semanticSummary.Symbol) End Sub @@ -390,7 +390,7 @@ End Module Assert.Equal("1", semanticSummary.Symbol.ToTestDisplayString()) Assert.Equal(SymbolKind.Label, semanticSummary.Symbol.Kind) - Assert.Equal(Of ISymbol)(declaredSymbol, semanticSummary.Symbol) + AssertEx.Equal(Of ISymbol)(declaredSymbol, semanticSummary.Symbol) End Sub @@ -424,7 +424,7 @@ End Module Assert.Equal("lab1", semanticSummary.Symbol.ToTestDisplayString()) Assert.Equal(SymbolKind.Label, semanticSummary.Symbol.Kind) - Assert.Equal(Of ISymbol)(declaredSymbol, semanticSummary.Symbol) + AssertEx.Equal(Of ISymbol)(declaredSymbol, semanticSummary.Symbol) End Sub diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/AnonymousTypes/AnonymousTypesSemanticsTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/AnonymousTypes/AnonymousTypesSemanticsTests.vb index 7b65cbcd40626..e60294355455e 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/AnonymousTypes/AnonymousTypesSemanticsTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/AnonymousTypes/AnonymousTypesSemanticsTests.vb @@ -144,7 +144,7 @@ End Module ' AnonymousObjectCreationExpression in the new { } declaration. Dim symbol = model.GetDeclaredSymbol(anonObjectCreation) Assert.NotNull(symbol) - Assert.Equal(Of ISymbol)(localType, symbol) + AssertEx.Equal(Of ISymbol)(localType, symbol) Assert.Same(anonObjectCreation, symbol.DeclaringSyntaxReferences(0).GetSyntax()) ' Locations: Return the Span of that particular @@ -176,7 +176,7 @@ End Module ' SemanticModel.GetDeclaredSymbol: Return this symbol when applied to its new { } ' declaration's AnonymousObjectMemberDeclarator. Dim propSymbol = model.GetDeclaredSymbol(propertyInitializer) - Assert.Equal(Of ISymbol)(member, propSymbol) + AssertEx.Equal(Of ISymbol)(member, propSymbol) Assert.Same(propertyInitializer, propSymbol.DeclaringSyntaxReferences(0).GetSyntax()) ' Locations: Return the Span of that particular diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/BindingsTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/BindingsTests.vb index d4b3713952fd1..8c83380829477 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/BindingsTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/BindingsTests.vb @@ -489,7 +489,7 @@ BC30179: interface 'Q' and class 'Q' conflict in namespace 'Goo.Bar.N1.N2'. symbol = importsYellowSymInfo.Symbol Assert.NotNull(symbol) Assert.Equal(SymbolKind.NamedType, symbol.Kind) - Assert.Equal(Of ISymbol)(importsYellowSymInfo.Type, symbol) + AssertEx.Equal(Of ISymbol)(importsYellowSymInfo.Type, symbol) Assert.Equal("Goo.Bar.N1.N2.Yellow(Of System.Int32)", symbol.ToDisplayString(SymbolDisplayFormat.TestFormat)) ' Bind "N2.IAmbig" in "arg1 as N2.IAmbig". It is ambiguous. diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/SourceSymbolTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/SourceSymbolTests.vb index d2c3eafa1562f..d4b5daddb7953 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/SourceSymbolTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/SourceSymbolTests.vb @@ -678,8 +678,8 @@ End Namespace") ' NamespaceNames and TypeNames do not match SyntaxTrees order. ' This is expected. - Assert.Equal({"", "N3", "N0", "N", "", "N4", "N"}, comp2.Declarations.NamespaceNames.ToArray()) - Assert.Equal({"C3", "C0", "S", "C", "C4", "C"}, comp2.Declarations.TypeNames.ToArray()) + AssertEx.Equal({"", "N3", "N0", "N", "", "N4", "N"}, comp2.Declarations.NamespaceNames.ToArray()) + AssertEx.Equal({"C3", "C0", "S", "C", "C4", "C"}, comp2.Declarations.TypeNames.ToArray()) ' RemoveSyntaxTrees should preserve order of remaining trees. Dim comp3 = comp2.RemoveSyntaxTrees(source0) diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/TypedConstantTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/TypedConstantTests.vb index 13ba0563a98bc..1d3617bfd1da1 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/TypedConstantTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/TypedConstantTests.vb @@ -7,6 +7,7 @@ Imports System.Linq Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Symbols Imports Microsoft.CodeAnalysis.VisualBasic.Syntax +Imports Roslyn.Test.Utilities Imports Xunit Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Symbols @@ -37,7 +38,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Symbols Assert.Equal(common.Value, lang.Value) Assert.Equal(common.Kind, lang.Kind) - Assert.Equal(Of Object)(common.Type, lang.Type) + AssertEx.Equal(Of Object)(common.Type, lang.Type) Assert.Equal(common.Value, common2.Value) Assert.Equal(common.Kind, common2.Kind) @@ -50,7 +51,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Symbols Assert.Equal(commonArray.Values.Single(), langArray.Values.Single()) Assert.Equal(commonArray.Kind, langArray.Kind) - Assert.Equal(Of Object)(commonArray.Type, langArray.Type) + AssertEx.Equal(Of Object)(commonArray.Type, langArray.Type) Assert.Equal(commonArray.Values, commonArray2.Values) Assert.Equal(commonArray.Kind, commonArray2.Kind) diff --git a/src/Compilers/VisualBasic/Test/Syntax/Parser/XmlDocComments.vb b/src/Compilers/VisualBasic/Test/Syntax/Parser/XmlDocComments.vb index bb4ec5fc7cc39..71f2983de47ef 100644 --- a/src/Compilers/VisualBasic/Test/Syntax/Parser/XmlDocComments.vb +++ b/src/Compilers/VisualBasic/Test/Syntax/Parser/XmlDocComments.vb @@ -574,7 +574,7 @@ End Module Dim actual = documentationComment.ToFullString() - Assert.Equal(Of String)(expected, actual) + AssertEx.Equal(Of String)(expected, actual) End Sub @@ -594,7 +594,7 @@ End Module Dim actual = documentationComment.ToFullString() - Assert.Equal(Of String)(expected, actual) + AssertEx.Equal(Of String)(expected, actual) End Sub @@ -622,7 +622,7 @@ End Module Dim actual = documentationComment.ToFullString() - Assert.Equal(Of String)(expected, actual) + AssertEx.Equal(Of String)(expected, actual) End Sub @@ -665,7 +665,7 @@ End Module Dim actual = documentationComment.ToFullString() - Assert.Equal(Of String)(expected, actual) + AssertEx.Equal(Of String)(expected, actual) End Sub @@ -691,7 +691,7 @@ End Module Dim actual = documentationComment.ToFullString() - Assert.Equal(Of String)(expected, actual) + AssertEx.Equal(Of String)(expected, actual) End Sub @@ -718,7 +718,7 @@ End Module Dim actual = documentationComment.ToFullString() - Assert.Equal(Of String)(expected, actual) + AssertEx.Equal(Of String)(expected, actual) End Sub @@ -749,7 +749,7 @@ End Module Dim actual = documentationComment.ToFullString() - Assert.Equal(Of String)(expected, actual) + AssertEx.Equal(Of String)(expected, actual) End Sub @@ -774,7 +774,7 @@ End Module Dim actual = documentationComment.ToFullString() - Assert.Equal(Of String)(expected, actual) + AssertEx.Equal(Of String)(expected, actual) End Sub @@ -799,7 +799,7 @@ End Module Dim actual = documentationComment.ToFullString() - Assert.Equal(Of String)(expected, actual) + AssertEx.Equal(Of String)(expected, actual) End Sub End Class diff --git a/src/EditorFeatures/CSharpTest/EditorConfigSettings/Updater/SettingsUpdaterTests.cs b/src/EditorFeatures/CSharpTest/EditorConfigSettings/Updater/SettingsUpdaterTests.cs index fe9b9ffa0305d..a8c549930d700 100644 --- a/src/EditorFeatures/CSharpTest/EditorConfigSettings/Updater/SettingsUpdaterTests.cs +++ b/src/EditorFeatures/CSharpTest/EditorConfigSettings/Updater/SettingsUpdaterTests.cs @@ -333,7 +333,7 @@ public async Task TestAnalyzerSettingsUpdaterService() var analyzerSetting = new AnalyzerSetting(descriptor, ReportDiagnostic.Suppress, updater, Language.CSharp, new SettingLocation(EditorConfigSettings.LocationKind.VisualStudio, null)); analyzerSetting.ChangeSeverity(ReportDiagnostic.Error); var updates = await updater.GetChangedEditorConfigAsync(default); - var update = Assert.Single(updates); + var update = AssertEx.Single(updates); Assert.Equal($"[*.cs]\r\ndotnet_diagnostic.{id}.severity = error", update.NewText); } @@ -356,7 +356,7 @@ public async Task TestCodeStyleSettingUpdaterService() var setting = CodeStyleSetting.Create(CSharpCodeStyleOptions.AllowBlankLineAfterColonInConstructorInitializer, "description", options, updater); setting.ChangeSeverity(ReportDiagnostic.Error); var updates = await updater.GetChangedEditorConfigAsync(default); - var update = Assert.Single(updates); + var update = AssertEx.Single(updates); Assert.Equal("[*.cs]\r\ncsharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:error", update.NewText); value = "false:error"; @@ -369,7 +369,7 @@ public async Task TestCodeStyleSettingUpdaterService() setting.ChangeValue(0); updates = await updater.GetChangedEditorConfigAsync(default); - update = Assert.Single(updates); + update = AssertEx.Single(updates); Assert.Equal("[*.cs]\r\ncsharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:error", update.NewText); } @@ -389,7 +389,7 @@ public async Task TestWhitespaceSettingUpdaterService() var setting = Setting.Create(CSharpFormattingOptions2.NewLineForElse, "description", options, updater); setting.SetValue(false); var updates = await updater.GetChangedEditorConfigAsync(default); - var update = Assert.Single(updates); + var update = AssertEx.Single(updates); Assert.Equal("[*.cs]\r\ncsharp_new_line_before_else = false", update.NewText); } diff --git a/src/Features/Test/FindUsages/DefinitionItemFactoryTests.cs b/src/Features/Test/FindUsages/DefinitionItemFactoryTests.cs index e37bf86c3b4ad..8795dc2a44e8c 100644 --- a/src/Features/Test/FindUsages/DefinitionItemFactoryTests.cs +++ b/src/Features/Test/FindUsages/DefinitionItemFactoryTests.cs @@ -112,7 +112,7 @@ void verify(Action assert) { assert(); } - catch (AssertActualExpectedException e) + catch (Exception e) when (e is IAssertionException) { failures.Add(e); } diff --git a/src/LanguageServer/ProtocolUnitTests/CodeLens/CSharpCodeLensTests.cs b/src/LanguageServer/ProtocolUnitTests/CodeLens/CSharpCodeLensTests.cs index 853cd7ef7225e..37ff9c71e2789 100644 --- a/src/LanguageServer/ProtocolUnitTests/CodeLens/CSharpCodeLensTests.cs +++ b/src/LanguageServer/ProtocolUnitTests/CodeLens/CSharpCodeLensTests.cs @@ -418,7 +418,7 @@ void M(A a) } }); var actualCodeLenses = await GetCodeLensAsync(testLspServer); - Assert.Empty(actualCodeLenses); + AssertEx.Empty(actualCodeLenses); } [Theory, CombinatorialData] diff --git a/src/LanguageServer/ProtocolUnitTests/Diagnostics/AdditionalFileDiagnosticsTests.cs b/src/LanguageServer/ProtocolUnitTests/Diagnostics/AdditionalFileDiagnosticsTests.cs index be6f6aa97321f..79c732d12ec6e 100644 --- a/src/LanguageServer/ProtocolUnitTests/Diagnostics/AdditionalFileDiagnosticsTests.cs +++ b/src/LanguageServer/ProtocolUnitTests/Diagnostics/AdditionalFileDiagnosticsTests.cs @@ -63,10 +63,10 @@ public async Task TestWorkspaceDiagnosticsWithRemovedAdditionalFile(bool useVSDi var results = await RunGetWorkspacePullDiagnosticsAsync(testLspServer, useVSDiagnostics); Assert.Equal(3, results.Length); - Assert.Empty(results[0].Diagnostics); + AssertEx.Empty(results[0].Diagnostics); Assert.Equal(MockAdditionalFileDiagnosticAnalyzer.Id, results[1].Diagnostics.Single().Code); Assert.Equal(@"C:\Test.txt", results[1].Uri.LocalPath); - Assert.Empty(results[2].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); var initialSolution = testLspServer.GetCurrentSolution(); var newSolution = initialSolution.RemoveAdditionalDocument(initialSolution.Projects.Single().AdditionalDocumentIds.Single()); @@ -80,9 +80,9 @@ public async Task TestWorkspaceDiagnosticsWithRemovedAdditionalFile(bool useVSDi Assert.Null(results2[0].ResultId); // The other files should have new results since the solution changed. - Assert.Empty(results2[1].Diagnostics); + AssertEx.Empty(results2[1].Diagnostics); Assert.NotNull(results2[1].ResultId); - Assert.Empty(results2[2].Diagnostics); + AssertEx.Empty(results2[2].Diagnostics); Assert.NotNull(results2[2].ResultId); } @@ -115,7 +115,7 @@ public async Task TestWorkspaceDiagnosticsWithAdditionalFileInMultipleProjects(b // Asking again should give us back an unchanged diagnostic. var results2 = await RunGetWorkspacePullDiagnosticsAsync(testLspServer, useVSDiagnostics: true, previousResults: CreateDiagnosticParamsFromPreviousReports(results)); - Assert.Empty(results2); + AssertEx.Empty(results2); } protected override TestComposition Composition => base.Composition.AddParts(typeof(MockAdditionalFileDiagnosticAnalyzer)); diff --git a/src/LanguageServer/ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs b/src/LanguageServer/ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs index 4a075aba1f661..d2c3417f72be2 100644 --- a/src/LanguageServer/ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs +++ b/src/LanguageServer/ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs @@ -354,7 +354,7 @@ public async Task TestDocumentDiagnosticsRemovedAfterErrorIsFixed(bool useVSDiag await InsertTextAsync(testLspServer, document, buffer.CurrentSnapshot.Length, "}"); results = await RunGetDocumentPullDiagnosticsAsync(testLspServer, document.GetURI(), useVSDiagnostics, results.Single().ResultId); - Assert.Empty(results[0].Diagnostics); + AssertEx.Empty(results[0].Diagnostics); } [Theory, CombinatorialData] @@ -470,11 +470,11 @@ class B {"; testLspServer.TestWorkspace.SetDocumentContext(csproj1Document.Id); results = await RunGetDocumentPullDiagnosticsAsync(testLspServer, csproj1Document.GetURI(), useVSDiagnostics); Assert.Equal(2, results.Single().Diagnostics!.Length); - Assert.All(results.Single().Diagnostics, d => Assert.Equal("CS1513", d.Code)); + AssertEx.All(results.Single().Diagnostics, d => Assert.Equal("CS1513", d.Code)); if (useVSDiagnostics) { - Assert.All(results.Single().Diagnostics, d => Assert.Equal("CSProj1", ((VSDiagnostic)d).Projects.Single().ProjectName)); + AssertEx.All(results.Single().Diagnostics, d => Assert.Equal("CSProj1", ((VSDiagnostic)d).Projects.Single().ProjectName)); } } @@ -565,7 +565,7 @@ public class {|caret:|} { } var originalResultId = results.Single().ResultId; results = await RunGetDocumentPullDiagnosticsAsync(testLspServer, csproj1Document.GetURI(), useVSDiagnostics, originalResultId); Assert.Single(results); - Assert.Empty(results.Single().Diagnostics); + AssertEx.Empty(results.Single().Diagnostics); Assert.NotEqual(originalResultId, results.Single().ResultId); } @@ -687,7 +687,7 @@ public async Task TestDocumentDiagnosticsIncludesSourceGeneratorDiagnostics(bool var results = await RunGetDocumentPullDiagnosticsAsync( testLspServer, document.GetURI(), useVSDiagnostics); - var diagnostic = Assert.Single(results.Single().Diagnostics); + var diagnostic = AssertEx.Single(results.Single().Diagnostics); Assert.Equal(DiagnosticProducingGenerator.Descriptor.Id, diagnostic.Code); } @@ -751,7 +751,7 @@ class A var results = await RunGetDocumentPullDiagnosticsAsync( testLspServer, document.GetURI(), useVSDiagnostics); - Assert.All(results.Single().Diagnostics, d => Assert.False(d.Tags!.Contains(DiagnosticTag.Unnecessary))); + AssertEx.All(results.Single().Diagnostics, d => Assert.False(d.Tags!.Contains(DiagnosticTag.Unnecessary))); } [Theory, CombinatorialData] @@ -844,7 +844,7 @@ void M() var results = await RunGetDocumentPullDiagnosticsAsync( testLspServer, document.GetURI(), useVSDiagnostics); - Assert.Empty(results.Single().Diagnostics); + AssertEx.Empty(results.Single().Diagnostics); } [Theory, CombinatorialData] @@ -926,8 +926,8 @@ public async Task TestWorkspaceDiagnosticsForClosedFilesWithFSAOn(bool useVSDiag Assert.Equal(3, results.Length); Assert.Equal("CS1513", results[0].Diagnostics.Single().Code); - Assert.Empty(results[1].Diagnostics); - Assert.Empty(results[2].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/roslyn/issues/65967")] @@ -947,9 +947,9 @@ public async Task TestWorkspaceDiagnosticsForClosedFilesWithRunCodeAnalysisAndFS Assert.Equal(3, results.Length); Assert.Equal("CS1513", results[0].Diagnostics.Single().Code); // this should be considered a build-error, since it was produced by the last code-analysis run. - Assert.Contains(VSDiagnosticTags.BuildError, results[0].Diagnostics.Single().Tags); - Assert.Empty(results[1].Diagnostics); - Assert.Empty(results[2].Diagnostics); + Assert.Contains(VSDiagnosticTags.BuildError, results[0].Diagnostics.Single().Tags!); + AssertEx.Empty(results[1].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); // Now fix the compiler error, but don't re-execute code analysis. // Verify that we still get the workspace diagnostics from the prior snapshot on which code analysis was executed. @@ -962,7 +962,7 @@ public async Task TestWorkspaceDiagnosticsForClosedFilesWithRunCodeAnalysisAndFS Assert.Equal(results[0].Diagnostics, results2[0].Diagnostics); // this should be considered a build-error, since it was produced by the last code-analysis run. - Assert.Contains(VSDiagnosticTags.BuildError, results2[0].Diagnostics.Single().Tags); + Assert.Contains(VSDiagnosticTags.BuildError, results2[0].Diagnostics.Single().Tags!); Assert.Equal(results[1].Diagnostics, results2[1].Diagnostics); Assert.Equal(results[2].Diagnostics, results2[2].Diagnostics); @@ -972,9 +972,9 @@ public async Task TestWorkspaceDiagnosticsForClosedFilesWithRunCodeAnalysisAndFS var results3 = await RunGetWorkspacePullDiagnosticsAsync(testLspServer, useVSDiagnostics, previousResults: CreateDiagnosticParamsFromPreviousReports(results2)); Assert.Equal(results.Length, results3.Length); - Assert.Empty(results3[0].Diagnostics); - Assert.Empty(results3[1].Diagnostics); - Assert.Empty(results3[2].Diagnostics); + AssertEx.Empty(results3[0].Diagnostics); + AssertEx.Empty(results3[1].Diagnostics); + AssertEx.Empty(results3[2].Diagnostics); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/roslyn/issues/65967")] @@ -995,9 +995,9 @@ public async Task TestWorkspaceDiagnosticsForClosedFilesWithRunCodeAnalysisFSAOn Assert.Equal(3, results.Length); Assert.Equal("CS1513", results[0].Diagnostics.Single().Code); // this should *not* be considered a build-error, since it was produced by the live workspace results. - Assert.DoesNotContain(VSDiagnosticTags.BuildError, results[0].Diagnostics.Single().Tags); - Assert.Empty(results[1].Diagnostics); - Assert.Empty(results[2].Diagnostics); + Assert.DoesNotContain(VSDiagnosticTags.BuildError, results[0].Diagnostics.Single().Tags!); + AssertEx.Empty(results[1].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); // Now fix the compiler error, but don't rerun code analysis. // Verify that we get up-to-date workspace diagnostics, i.e. no compiler errors, from the current snapshot because FSA is enabled. @@ -1009,9 +1009,9 @@ public async Task TestWorkspaceDiagnosticsForClosedFilesWithRunCodeAnalysisFSAOn Assert.Equal(results.Length, results2.Length); Assert.Equal(results.Length, results2.Length); - Assert.Empty(results2[0].Diagnostics); - Assert.Empty(results2[1].Diagnostics); - Assert.Empty(results2[2].Diagnostics); + AssertEx.Empty(results2[0].Diagnostics); + AssertEx.Empty(results2[1].Diagnostics); + AssertEx.Empty(results2[2].Diagnostics); // Now rerun code analysis and verify we still get up-to-date workspace diagnostics. await testLspServer.RunCodeAnalysisAsync(projectId); @@ -1043,7 +1043,7 @@ public async Task SourceGeneratorFailures_FSA(bool useVSDiagnostics, bool mutati var results = await RunGetWorkspacePullDiagnosticsAsync(testLspServer, useVSDiagnostics); Assert.Equal(2, results.Length); - Assert.Empty(results[0].Diagnostics); + AssertEx.Empty(results[0].Diagnostics); Assert.True(results[1].Diagnostics.Single().Message.Contains("Source generator failed")); } @@ -1341,7 +1341,7 @@ public async Task TestWorkspaceDiagnosticsIncludesSourceGeneratorDiagnosticsClos var results = await RunGetWorkspacePullDiagnosticsAsync(testLspServer, useVSDiagnostics); Assert.Equal(DiagnosticProducingGenerator.Descriptor.Id, results[0].Diagnostics.Single().Code); - Assert.Empty(results[1].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); } [Theory, CombinatorialData] @@ -1407,9 +1407,9 @@ public async Task TestWorkspaceDiagnosticsForSourceGeneratedFiles(bool useVSDiag Assert.Equal(3, results.Length); // Since we sorted above by URI the first result is the project. - Assert.Empty(results[0].Diagnostics); + AssertEx.Empty(results[0].Diagnostics); Assert.Equal("CS1513", results[1].Diagnostics.Single().Code); - Assert.Empty(results[2].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); } [Theory, CombinatorialData] @@ -1425,8 +1425,8 @@ public async Task TestWorkspaceDiagnosticsForRemovedDocument(bool useVSDiagnosti Assert.Equal(3, results.Length); Assert.Equal("CS1513", results[0].Diagnostics.Single().Code); - Assert.Empty(results[1].Diagnostics); - Assert.Empty(results[2].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); testLspServer.TestWorkspace.OnDocumentRemoved(testLspServer.TestWorkspace.Documents.First().Id); @@ -1439,9 +1439,9 @@ public async Task TestWorkspaceDiagnosticsForRemovedDocument(bool useVSDiagnosti Assert.Null(results2[0].ResultId); // Second and third doc should be changed as the project has changed. - Assert.Empty(results2[1].Diagnostics); + AssertEx.Empty(results2[1].Diagnostics); Assert.NotEqual(results[1].ResultId, results2[1].ResultId); - Assert.Empty(results2[2].Diagnostics); + AssertEx.Empty(results2[2].Diagnostics); Assert.NotEqual(results[2].ResultId, results2[2].ResultId); } @@ -1458,8 +1458,8 @@ public async Task TestNoChangeIfWorkspaceDiagnosticsCalledTwice(bool useVSDiagno Assert.Equal(3, results.Length); Assert.Equal("CS1513", results[0].Diagnostics.Single().Code); - Assert.Empty(results[1].Diagnostics); - Assert.Empty(results[2].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); var results2 = await RunGetWorkspacePullDiagnosticsAsync(testLspServer, useVSDiagnostics, previousResults: CreateDiagnosticParamsFromPreviousReports(results)); @@ -1480,8 +1480,8 @@ public async Task TestWorkspaceDiagnosticsRemovedAfterErrorIsFixed(bool useVSDia Assert.Equal(3, results.Length); Assert.Equal("CS1513", results[0].Diagnostics.Single().Code); - Assert.Empty(results[1].Diagnostics); - Assert.Empty(results[2].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); var buffer = testLspServer.TestWorkspace.Documents.First().GetTextBuffer(); buffer.Insert(buffer.CurrentSnapshot.Length, "}"); @@ -1489,11 +1489,11 @@ public async Task TestWorkspaceDiagnosticsRemovedAfterErrorIsFixed(bool useVSDia var results2 = await RunGetWorkspacePullDiagnosticsAsync(testLspServer, useVSDiagnostics, previousResults: CreateDiagnosticParamsFromPreviousReports(results)); Assert.Equal(3, results2.Length); - Assert.Empty(results2[0].Diagnostics); + AssertEx.Empty(results2[0].Diagnostics); // Project has changed, so we re-computed diagnostics as changes in the first file // may have changed results in the second. - Assert.Empty(results2[1].Diagnostics); - Assert.Empty(results2[2].Diagnostics); + AssertEx.Empty(results2[1].Diagnostics); + AssertEx.Empty(results2[2].Diagnostics); Assert.NotEqual(results[0].ResultId, results2[0].ResultId); Assert.NotEqual(results[1].ResultId, results2[1].ResultId); @@ -1515,8 +1515,8 @@ public async Task TestWorkspaceDiagnosticsRemainAfterErrorIsNotFixed(bool useVSD Assert.Equal("CS1513", results[0].Diagnostics.Single().Code); Assert.Equal(new Position { Line = 0, Character = 9 }, results[0].Diagnostics.Single().Range.Start); - Assert.Empty(results[1].Diagnostics); - Assert.Empty(results[2].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); var buffer = testLspServer.TestWorkspace.Documents.First().GetTextBuffer(); buffer.Insert(0, " "); @@ -1534,9 +1534,9 @@ public async Task TestWorkspaceDiagnosticsRemainAfterErrorIsNotFixed(bool useVSD Assert.Equal("CS1513", results2[0].Diagnostics.Single().Code); Assert.Equal(new Position { Line = 0, Character = 10 }, results2[0].Diagnostics.Single().Range.Start); - Assert.Empty(results2[1].Diagnostics); + AssertEx.Empty(results2[1].Diagnostics); Assert.NotEqual(results[1].ResultId, results2[1].ResultId); - Assert.Empty(results2[2].Diagnostics); + AssertEx.Empty(results2[2].Diagnostics); Assert.NotEqual(results[2].ResultId, results2[2].ResultId); } @@ -1575,8 +1575,8 @@ class A {"; Assert.Equal(ProtocolConversions.CreateAbsoluteUri(@"C:\test1.cs"), results[0].TextDocument!.Uri); Assert.Equal("CS1513", results[0].Diagnostics.Single().Code); Assert.Equal(1, results[0].Diagnostics.Single().Range.Start.Line); - Assert.Empty(results[1].Diagnostics); - Assert.Empty(results[2].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); } [Theory, CombinatorialData] @@ -1628,11 +1628,11 @@ public class {|caret:|} { } Assert.Equal(4, results.Length); // Verify diagnostics for A.cs are updated as the type B now exists. - Assert.Empty(results[0].Diagnostics); + AssertEx.Empty(results[0].Diagnostics); Assert.NotEqual(previousResultIds[0].resultId, results[0].ResultId); // Verify diagnostics for B.cs are updated as the class definition is now correct. - Assert.Empty(results[2].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); Assert.NotEqual(previousResultIds[2].resultId, results[2].ResultId); } @@ -1683,12 +1683,12 @@ public class {|caret:|} var results = await RunGetWorkspacePullDiagnosticsAsync(testLspServer, useVSDiagnostics); AssertEx.NotNull(results); Assert.Equal(6, results.Length); - Assert.Empty(results[0].Diagnostics); - Assert.Empty(results[1].Diagnostics); - Assert.Empty(results[2].Diagnostics); - Assert.Empty(results[3].Diagnostics); + AssertEx.Empty(results[0].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); + AssertEx.Empty(results[3].Diagnostics); Assert.Equal("CS1001", results[4].Diagnostics.Single().Code); - Assert.Empty(results[5].Diagnostics); + AssertEx.Empty(results[5].Diagnostics); // Insert C into C.cs via the workspace. var caretLocation = testLspServer.GetLocations("caret").First().Range; @@ -1704,19 +1704,19 @@ public class {|caret:|} // Verify that new diagnostics are returned for all files (even though the diagnostics for the first two files are the same) // since we re-calculate when transitive project dependencies change. - Assert.Empty(results[0].Diagnostics); + AssertEx.Empty(results[0].Diagnostics); Assert.NotEqual(previousResultIds[0].resultId, results[0].ResultId); - Assert.Empty(results[1].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); Assert.NotEqual(previousResultIds[1].resultId, results[1].ResultId); - Assert.Empty(results[2].Diagnostics); + AssertEx.Empty(results[2].Diagnostics); Assert.NotEqual(previousResultIds[2].resultId, results[2].ResultId); - Assert.Empty(results[3].Diagnostics); + AssertEx.Empty(results[3].Diagnostics); Assert.NotEqual(previousResultIds[3].resultId, results[3].ResultId); - Assert.Empty(results[4].Diagnostics); + AssertEx.Empty(results[4].Diagnostics); Assert.NotEqual(previousResultIds[4].resultId, results[4].ResultId); - Assert.Empty(results[5].Diagnostics); + AssertEx.Empty(results[5].Diagnostics); Assert.NotEqual(previousResultIds[5].resultId, results[5].ResultId); } @@ -1753,9 +1753,9 @@ public class {|caret:|} { } AssertEx.NotNull(results); Assert.Equal(4, results.Length); Assert.Equal("CS0246", results[0].Diagnostics.Single().Code); - Assert.Empty(results[1].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); Assert.Equal("CS1001", results[2].Diagnostics.Single().Code); - Assert.Empty(results[3].Diagnostics); + AssertEx.Empty(results[3].Diagnostics); // Insert B into B.cs via the workspace. var caretLocation = testLspServer.GetLocations("caret").First().Range; @@ -1771,9 +1771,9 @@ public class {|caret:|} { } // Note: tehre will be no results for A.cs as it is unchanged and does not reference CSProj2. // Verify that the diagnostics result for B.cs reflects the change we made to it. - Assert.Empty(results[0].Diagnostics); + AssertEx.Empty(results[0].Diagnostics); Assert.NotEqual(previousResultIds[2].resultId, results[0].ResultId); - Assert.Empty(results[1].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); Assert.NotEqual(previousResultIds[3].resultId, results[1].ResultId); } @@ -2084,7 +2084,7 @@ public async Task TestWorkspaceDiagnosticsForClosedFilesSwitchFSAFromOnToOff(boo Assert.Equal(2, results.Length); Assert.Equal("CS1513", results[0].Diagnostics.Single().Code); - Assert.Empty(results[1].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); var options = testLspServer.TestWorkspace.ExportProvider.GetExportedValue(); options.SetGlobalOption(SolutionCrawlerOptionsStorage.BackgroundAnalysisScopeOption, LanguageNames.CSharp, BackgroundAnalysisScope.OpenFiles); @@ -2105,8 +2105,8 @@ public async Task TestWorkspaceDiagnosticsForClosedFilesSwitchFSAFromOnToOff(boo } else { - Assert.Empty(results[0].Diagnostics); - Assert.Empty(results[1].Diagnostics); + AssertEx.Empty(results[0].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); } } @@ -2130,7 +2130,7 @@ public async Task TestWorkspaceDiagnosticsForClosedFilesSwitchFSAFromOffToOn(boo Assert.Equal(2, results.Length); Assert.Equal("CS1513", results[0].Diagnostics.Single().Code); - Assert.Empty(results[1].Diagnostics); + AssertEx.Empty(results[1].Diagnostics); } #endregion diff --git a/src/LanguageServer/ProtocolUnitTests/Diagnostics/WorkspaceProjectDiagnosticsTests.cs b/src/LanguageServer/ProtocolUnitTests/Diagnostics/WorkspaceProjectDiagnosticsTests.cs index bf060ae5b2fc0..3e9c8413166d8 100644 --- a/src/LanguageServer/ProtocolUnitTests/Diagnostics/WorkspaceProjectDiagnosticsTests.cs +++ b/src/LanguageServer/ProtocolUnitTests/Diagnostics/WorkspaceProjectDiagnosticsTests.cs @@ -9,6 +9,7 @@ using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.SolutionCrawler; using Microsoft.CodeAnalysis.Test.Utilities; +using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; @@ -27,7 +28,7 @@ public async Task TestWorkspaceDiagnosticsReportsProjectDiagnostic(bool useVSDia var results = await RunGetWorkspacePullDiagnosticsAsync(testLspServer, useVSDiagnostics); Assert.Equal(2, results.Length); - Assert.Empty(results[0].Diagnostics); + AssertEx.Empty(results[0].Diagnostics); Assert.Equal(MockProjectDiagnosticAnalyzer.Id, results[1].Diagnostics.Single().Code); Assert.Equal(ProtocolConversions.CreateAbsoluteUri(testLspServer.GetCurrentSolution().Projects.First().FilePath!), results[1].Uri); @@ -44,7 +45,7 @@ public async Task TestWorkspaceDiagnosticsWithRemovedProject(bool useVSDiagnosti var results = await RunGetWorkspacePullDiagnosticsAsync(testLspServer, useVSDiagnostics); Assert.Equal(2, results.Length); - Assert.Empty(results[0].Diagnostics); + AssertEx.Empty(results[0].Diagnostics); Assert.Equal(MockProjectDiagnosticAnalyzer.Id, results[1].Diagnostics.Single().Code); Assert.Equal(ProtocolConversions.CreateAbsoluteUri(testLspServer.GetCurrentSolution().Projects.First().FilePath!), results[1].Uri); diff --git a/src/LanguageServer/ProtocolUnitTests/Metadata/LspMetadataAsSourceWorkspaceTests.cs b/src/LanguageServer/ProtocolUnitTests/Metadata/LspMetadataAsSourceWorkspaceTests.cs index be4d17c5e185e..36e37923ab780 100644 --- a/src/LanguageServer/ProtocolUnitTests/Metadata/LspMetadataAsSourceWorkspaceTests.cs +++ b/src/LanguageServer/ProtocolUnitTests/Metadata/LspMetadataAsSourceWorkspaceTests.cs @@ -114,6 +114,7 @@ public static void WriteLine(string value) {} var definitionFromMetadata = await testLspServer.ExecuteRequestAsync(LSP.Methods.TextDocumentDefinitionName, CreateTextDocumentPositionParams(locationOfStringKeyword), CancellationToken.None); + Assert.NotNull(definitionFromMetadata); Assert.NotEmpty(definitionFromMetadata); Assert.Contains("String.cs", definitionFromMetadata.Single().Uri.LocalPath); } diff --git a/src/LanguageServer/ProtocolUnitTests/SpellCheck/SpellCheckTests.cs b/src/LanguageServer/ProtocolUnitTests/SpellCheck/SpellCheckTests.cs index 463b5a8774043..4f882cdbe5239 100644 --- a/src/LanguageServer/ProtocolUnitTests/SpellCheck/SpellCheckTests.cs +++ b/src/LanguageServer/ProtocolUnitTests/SpellCheck/SpellCheckTests.cs @@ -349,7 +349,7 @@ public async Task TestWorkspaceResultsForClosedFiles(bool mutatingLspWorkspace) ResultId = "WorkspaceSpellCheckHandler:0", Ranges = GetRanges(testLspServer.TestWorkspace.Documents.First().AnnotatedSpans), }); - Assert.Empty(results[1].Ranges); + AssertEx.Empty(results[1].Ranges); } [Theory, CombinatorialData] @@ -422,7 +422,7 @@ public async Task TestWorkspaceResultsForRemovedDocument(bool mutatingLspWorkspa ResultId = "WorkspaceSpellCheckHandler:0", Ranges = GetRanges(testLspServer.TestWorkspace.Documents.First().AnnotatedSpans), }); - Assert.Empty(results[1].Ranges); + AssertEx.Empty(results[1].Ranges); testLspServer.TestWorkspace.OnDocumentRemoved(testLspServer.TestWorkspace.Documents.First().Id); @@ -434,7 +434,7 @@ public async Task TestWorkspaceResultsForRemovedDocument(bool mutatingLspWorkspa Assert.Null(results2[0].ResultId); // Second doc should be unchanged - Assert.Empty(results[1].Ranges); + AssertEx.Empty(results[1].Ranges); Assert.Equal(results[1].ResultId, results2[1].ResultId); } @@ -460,7 +460,7 @@ public async Task TestNoChangeIfWorkspaceResultsCalledTwice(bool mutatingLspWork ResultId = "WorkspaceSpellCheckHandler:0", Ranges = GetRanges(testLspServer.TestWorkspace.Documents.First().AnnotatedSpans), }); - Assert.Empty(results[1].Ranges); + AssertEx.Empty(results[1].Ranges); var results2 = await RunGetWorkspaceSpellCheckSpansAsync(testLspServer, previousResults: CreateParamsFromPreviousReports(results)); @@ -496,7 +496,7 @@ public async Task TestWorkspaceResultUpdatedAfterEdit(bool mutatingLspWorkspace) ResultId = "WorkspaceSpellCheckHandler:0", Ranges = GetRanges(testLspServer.TestWorkspace.Documents.First().AnnotatedSpans), }); - Assert.Empty(results[1].Ranges); + AssertEx.Empty(results[1].Ranges); var buffer = testLspServer.TestWorkspace.Documents.First().GetTextBuffer(); buffer.Insert(buffer.CurrentSnapshot.Length, "// comment"); @@ -549,7 +549,7 @@ public async Task TestStreamingWorkspaceResults(bool mutatingLspWorkspace) ResultId = "WorkspaceSpellCheckHandler:0", Ranges = GetRanges(testLspServer.TestWorkspace.Documents.First().AnnotatedSpans), }); - Assert.Empty(results[1].Ranges); + AssertEx.Empty(results[1].Ranges); results = await RunGetWorkspaceSpellCheckSpansAsync(testLspServer, CreateParamsFromPreviousReports(results), useProgress: true); diff --git a/src/LanguageServer/ProtocolUnitTests/Symbols/WorkspaceSymbolsTests.cs b/src/LanguageServer/ProtocolUnitTests/Symbols/WorkspaceSymbolsTests.cs index d5ab8a0cda616..3a90b5d341ab6 100644 --- a/src/LanguageServer/ProtocolUnitTests/Symbols/WorkspaceSymbolsTests.cs +++ b/src/LanguageServer/ProtocolUnitTests/Symbols/WorkspaceSymbolsTests.cs @@ -208,7 +208,7 @@ void M() await using var testLspServer = await CreateTestLspServerAsync(markup, mutatingLspWorkspace); var results = await RunGetWorkspaceSymbolsAsync(testLspServer, "NonExistingSymbol").ConfigureAwait(false); - Assert.Empty(results); + AssertEx.Empty(results); } [Theory, CombinatorialData] diff --git a/src/LanguageServer/ProtocolUnitTests/VSTypeScriptHandlerTests.cs b/src/LanguageServer/ProtocolUnitTests/VSTypeScriptHandlerTests.cs index 31c6ceb43706a..6093ca628acc8 100644 --- a/src/LanguageServer/ProtocolUnitTests/VSTypeScriptHandlerTests.cs +++ b/src/LanguageServer/ProtocolUnitTests/VSTypeScriptHandlerTests.cs @@ -69,7 +69,7 @@ public async Task TestRoslynTypeScriptHandlerInvoked() }; var response = await testLspServer.ExecuteRequestAsync(VSInternalMethods.DocumentPullDiagnosticName, documentPullRequest, CancellationToken.None); - Assert.Empty(response); + AssertEx.Empty(response); } [Fact, WorkItem("https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1901118")] diff --git a/src/Tools/TestDiscoveryWorker/Program.cs b/src/Tools/TestDiscoveryWorker/Program.cs index 882ab62b3db1c..5d28bb5103a54 100644 --- a/src/Tools/TestDiscoveryWorker/Program.cs +++ b/src/Tools/TestDiscoveryWorker/Program.cs @@ -65,7 +65,7 @@ await Console.Out.WriteLineAsync($"Discovering tests in {testDescriptor}...").ConfigureAwait(false); using var xunit = new XunitFrontController(AppDomainSupport.IfAvailable, assemblyFileName, shadowCopy: false); - var configuration = ConfigReader.Load(assemblyFileName); + var configuration = ConfigReader.Load(assemblyFileName, configFileName: null, warnings: null); var sink = new Sink(); xunit.Find(includeSourceInformation: false, messageSink: sink, diff --git a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/InputInProcess.cs b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/InputInProcess.cs index fd6044eae7b7a..61d002c295b67 100644 --- a/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/InputInProcess.cs +++ b/src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/InputInProcess.cs @@ -84,7 +84,7 @@ internal async Task SendToNavigateToAsync(InputKey[] keys, CancellationToken can var searchBox = Assert.IsAssignableFrom(Keyboard.FocusedElement); // Validate the focused control against the "old" search experience as well as the // all-in-one search experience. - Assert.Contains(searchBox.Name, ["PART_SearchBox", "SearchBoxControl"]); + Assert.Contains(searchBox.Name, (string[])["PART_SearchBox", "SearchBoxControl"]); // AbstractSendKeys runs synchronously, so switch to a background thread before the call await TaskScheduler.Default; diff --git a/src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs b/src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs index b044955cb63ff..818dfccd295a6 100644 --- a/src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs +++ b/src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs @@ -45,7 +45,7 @@ public void WhenAll_AllCompletedSuccessfully() var whenAll = SpecializedTasks.WhenAll([new ValueTask(0), new ValueTask(1)]); Debug.Assert(whenAll.IsCompleted); Assert.True(whenAll.IsCompletedSuccessfully); - Assert.Equal([0, 1], whenAll.Result); + Assert.Equal((int[])[0, 1], whenAll.Result); } [Fact] @@ -66,7 +66,7 @@ public void WhenAll_NotYetCompleted() completionSource.SetResult(0); Assert.True(whenAll.IsCompleted); Debug.Assert(whenAll.IsCompleted); - Assert.Equal([0], whenAll.Result); + Assert.Equal((int[])[0], whenAll.Result); } [Fact] From 96045bdabb4e81e508aa9217942c432b3ce002c7 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Thu, 12 Sep 2024 14:57:06 -0700 Subject: [PATCH 02/12] more --- .editorconfig | 9 ++++++ .vscode/tasks.json | 30 +++++++++---------- .../Semantics/BindingAsyncTasklikeTests.cs | 2 +- .../NamedPipeClientConnectionHostTests.cs | 4 +-- src/Compilers/Test/Core/Assert/AssertEx.cs | 11 ++++++- .../UtilityTest/SpecializedTasksTests.cs | 4 +-- 6 files changed, 38 insertions(+), 22 deletions(-) diff --git a/.editorconfig b/.editorconfig index 753499f5afaf4..a783fcb954f9f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -151,6 +151,15 @@ dotnet_public_api_analyzer.require_api_files = true # Workaround for https://github.com/dotnet/roslyn/issues/70570 dotnet_diagnostic.IDE0055.severity = warning +# Enable the xUnit analyzer rules +# https://github.com/dotnet/roslyn/issues/75093 +dotnet_diagnostic.xUnit1030.severity = none +dotnet_diagnostic.xUnit1031.severity = none +dotnet_diagnostic.xUnit2005.severity = none +dotnet_diagnostic.xUnit2020.severity = none +dotnet_diagnostic.xUnit2023.severity = none +dotnet_diagnostic.xUnit2029.severity = none + # CSharp code style settings: [*.cs] # Newline settings diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a16eb6aa6b04a..5ac5060625cf5 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -25,22 +25,6 @@ "problemMatcher": "$msCompile", "group": "build" }, - { - "label": "build with analyzers", - "command": "./build.sh", - "type": "shell", - "args": [ - "--runAnalyzers" - ], - "windows": { - "command": "${workspaceFolder}/build.cmd", - "args": [ - "-runAnalyzers" - ], - }, - "problemMatcher": "$msCompile", - "group": "build" - }, { "label": "build csc", "command": "dotnet", @@ -83,6 +67,20 @@ "problemMatcher": "$msCompile", "group": "build" }, + { + "label": "build Roslyn.sln with analyzers", + "command": "dotnet", + "type": "shell", + "args": [ + "build", + "-p:RunAnalyzersDuringBuild=true", + "-p:GenerateFullPaths=true", + "-tl:off", + "Roslyn.sln" + ], + "problemMatcher": "$msCompile", + "group": "build" + }, { "label": "build current project", "type": "shell", diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/BindingAsyncTasklikeTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/BindingAsyncTasklikeTests.cs index aed8b42cc7c7f..d34a087079884 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/BindingAsyncTasklikeTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/BindingAsyncTasklikeTests.cs @@ -197,7 +197,7 @@ namespace System.Runtime.CompilerServices { class AsyncMethodBuilderAttribute : } [Fact] - public bool TasklikeA3() => VerifyTaskOverloads("f(async () => 3)", + public void TasklikeA3() => VerifyTaskOverloads("f(async () => 3)", "f(Func> lambda)", null); diff --git a/src/Compilers/Server/VBCSCompilerTests/NamedPipeClientConnectionHostTests.cs b/src/Compilers/Server/VBCSCompilerTests/NamedPipeClientConnectionHostTests.cs index d4b99885bb927..119a879651fa0 100644 --- a/src/Compilers/Server/VBCSCompilerTests/NamedPipeClientConnectionHostTests.cs +++ b/src/Compilers/Server/VBCSCompilerTests/NamedPipeClientConnectionHostTests.cs @@ -57,13 +57,13 @@ public async Task CallAfterComplete() } [ConditionalFact(typeof(WindowsOrLinuxOnly), Reason = "https://github.com/dotnet/runtime/issues/40301")] - public void EndListenCancelsIncompleteTask() + public async Task EndListenCancelsIncompleteTask() { _host.BeginListening(); var task = _host.GetNextClientConnectionAsync(); _host.EndListening(); - Assert.ThrowsAsync(() => task); + await Assert.ThrowsAsync(() => task); } /// diff --git a/src/Compilers/Test/Core/Assert/AssertEx.cs b/src/Compilers/Test/Core/Assert/AssertEx.cs index 9e41149a8ee3e..cd543b346c307 100644 --- a/src/Compilers/Test/Core/Assert/AssertEx.cs +++ b/src/Compilers/Test/Core/Assert/AssertEx.cs @@ -161,6 +161,9 @@ public static void AreEqual(T expected, T actual, string message = null, IEqu } } + public static void Equal(ImmutableArray expected, IEnumerable actual) + => Equal(expected, actual, comparer: null, message: null); + public static void Equal(ImmutableArray expected, IEnumerable actual, IEqualityComparer comparer = null, string message = null) { if (actual == null || expected.IsDefault) @@ -173,6 +176,10 @@ public static void Equal(ImmutableArray expected, IEnumerable actual, I } } + + public static void Equal(IEnumerable expected, ImmutableArray actual) + => Equal(expected, actual, comparer: null, message: null, itemInspector: null); + public static void Equal(IEnumerable expected, ImmutableArray actual, IEqualityComparer comparer = null, string message = null, string itemSeparator = null) { if (expected == null || actual.IsDefault) @@ -185,6 +192,9 @@ public static void Equal(IEnumerable expected, ImmutableArray actual, I } } + public static void Equal(ImmutableArray expected, ImmutableArray actual) + => Equal(expected, actual, comparer: null, message: null, itemInspector: null); + public static void Equal(ImmutableArray expected, ImmutableArray actual, IEqualityComparer comparer = null, string message = null, string itemSeparator = null) { Equal(expected, (IEnumerable)actual, comparer, message, itemSeparator); @@ -865,7 +875,6 @@ public static void Empty(IEnumerable items, string message = "") } } - private sealed class LineComparer : IEqualityComparer { public static readonly LineComparer Instance = new LineComparer(); diff --git a/src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs b/src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs index 818dfccd295a6..e98e5be9c7c7c 100644 --- a/src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs +++ b/src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs @@ -49,12 +49,12 @@ public void WhenAll_AllCompletedSuccessfully() } [Fact] - public void WhenAll_CompletedButCanceled() + public async Task WhenAll_CompletedButCanceled() { var whenAll = SpecializedTasks.WhenAll([new ValueTask(Task.FromCanceled(new CancellationToken(true)))]); Assert.True(whenAll.IsCompleted); Assert.False(whenAll.IsCompletedSuccessfully); - Assert.ThrowsAsync(async () => await whenAll); + await Assert.ThrowsAsync(async () => await whenAll); } [Fact] From 9228c155df442be6b1a84bae9b2eeb3ef6296d53 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Thu, 12 Sep 2024 16:18:09 -0700 Subject: [PATCH 03/12] more --- src/Compilers/Test/Core/Assert/AssertEx.cs | 1 - .../CoreTest/SolutionTests/SolutionTests.cs | 20 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Compilers/Test/Core/Assert/AssertEx.cs b/src/Compilers/Test/Core/Assert/AssertEx.cs index cd543b346c307..c430a4e4cf281 100644 --- a/src/Compilers/Test/Core/Assert/AssertEx.cs +++ b/src/Compilers/Test/Core/Assert/AssertEx.cs @@ -176,7 +176,6 @@ public static void Equal(ImmutableArray expected, IEnumerable actual, I } } - public static void Equal(IEnumerable expected, ImmutableArray actual) => Equal(expected, actual, comparer: null, message: null, itemInspector: null); diff --git a/src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs b/src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs index d328c2be37edd..81169657802d4 100644 --- a/src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs +++ b/src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs @@ -1856,8 +1856,8 @@ public void AddProjectReferences() var e = OnceEnumerable(projectRef2, externalProjectRef); var solution3 = solution.AddProjectReferences(projectId, e); - AssertEx.Equal([projectRef2], solution3.GetProject(projectId)!.ProjectReferences); - AssertEx.Equal([projectRef2, externalProjectRef], solution3.GetProject(projectId)!.AllProjectReferences); + AssertEx.Equal((ProjectReference[])[projectRef2], solution3.GetProject(projectId)!.ProjectReferences); + AssertEx.Equal((ProjectReference[])[projectRef2, externalProjectRef], solution3.GetProject(projectId)!.AllProjectReferences); Assert.Throws("projectId", () => solution.AddProjectReferences(null!, [projectRef2])); Assert.Throws("projectReferences", () => solution.AddProjectReferences(projectId, null!)); @@ -1889,11 +1889,11 @@ public void RemoveProjectReference() // remove reference to a project that's not part of the solution: var solution2 = solution.RemoveProjectReference(projectId, externalProjectRef); - AssertEx.Equal([projectRef2], solution2.GetProject(projectId)!.AllProjectReferences); + AssertEx.Equal((ProjectReference[])[projectRef2], solution2.GetProject(projectId)!.AllProjectReferences); // remove reference to a project that's part of the solution: var solution3 = solution.RemoveProjectReference(projectId, projectRef2); - AssertEx.Equal([externalProjectRef], solution3.GetProject(projectId)!.AllProjectReferences); + AssertEx.Equal((ProjectReference[])[externalProjectRef], solution3.GetProject(projectId)!.AllProjectReferences); var solution4 = solution3.RemoveProjectReference(projectId, externalProjectRef); Assert.Empty(solution4.GetProject(projectId)!.AllProjectReferences); @@ -1976,7 +1976,7 @@ public void AddMetadataReferences() var metadataRef2 = new TestMetadataReference(); var solution3 = solution.AddMetadataReferences(projectId, OnceEnumerable(metadataRef1, metadataRef2)); - AssertEx.Equal([metadataRef1, metadataRef2], solution3.GetProject(projectId)!.MetadataReferences); + AssertEx.Equal((MetadataReference[])[metadataRef1, metadataRef2], solution3.GetProject(projectId)!.MetadataReferences); Assert.Throws("projectId", () => solution.AddMetadataReferences(null!, [metadataRef1])); Assert.Throws("metadataReferences", () => solution.AddMetadataReferences(projectId, null!)); @@ -1999,7 +1999,7 @@ public void RemoveMetadataReference() solution = solution.WithProjectMetadataReferences(projectId, [metadataRef1, metadataRef2]); var solution2 = solution.RemoveMetadataReference(projectId, metadataRef1); - AssertEx.Equal([metadataRef2], solution2.GetProject(projectId)!.MetadataReferences); + AssertEx.Equal((MetadataReference[])[metadataRef2], solution2.GetProject(projectId)!.MetadataReferences); var solution3 = solution2.RemoveMetadataReference(projectId, metadataRef2); Assert.Empty(solution3.GetProject(projectId)!.MetadataReferences); @@ -2046,7 +2046,7 @@ public void AddAnalyzerReferences_Project() var analyzerRef2 = new TestAnalyzerReference(); var solution3 = solution.AddAnalyzerReferences(projectId, OnceEnumerable(analyzerRef1, analyzerRef2)); - AssertEx.Equal([analyzerRef1, analyzerRef2], solution3.GetProject(projectId)!.AnalyzerReferences); + AssertEx.Equal((AnalyzerReference[])[analyzerRef1, analyzerRef2], solution3.GetProject(projectId)!.AnalyzerReferences); var solution4 = solution3.AddAnalyzerReferences(projectId, []); @@ -2072,7 +2072,7 @@ public void RemoveAnalyzerReference_Project() solution = solution.WithProjectAnalyzerReferences(projectId, [analyzerRef1, analyzerRef2]); var solution2 = solution.RemoveAnalyzerReference(projectId, analyzerRef1); - AssertEx.Equal([analyzerRef2], solution2.GetProject(projectId)!.AnalyzerReferences); + AssertEx.Equal((AnalyzerReference[])[analyzerRef2], solution2.GetProject(projectId)!.AnalyzerReferences); var solution3 = solution2.RemoveAnalyzerReference(projectId, analyzerRef2); Assert.Empty(solution3.GetProject(projectId)!.AnalyzerReferences); @@ -2114,7 +2114,7 @@ public void AddAnalyzerReferences() var analyzerRef2 = new TestAnalyzerReference(); var solution3 = solution.AddAnalyzerReferences(OnceEnumerable(analyzerRef1, analyzerRef2)); - AssertEx.Equal([analyzerRef1, analyzerRef2], solution3.AnalyzerReferences); + AssertEx.Equal((AnalyzerReference[])[analyzerRef1, analyzerRef2], solution3.AnalyzerReferences); var solution4 = solution3.AddAnalyzerReferences([]); @@ -2138,7 +2138,7 @@ public void RemoveAnalyzerReference() solution = solution.WithAnalyzerReferences([analyzerRef1, analyzerRef2]); var solution2 = solution.RemoveAnalyzerReference(analyzerRef1); - AssertEx.Equal([analyzerRef2], solution2.AnalyzerReferences); + AssertEx.Equal((AnalyzerReference[])[analyzerRef2], solution2.AnalyzerReferences); var solution3 = solution2.RemoveAnalyzerReference(analyzerRef2); Assert.Empty(solution3.AnalyzerReferences); From 02908cdf3660598b1fb0772f407a5766f2d37471 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Thu, 12 Sep 2024 20:23:53 -0700 Subject: [PATCH 04/12] more --- .editorconfig | 3 ++- .../CSharpTest/Debugging/ProximityExpressionsGetterTests.cs | 2 +- .../AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index a783fcb954f9f..0b059a78dc0e9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -153,6 +153,7 @@ dotnet_diagnostic.IDE0055.severity = warning # Enable the xUnit analyzer rules # https://github.com/dotnet/roslyn/issues/75093 +dotnet_diagnostic.xUnit1012.severity = none dotnet_diagnostic.xUnit1030.severity = none dotnet_diagnostic.xUnit1031.severity = none dotnet_diagnostic.xUnit2005.severity = none @@ -309,4 +310,4 @@ dotnet_diagnostic.RS0057.severity = error dotnet_diagnostic.RS0058.severity = error dotnet_diagnostic.RS0059.severity = error dotnet_diagnostic.RS0060.severity = error -dotnet_diagnostic.RS0061.severity = error \ No newline at end of file +dotnet_diagnostic.RS0061.severity = error diff --git a/src/EditorFeatures/CSharpTest/Debugging/ProximityExpressionsGetterTests.cs b/src/EditorFeatures/CSharpTest/Debugging/ProximityExpressionsGetterTests.cs index 8ca02f14acabd..fc906ca80093e 100644 --- a/src/EditorFeatures/CSharpTest/Debugging/ProximityExpressionsGetterTests.cs +++ b/src/EditorFeatures/CSharpTest/Debugging/ProximityExpressionsGetterTests.cs @@ -61,7 +61,7 @@ static void Main(string[] args) }"); var terms = CSharpProximityExpressionsService.GetProximityExpressions(tree, 245, cancellationToken: default); Assert.NotNull(terms); - AssertEx.Equal(["yy", "xx"], terms); + AssertEx.Equal((string[])["yy", "xx"], terms); } private static async Task TestProximityExpressionGetterAsync( diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs index 13a4e5a410894..1725095e279cd 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs @@ -115,7 +115,7 @@ protected static async Task> TestAddDocument( Assert.NotNull(addedDocument); - AssertEx.Equal(expectedFolders, addedDocument.Folders); + AssertEx.Equal(expectedFolders, addedDocument.Folders.AsEnumerable()); Assert.Equal(expectedDocumentName, addedDocument.Name); var actual = (await addedDocument.GetTextAsync()).ToString(); Assert.Equal(expected, actual); From e1adb8b594c8e59142f99c4f149cd61f8676e65c Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Fri, 13 Sep 2024 08:47:21 -0700 Subject: [PATCH 05/12] more --- .../VBCSCompilerTests/NamedPipeClientConnectionHostTests.cs | 2 +- src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Compilers/Server/VBCSCompilerTests/NamedPipeClientConnectionHostTests.cs b/src/Compilers/Server/VBCSCompilerTests/NamedPipeClientConnectionHostTests.cs index 119a879651fa0..21709cdcc467a 100644 --- a/src/Compilers/Server/VBCSCompilerTests/NamedPipeClientConnectionHostTests.cs +++ b/src/Compilers/Server/VBCSCompilerTests/NamedPipeClientConnectionHostTests.cs @@ -63,7 +63,7 @@ public async Task EndListenCancelsIncompleteTask() var task = _host.GetNextClientConnectionAsync(); _host.EndListening(); - await Assert.ThrowsAsync(() => task); + await Assert.ThrowsAsync(async () => await task); } /// diff --git a/src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs b/src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs index e98e5be9c7c7c..6faf673d2fc88 100644 --- a/src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs +++ b/src/Workspaces/CoreTest/UtilityTest/SpecializedTasksTests.cs @@ -54,7 +54,7 @@ public async Task WhenAll_CompletedButCanceled() var whenAll = SpecializedTasks.WhenAll([new ValueTask(Task.FromCanceled(new CancellationToken(true)))]); Assert.True(whenAll.IsCompleted); Assert.False(whenAll.IsCompletedSuccessfully); - await Assert.ThrowsAsync(async () => await whenAll); + await Assert.ThrowsAsync(async () => await whenAll); } [Fact] From db8f936596951514de49fa3d2b426ea9197839e1 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Tue, 17 Sep 2024 10:06:56 -0700 Subject: [PATCH 06/12] see if this fixes the tests --- eng/Directory.Packages.props | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eng/Directory.Packages.props b/eng/Directory.Packages.props index ca7bce510510f..a3e16de05ae9e 100644 --- a/eng/Directory.Packages.props +++ b/eng/Directory.Packages.props @@ -12,7 +12,7 @@ 9.0.0-rc.2.24462.10 6.0.0-rtm.21518.12 7.0.0-alpha.1.22060.1 - 17.10.0 + <_MicrosoftTestPlatformVersion>17.5.0 - - + + 8.0.0 8.0.0 - <_xunitVersion>2.9.0 + <_xunitVersion>2.6.6 2.1.0 17.10.2079 @@ -282,7 +282,7 @@ - + From f2af9e981e645e3c839908f1b43850cd0ee98f2d Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Wed, 18 Sep 2024 08:05:14 -0700 Subject: [PATCH 08/12] fix overload --- .../Portable/SymbolDisplay/SymbolDisplay.cs | 1 - .../Semantic/Semantics/DelegateTypeTests.cs | 52 +++++++++---------- src/Compilers/Test/Core/Assert/AssertEx.cs | 3 ++ .../LspFileChangeWatcherTests.cs | 7 +++ 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplay.cs b/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplay.cs index 8f567a2721ebf..dddb063e87bad 100644 --- a/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplay.cs +++ b/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplay.cs @@ -281,7 +281,6 @@ private static ArrayBuilder PopulateDisplayParts( symbol.Accept(visitor); visitor.Free(); } - return builder; } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs index f75885a849cb9..a1602cf79cb41 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs @@ -1384,7 +1384,7 @@ static class B // https://github.com/dotnet/roslyn/issues/52870: GetSymbolInfo() should return resolved method from method group. Assert.Null(symbolInfo.Symbol); - Assert.Equal((string[])["void System.Object.F(System.Object y)", "void System.Object.F(T y)"], + AssertEx.Equal(["void System.Object.F(System.Object y)", "void System.Object.F(T y)"], model.GetMemberGroup(expr).ToTestDisplayStrings()); } @@ -1427,7 +1427,7 @@ static class B // https://github.com/dotnet/roslyn/issues/52870: GetSymbolInfo() should return resolved method from method group. Assert.Null(symbolInfo.Symbol); - Assert.Equal((string[])["void System.Object.F()", "void System.Object.F()"], + AssertEx.Equal(["void System.Object.F()", "void System.Object.F()"], model.GetMemberGroup(expr).ToTestDisplayStrings()); } @@ -2090,7 +2090,7 @@ public static void M(this C c, object o) Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2155,7 +2155,7 @@ public static void M(this C c, object o) { } // ignored Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal((string[])["void C.M()", "void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()", "void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2218,7 +2218,7 @@ public static void M(this C c, object o) { } // ignored Assert.True(typeInfo.ConvertedType!.IsErrorType()); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal((string[])["void C.M()", "void C.M(System.Object o)", "void C.M(System.Object o)"], + AssertEx.Equal(["void C.M()", "void C.M(System.Object o)", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } @@ -2276,7 +2276,7 @@ public static void M(this C c, object o) { } // ignored Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2325,7 +2325,7 @@ public static void M(this C c) Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2365,7 +2365,7 @@ public static void M(this C c) Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); // https://github.com/dotnet/roslyn/issues/52870: GetSymbolInfo() should return resolved method from method group. Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2408,7 +2408,7 @@ public static void M(this C c) Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); // https://github.com/dotnet/roslyn/issues/52870: GetSymbolInfo() should return resolved method from method group. Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2459,7 +2459,7 @@ public static void M(this C c) { } Assert.Null(typeInfo.Type); Assert.True(typeInfo.ConvertedType!.IsErrorType()); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal((string[])["void C.M(C c)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M(C c)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2500,7 +2500,7 @@ public static void M(this C c) Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2548,7 +2548,7 @@ public static class E2 Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2600,7 +2600,7 @@ public static class E2 Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2646,7 +2646,7 @@ public static void M(this C c) Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2694,7 +2694,7 @@ public static void M(this C c) Assert.Null(typeInfo.Type); Assert.Equal("System.Action", typeInfo.ConvertedType!.ToTestDisplayString()); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2741,7 +2741,7 @@ public static class E Assert.Null(typeInfo.Type); Assert.True(typeInfo.ConvertedType!.IsErrorType()); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal((string[])["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()", "void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2785,7 +2785,7 @@ public static class DExt var memberAccess = GetSyntax(tree, "c.M"); // https://github.com/dotnet/roslyn/issues/52870: GetSymbolInfo() should return resolved method from method group. Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal((string[])["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Fact, WorkItem("https://github.com/dotnet/csharplang/issues/7364")] @@ -2835,7 +2835,7 @@ public static void M(this T t) var model = comp.GetSemanticModel(tree); var memberAccess = GetSyntax(tree, "new object().M"); Assert.Equal("void System.Object.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void System.Object.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void System.Object.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69222")] @@ -2865,7 +2865,7 @@ public static void M(this C t) Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void C.M()"], + AssertEx.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } @@ -2894,7 +2894,7 @@ public static void M(this C c) { } var model = comp.GetSemanticModel(tree); var memberAccess = GetSyntax(tree, "new C().M"); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69222")] @@ -2923,7 +2923,7 @@ public void M(object o) where T : class { } var memberAccess = GetSyntax(tree, "new C().M"); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void C.M()", "void C.M(System.Object o)"], + AssertEx.Equal(["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } @@ -2954,7 +2954,7 @@ public void M(object o) where T : class { } var memberAccess = GetSyntax(tree, "new C().M"); Assert.Null(model.GetSymbolInfo(memberAccess).Symbol); - Assert.Equal((string[])["void C.M()", "void C.M(System.Object o)"], + AssertEx.Equal(["void C.M()", "void C.M(System.Object o)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } @@ -2986,7 +2986,7 @@ public void M() where T : class var model = comp.GetSemanticModel(tree); var memberAccess = GetSyntax(tree, "new C().M"); Assert.Equal("void C.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void C.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69222")] @@ -3017,7 +3017,7 @@ public static void M(this T t, object ignored) where T : struct { } var model = comp.GetSemanticModel(tree); var memberAccess = GetSyntax(tree, "new object().M"); Assert.Equal("void System.Object.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void System.Object.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); + AssertEx.Equal(["void System.Object.M()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69222")] @@ -3049,7 +3049,7 @@ public static void M(this T t, object ignored) where T : struct { } var memberAccess = GetSyntax(tree, "new object().M"); Assert.Equal("void System.Object.M()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void System.Object.M()", "void System.Object.M(System.Object ignored)"], + AssertEx.Equal(["void System.Object.M()", "void System.Object.M(System.Object ignored)"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } @@ -3084,7 +3084,7 @@ static class A var memberAccess = GetSyntax(tree, "new object().F"); Assert.Equal("void System.Object.F()", model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString()); - Assert.Equal((string[])["void System.Object.F()", "void System.Object.F()"], + AssertEx.Equal(["void System.Object.F()", "void System.Object.F()"], model.GetMemberGroup(memberAccess).ToTestDisplayStrings()); } diff --git a/src/Compilers/Test/Core/Assert/AssertEx.cs b/src/Compilers/Test/Core/Assert/AssertEx.cs index c430a4e4cf281..49a41a88e565e 100644 --- a/src/Compilers/Test/Core/Assert/AssertEx.cs +++ b/src/Compilers/Test/Core/Assert/AssertEx.cs @@ -161,6 +161,9 @@ public static void AreEqual(T expected, T actual, string message = null, IEqu } } + public static void Equal(ReadOnlySpan expected, T[] actual) => + Equal(expected.ToArray(), actual); + public static void Equal(ImmutableArray expected, IEnumerable actual) => Equal(expected, actual, comparer: null, message: null); diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs index 41fe21c197552..c9569a9b3beac 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs @@ -47,6 +47,13 @@ public async Task LspFileWatcherSupportedWithClientSupport() [Fact] public async Task CreatingDirectoryWatchRequestsDirectoryWatch() { + bool b = true; + while (b) + { + System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1)); + Console.WriteLine($"here: {System.Diagnostics.Process.GetCurrentProcess().Id}"); + } + AsynchronousOperationListenerProvider.Enable(enable: true); await using var testLspServer = await TestLspServer.CreateAsync(_clientCapabilitiesWithFileWatcherSupport, TestOutputLogger); From a9c728a653cd32d00a73a800ebb752c5540a47e2 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Wed, 18 Sep 2024 08:11:10 -0700 Subject: [PATCH 09/12] fixup for new xunit version --- src/Tools/TestDiscoveryWorker/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tools/TestDiscoveryWorker/Program.cs b/src/Tools/TestDiscoveryWorker/Program.cs index 5d28bb5103a54..882ab62b3db1c 100644 --- a/src/Tools/TestDiscoveryWorker/Program.cs +++ b/src/Tools/TestDiscoveryWorker/Program.cs @@ -65,7 +65,7 @@ await Console.Out.WriteLineAsync($"Discovering tests in {testDescriptor}...").ConfigureAwait(false); using var xunit = new XunitFrontController(AppDomainSupport.IfAvailable, assemblyFileName, shadowCopy: false); - var configuration = ConfigReader.Load(assemblyFileName, configFileName: null, warnings: null); + var configuration = ConfigReader.Load(assemblyFileName); var sink = new Sink(); xunit.Find(includeSourceInformation: false, messageSink: sink, From e45edb9941610af06d72d5d1b7e1d1903a24213c Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Wed, 18 Sep 2024 11:28:42 -0700 Subject: [PATCH 10/12] fix --- .../LspFileChangeWatcherTests.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs index c9569a9b3beac..41fe21c197552 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs @@ -47,13 +47,6 @@ public async Task LspFileWatcherSupportedWithClientSupport() [Fact] public async Task CreatingDirectoryWatchRequestsDirectoryWatch() { - bool b = true; - while (b) - { - System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1)); - Console.WriteLine($"here: {System.Diagnostics.Process.GetCurrentProcess().Id}"); - } - AsynchronousOperationListenerProvider.Enable(enable: true); await using var testLspServer = await TestLspServer.CreateAsync(_clientCapabilitiesWithFileWatcherSupport, TestOutputLogger); From 8d9ee0b92c387c3c617d8920e2f8b752c12199c7 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Wed, 25 Sep 2024 15:37:12 -0700 Subject: [PATCH 11/12] more --- .editorconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 0b059a78dc0e9..734314d6db6d7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -151,7 +151,10 @@ dotnet_public_api_analyzer.require_api_files = true # Workaround for https://github.com/dotnet/roslyn/issues/70570 dotnet_diagnostic.IDE0055.severity = warning -# Enable the xUnit analyzer rules +# These xUnit analyzers were disabled temporarily to let us move to the +# new xUnit and get past several component governance issues. The +# following issue tracks enabling them +# # https://github.com/dotnet/roslyn/issues/75093 dotnet_diagnostic.xUnit1012.severity = none dotnet_diagnostic.xUnit1030.severity = none From 0d749b987390339059284bc3de174ffc3cfd662f Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Thu, 26 Sep 2024 11:38:31 -0700 Subject: [PATCH 12/12] Fix --- .../ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LanguageServer/ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs b/src/LanguageServer/ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs index d2c3417f72be2..34f524982c811 100644 --- a/src/LanguageServer/ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs +++ b/src/LanguageServer/ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs @@ -1188,7 +1188,7 @@ public async Task EditAndContinue_NonHostWorkspace(bool mutatingLspWorkspace) encSessionState.IsSessionActive = true; var results = await RunGetDocumentPullDiagnosticsAsync(testLspServer, document.GetURI(), useVSDiagnostics: false, category: PullDiagnosticCategories.EditAndContinue); - Assert.Empty(results.Single().Diagnostics); + AssertEx.Empty(results.Single().Diagnostics); } [Theory, CombinatorialData]