提交 b0615aef 编写于 作者: G Gen Lu

Fix test failures

上级 3c3a8a1f
......@@ -205,31 +205,31 @@ public void M(int x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task UsingAliasInDeclaration_PrimitiveType(ReferenceType refType)
{
var file1 = $@"
var file1 = @"
using System;
using MyInt = System.Int32;
namespace Foo
{{
{
public static class ExtensionClass
{{
{
public static bool ExtentionMethod(this MyInt x)
=> true;
}}
}}";
var file2 = $@"
}
}";
var file2 = @"
using System;
namespace Baz
{{
{
public class Bat
{{
{
public void M(int x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemExistsAsync(
......@@ -243,31 +243,31 @@ public void M(int x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task UsingAliasInDeclaration_RegularType(ReferenceType refType)
{
var file1 = $@"
var file1 = @"
using System;
using MyAlias = System.Exception;
namespace Foo
{{
{
public static class ExtensionClass
{{
{
public static bool ExtentionMethod(this MyAlias x)
=> true;
}}
}}";
var file2 = $@"
}
}";
var file2 = @"
using System;
namespace Baz
{{
{
public class Bat
{{
{
public void M(Exception x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemExistsAsync(
......@@ -281,31 +281,31 @@ public void M(Exception x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task UsingAliasInDeclaration_GenericType(ReferenceType refType)
{
var file1 = $@"
var file1 = @"
using System;
using MyAlias = System.Collections.Generic.List<int>;
namespace Foo
{{
{
public static class ExtensionClass
{{
{
public static bool ExtentionMethod(this MyAlias x)
=> true;
}}
}}";
var file2 = $@"
}
}";
var file2 = @"
using System;
namespace Baz
{{
{
public class Bat
{{
{
public void M(System.Collections.Generic.List<int> x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemExistsAsync(
......@@ -319,30 +319,30 @@ public void M(System.Collections.Generic.List<int> x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task UsingAliasInDeclaration_RegularTypeWithSameSimpleName(ReferenceType refType)
{
var file1 = $@"
var file1 = @"
using DataTime = System.Exception;
namespace Foo
{{
{
public static class ExtensionClass
{{
{
public static bool ExtentionMethod(this System.DateTime x)
=> true;
}}
}}";
var file2 = $@"
}
}";
var file2 = @"
using System;
namespace Baz
{{
{
public class Bat
{{
{
public void M(DateTime x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemExistsAsync(
......@@ -356,31 +356,31 @@ public void M(DateTime x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task UsingAliasInDeclaration_Namespace(ReferenceType refType)
{
var file1 = $@"
var file1 = @"
using System;
using GenericCollection = System.Collections.Generic;
namespace Foo
{{
{
public static class ExtensionClass
{{
{
public static bool ExtentionMethod<T>(this GenericCollection.List<T> x)
=> true;
}}
}}";
var file2 = $@"
}
}";
var file2 = @"
using System;
namespace Baz
{{
{
public class Bat
{{
{
public void M(System.Collections.Generic.List<int> x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemExistsAsync(
......@@ -395,31 +395,31 @@ public void M(System.Collections.Generic.List<int> x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task UsingAliasInUsage(ReferenceType refType)
{
var file1 = $@"
var file1 = @"
using System;
namespace Foo
{{
{
public static class ExtensionClass
{{
{
public static bool ExtentionMethod(this int x)
=> true;
}}
}}";
var file2 = $@"
}
}";
var file2 = @"
using System;
using MyInt = System.Int32;
namespace Baz
{{
{
public class Bat
{{
{
public void M(MyInt x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemExistsAsync(
......@@ -446,19 +446,19 @@ public static bool ExtentionMethod(this MyType t)
=> true;
}}
}}";
var file2 = $@"
var file2 = @"
using System;
namespace Baz
{{
{
public class Bat
{{
{
public void M(MyType x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemExistsAsync(
markup,
......@@ -484,19 +484,19 @@ public static bool ExtentionMethod(this object t)
=> true;
}}
}}";
var file2 = $@"
var file2 = @"
using System;
namespace Baz
{{
{
public class Bat
{{
{
public void M(MyType x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemExistsAsync(
markup,
......@@ -571,19 +571,19 @@ public static bool ExtentionMethod(this MyBase t)
=> true;
}}
}}";
var file2 = $@"
var file2 = @"
using System;
namespace Baz
{{
{
public class Bat
{{
{
public void M(MyType x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemExistsAsync(
markup,
......@@ -604,18 +604,18 @@ public void M(MyType x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task BoundedGenericType(string type, ReferenceType refType)
{
var file1 = $@"
var file1 = @"
using System;
using System.Collections.Generic;
namespace Foo
{{
{
public static class ExtensionClass
{{
{
public static bool ExtentionMethod(this IEnumerable<string> t)
=> true;
}}
}}";
}
}";
var file2 = $@"
using System;
using System.Collections.Generic;
......@@ -650,17 +650,17 @@ public void M({type} x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task MatchingTypeParameter(string type, ReferenceType refType)
{
var file1 = $@"
var file1 = @"
using System;
namespace Foo
{{
{
public static class ExtensionClass
{{
{
public static bool ExtentionMethod<T>(this T t)
=> true;
}}
}}";
}
}";
var file2 = $@"
using System;
using System.Collections.Generic;
......@@ -691,30 +691,30 @@ public void M({type} x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task TestInternalExtensionMethods_NoIVT_InReference(ReferenceType refType)
{
var file1 = $@"
var file1 = @"
using System;
namespace Foo
{{
{
internal static class ExtensionClass
{{
{
public static bool ExtentionMethod(this int x)
=> true;
}}
}}";
var file2 = $@"
}
}";
var file2 = @"
using System;
namespace Baz
{{
{
public class Bat
{{
{
public void M(int x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemIsAbsentAsync(
......@@ -728,39 +728,39 @@ public void M(int x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task TestConflictingInternalExtensionMethods_NoIVT_InReference(ReferenceType refType)
{
var file1 = $@"
var file1 = @"
using System;
namespace Foo
{{
{
internal static class ExtensionClass
{{
{
public static bool ExtentionMethod(this int x)
=> true;
}}
}}";
var file2 = $@"
}
}";
var file2 = @"
using System;
namespace Foo
{{
{
internal static class ExtensionClass
{{
{
public static bool ExtentionMethod(this int x)
=> true;
}}
}}
}
}
namespace Baz
{{
{
public class Bat
{{
{
public void M(int x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemExistsAsync(
......@@ -773,30 +773,30 @@ public void M(int x)
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task TestInternalExtensionMethods_NoIVT_InSameProject()
{
var file1 = $@"
var file1 = @"
using System;
namespace Foo
{{
{
internal static class ExtensionClass
{{
{
internal static bool ExtentionMethod(this int x)
=> true;
}}
}}";
var file2 = $@"
}
}";
var file2 = @"
using System;
namespace Baz
{{
{
public class Bat
{{
{
public void M(int x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, ReferenceType.None);
await VerifyTypeImportItemExistsAsync(
......@@ -812,28 +812,28 @@ public void M(int x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task TestInternalExtensionMethods_WithIVT(ReferenceType refType)
{
var file1 = $@"
var file1 = @"
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(""Project1"")]
namespace Foo
{{
{
internal static class ExtensionClass
{{
{
internal static bool ExtentionMethod(this int x)
=> true;
}}
}}";
var file2 = $@"
}
}";
var file2 = @"
namespace Baz
{{
{
public class Bat
{{
{
public void M(int x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemExistsAsync(
......@@ -847,34 +847,34 @@ public void M(int x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task UserDefinedGenericType(ReferenceType refType)
{
var file1 = $@"
var file1 = @"
using System;
public class MyGeneric<T>
{{
}}
{
}
namespace Foo
{{
{
public static class ExtensionClass
{{
{
public static bool ExtentionMethod(this MyGeneric<int> x)
=> true;
}}
}}";
var file2 = $@"
}
}";
var file2 = @"
using System;
namespace Baz
{{
{
public class Bat
{{
{
public void M(MyGeneric<int> x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = GetMarkup(file2, file1, refType);
await VerifyTypeImportItemExistsAsync(
......@@ -889,17 +889,17 @@ public void M(MyGeneric<int> x)
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task MethodSymbolReceiver(string expression)
{
var file1 = $@"
var file1 = @"
using System;
namespace Foo
{{
{
public static class ExtensionClass
{{
{
public static bool ExtentionMethod(this int x)
=> true;
}}
}}";
}
}";
var file2 = $@"
using System;
......@@ -992,7 +992,7 @@ public void M({csType} x)
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task ExtensionMethodDelcaredInRootNamespaceVBSource()
{
var file1 = $@"
var file1 = @"
Imports System
Imports System.Runtime.CompilerServices
......@@ -1002,19 +1002,19 @@ Imports System.Runtime.CompilerServices
Return True
End Function
End Module";
var file2 = $@"
var file2 = @"
using System;
namespace Baz
{{
{
public class Bat
{{
{
public void M(int x)
{{
{
x.$$
}}
}}
}}";
}
}
}";
var markup = CreateMarkupForProjecWithVBProjectReference(file2, file1, sourceLanguage: LanguageNames.CSharp, rootNamespace: "Root");
await VerifyTypeImportItemExistsAsync(
......@@ -1027,7 +1027,7 @@ public void M(int x)
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task ExtensionMethodDelcaredInGlobalNamespaceVBSource()
{
var file1 = $@"
var file1 = @"
Imports System
Imports System.Runtime.CompilerServices
......@@ -1037,6 +1037,92 @@ Imports System.Runtime.CompilerServices
Return True
End Function
End Module";
var file2 = @"
using System;
namespace Baz
{
public class Bat
{
public void M(int x)
{
x.$$
}
}
}";
var markup = CreateMarkupForProjecWithVBProjectReference(file2, file1, sourceLanguage: LanguageNames.CSharp);
await VerifyTypeImportItemIsAbsentAsync(
markup,
"ExtentionMethod",
inlineDescription: "");
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task TestTriggerLocation()
{
var file1 = @"
using System;
namespace Foo
{
internal static class ExtensionClass
{
internal static bool ExtentionMethod(this int x)
=> true;
}
}";
var file2 = @"
using System;
namespace Baz
{
public class Bat
{
public void M(int x)
{
x.$$
var z = 10;
}
}
}";
var markup = GetMarkup(file2, file1, ReferenceType.None);
await VerifyTypeImportItemExistsAsync(
markup,
"ExtentionMethod",
glyph: (int)Glyph.ExtensionMethodInternal, // This is based on declared accessibility
inlineDescription: "Foo");
}
[InlineData("int", "Int32Method", "Foo")]
[InlineData("string", "StringMethod", "Bar", Skip = "Currently can't handle aliases with idencical name")]
[Theory, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task TestIdenticalAlias_UseOuterOne(string type, string expectedMethodname, string expectedNamespace)
{
var file1 = @"
using X = System.String;
namespace Foo
{
using X = System.Int32;
internal static class ExtensionClass
{
internal static bool Int32Method(this X x)
=> true;
}
}
namespace Bar
{
internal static class ExtensionClass
{
internal static bool StringMethod(this X x)
=> true;
}
}
";
var file2 = $@"
using System;
......@@ -1044,18 +1130,19 @@ namespace Baz
{{
public class Bat
{{
public void M(int x)
public void M({type} x)
{{
x.$$
}}
}}
}}";
var markup = CreateMarkupForProjecWithVBProjectReference(file2, file1, sourceLanguage: LanguageNames.CSharp);
await VerifyTypeImportItemIsAbsentAsync(
var markup = GetMarkup(file2, file1, ReferenceType.None);
await VerifyTypeImportItemExistsAsync(
markup,
"ExtentionMethod",
inlineDescription: "");
expectedMethodname,
glyph: (int)Glyph.ExtensionMethodInternal,
inlineDescription: expectedNamespace);
}
private Task VerifyTypeImportItemExistsAsync(string markup, string expectedItem, int glyph, string inlineDescription, string displayTextSuffix = null, string expectedDescriptionOrNull = null)
......
......@@ -38,7 +38,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Completion.Complet
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function Test() As Task
Public Async Function TestExtensionAttribute() As Task
' attribute suffix isn't capitalized
Dim file1 = <Text><![CDATA[
......@@ -92,7 +92,7 @@ End Class]]></Text>.Value
Await VerifyItemExistsAsync(markup, "ExtensionMethod3", glyph:=Glyph.ExtensionMethodPublic, inlineDescription:="Foo")
Await VerifyItemExistsAsync(markup, "ExtensionMethod4", glyph:=Glyph.ExtensionMethodPublic, inlineDescription:="Foo")
Await VerifyItemExistsAsync(markup, "ExtensionMethod5", glyph:=Glyph.ExtensionMethodPublic, inlineDescription:="Foo")
Await VerifyItemExistsAsync(markup, "ExtensionMethod6", glyph:=Glyph.ExtensionMethodPublic, inlineDescription:="Foo")
Await VerifyItemIsAbsentAsync(markup, "ExtensionMethod6", inlineDescription:="Foo")
End Function
End Class
End Namespace
......@@ -120,7 +120,11 @@ internal sealed partial class SyntaxTreeIndex
{
foreach (var (aliasName, name) in aliases)
{
Debug.Assert(!usingAliases.ContainsKey(aliasName));
// TODO:
// we currently don't handle using aliases with same name declared
// in different containers in the document (only allowed in C#)
// e.g. see test CSharpReferenceHighlightingTests.TestAlias4
// Debug.Assert(!usingAliases.ContainsKey(aliasName));
usingAliases[aliasName] = name;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册