diff --git a/src/EditorFeatures/CSharpTest/Classification/SemanticClassifierTests.cs b/src/EditorFeatures/CSharpTest/Classification/SemanticClassifierTests.cs index e003555af544b..09431cf6d8667 100644 --- a/src/EditorFeatures/CSharpTest/Classification/SemanticClassifierTests.cs +++ b/src/EditorFeatures/CSharpTest/Classification/SemanticClassifierTests.cs @@ -291,7 +291,9 @@ await TestAsync( class C { dynamic d; -}", testHost); +}", + testHost, + Class("dynamic")); } [Theory] @@ -1461,7 +1463,8 @@ public async Task NAQTypeNameMethodCall(TestHost testHost) await TestInMethodAsync(@"global::System.String.Clone("");", testHost, Namespace("System"), - Class("String")); + Class("String"), + Method("Clone")); } [Theory] @@ -1974,12 +1977,12 @@ class Serializable { } -[NonSerialized] // Binds to global::NonSerializedAttribute; not colorized +[NonSerialized] // Binds to global::NonSerializedAttribute; colorized class NonSerializedAttribute { } -[NonSerializedAttribute] // Binds to global::NonSerializedAttribute; not colorized +[NonSerializedAttribute] // Binds to global::NonSerializedAttribute; colorized class NonSerializedAttribute { } @@ -1997,6 +2000,8 @@ class ObsoleteAttribute : Attribute Namespace("System"), Class("Serializable"), Class("SerializableAttribute"), + Class("NonSerialized"), + Class("NonSerializedAttribute"), Class("Obsolete"), Class("Attribute"), Class("ObsoleteAttribute"), @@ -2589,7 +2594,8 @@ void goo() } }", testHost, - Keyword("var")); + Keyword("var"), + Method("nameof")); } [WpfFact] @@ -4451,5 +4457,30 @@ class C { }", testHost, Namespace("NS")); } + + [Theory] + [CombinatorialData] + [WorkItem(57184, "https://github.com/dotnet/roslyn/issues/57184")] + public async Task MethodGroupClassifications(TestHost testHost) + { + await TestAsync( +@"var f = m; +Delegate d = m; +MulticastDelegate md = m; +ICloneable c = m; +object obj = m; +m(m); + +int m(Delegate d) { }", + testHost, + Keyword("var"), + Method("m"), + Method("m"), + Method("m"), + Method("m"), + Method("m"), + Method("m"), + Method("m")); + } } } diff --git a/src/EditorFeatures/CSharpTest/Classification/TotalClassifierTests.cs b/src/EditorFeatures/CSharpTest/Classification/TotalClassifierTests.cs index ff27fdbe06be6..fd3122121d247 100644 --- a/src/EditorFeatures/CSharpTest/Classification/TotalClassifierTests.cs +++ b/src/EditorFeatures/CSharpTest/Classification/TotalClassifierTests.cs @@ -55,7 +55,8 @@ await TestAsync( /// 0) - { - var firstSymbol = symbolInfo.CandidateSymbols[0]; - - switch (symbolInfo.CandidateReason) - { - case CandidateReason.NotAValue: - return firstSymbol; - - case CandidateReason.NotCreatable: - // We want to color types even if they can't be constructed. - if (firstSymbol.IsConstructor() || firstSymbol is ITypeSymbol) - { - symbol = firstSymbol; - } - - break; - - case CandidateReason.OverloadResolutionFailure: - // If we couldn't bind to a constructor, still classify the type. - if (firstSymbol.IsConstructor()) - { - symbol = firstSymbol; - } - - break; - - case CandidateReason.Inaccessible: - // If a constructor wasn't accessible, still classify the type if it's accessible. - if (firstSymbol.IsConstructor() && semanticModel.IsAccessible(node.SpanStart, firstSymbol.ContainingType)) - { - symbol = firstSymbol; - } - - break; - - case CandidateReason.WrongArity: - var arity = GetRightmostNameArity(node); - - if (arity.HasValue && arity.Value == 0) - { - // When the user writes something like "IList" we don't want to *not* classify - // just because the type bound to "IList". This is also important for use - // cases like "Add-using" where it can be confusing when the using is added for - // "using System.Collection.Generic" but then the type name still does not classify. - symbol = firstSymbol; - } - - break; - } - } + var symbol = symbolInfo.GetAnySymbol(); // Classify a reference to an attribute constructor in an attribute location // as if we were classifying the attribute type itself. diff --git a/src/Workspaces/VisualBasic/Portable/Classification/SyntaxClassification/NameSyntaxClassifier.vb b/src/Workspaces/VisualBasic/Portable/Classification/SyntaxClassification/NameSyntaxClassifier.vb index d34c54f173a17..b7bb68596e9f2 100644 --- a/src/Workspaces/VisualBasic/Portable/Classification/SyntaxClassification/NameSyntaxClassifier.vb +++ b/src/Workspaces/VisualBasic/Portable/Classification/SyntaxClassification/NameSyntaxClassifier.vb @@ -73,7 +73,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Classification.Classifiers Dim classifiedSpan As ClassifiedSpan Dim symbolInfo = semanticModel.GetSymbolInfo(node, cancellationToken) - Dim symbol = TryGetSymbol(node, symbolInfo, semanticModel) + Dim symbol = TryGetSymbol(node, symbolInfo) If symbol Is Nothing Then If TryClassifyIdentifier(node, semanticModel, cancellationToken, classifiedSpan) Then