Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev15.7-preview3 to dev15.7.x #25785

Merged
merged 3 commits into from
Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.ComponentModel.Composition;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.Classification;
using Microsoft.VisualStudio.Language.StandardClassification;
using Microsoft.VisualStudio.Text.Classification;
Expand Down Expand Up @@ -73,6 +72,61 @@ internal sealed class ClassificationTypeDefinitions
internal readonly ClassificationTypeDefinition UserTypeTypeParametersTypeDefinition;
#endregion

#region Field Name
[Export]
[Name(ClassificationTypeNames.FieldName)]
[BaseDefinition(PredefinedClassificationTypeNames.Identifier)]
internal readonly ClassificationTypeDefinition FieldNameTypeDefinition;
#endregion
#region Enum Member Name
[Export]
[Name(ClassificationTypeNames.EnumMemberName)]
[BaseDefinition(PredefinedClassificationTypeNames.Identifier)]
internal readonly ClassificationTypeDefinition EnumMemberNameTypeDefinition;
#endregion
#region Constant Name
[Export]
[Name(ClassificationTypeNames.ConstantName)]
[BaseDefinition(PredefinedClassificationTypeNames.Identifier)]
internal readonly ClassificationTypeDefinition ConstantNameTypeDefinition;
#endregion
#region Local Name
[Export]
[Name(ClassificationTypeNames.LocalName)]
[BaseDefinition(PredefinedClassificationTypeNames.Identifier)]
internal readonly ClassificationTypeDefinition LocalNameTypeDefinition;
#endregion
#region Parameter Name
[Export]
[Name(ClassificationTypeNames.ParameterName)]
[BaseDefinition(PredefinedClassificationTypeNames.Identifier)]
internal readonly ClassificationTypeDefinition ParameterNameTypeDefinition;
#endregion
#region Method Name
[Export]
[Name(ClassificationTypeNames.MethodName)]
[BaseDefinition(PredefinedClassificationTypeNames.Identifier)]
internal readonly ClassificationTypeDefinition MethodNameTypeDefinition;
#endregion
#region Extension Method Name
[Export]
[Name(ClassificationTypeNames.ExtensionMethodName)]
[BaseDefinition(PredefinedClassificationTypeNames.Identifier)]
internal readonly ClassificationTypeDefinition ExtensionMethodNameTypeDefinition;
#endregion
#region Property Name
[Export]
[Name(ClassificationTypeNames.PropertyName)]
[BaseDefinition(PredefinedClassificationTypeNames.Identifier)]
internal readonly ClassificationTypeDefinition PropertyNameTypeDefinition;
#endregion
#region Event Name
[Export]
[Name(ClassificationTypeNames.EventName)]
[BaseDefinition(PredefinedClassificationTypeNames.Identifier)]
internal readonly ClassificationTypeDefinition EventNameTypeDefinition;
#endregion

#region XML Doc Comments - Attribute Name
[Export]
[Name(ClassificationTypeNames.XmlDocCommentAttributeName)]
Expand Down
37 changes: 37 additions & 0 deletions src/EditorFeatures/Test/Workspaces/ClassificationTypeNamesTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Reflection;
using Microsoft.CodeAnalysis.Classification;
using Microsoft.VisualStudio.Text.Classification;
using Roslyn.Test.Utilities;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
{
public class ClassificationTypeNamesTests
{
public static IEnumerable<object[]> AllClassificationTypeNames
{
get
{
foreach (var field in typeof(ClassificationTypeNames).GetFields(BindingFlags.Static | BindingFlags.Public))
{
yield return new object[] { field.Name, field.GetRawConstantValue() };
}
}
}

[Theory]
[MemberData(nameof(AllClassificationTypeNames))]
[WorkItem(25716, "https://github.com/dotnet/roslyn/issues/25716")]
public void ClassificationTypeExported(string fieldName, object constantValue)
{
var classificationTypeName = Assert.IsType<string>(constantValue);
var exportProvider = TestExportProvider.ExportProviderWithCSharpAndVisualBasic;
var classificationTypeRegistryService = exportProvider.GetExport<IClassificationTypeRegistryService>().Value;
var classificationType = classificationTypeRegistryService.GetClassificationType(classificationTypeName);
Assert.True(classificationType != null, $"{nameof(ClassificationTypeNames)}.{fieldName} has value \"{classificationTypeName}\", but no matching {nameof(ClassificationTypeDefinition)} was exported.");
}
}
}