未验证 提交 6d43c55c 编写于 作者: T Tom Meschter 提交者: GitHub

Merge pull request #25785 from dotnet/merges/dev15.7-preview3-to-dev15.7.x

Merge dev15.7-preview3 to dev15.7.x
// 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;
......@@ -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)]
......
// 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.");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册