StyleCop.Analyzers 是否支持 C# 记录?

Does StyleCop.Analyzers support C# records?

问题描述:

StyleCop.Analyzers 的项目中添加 C# 记录时,显示警告:

Warning AD0001  Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName' threw an exception of type 'System.ArgumentException' with message 'Unhandled declaration kind: RecordDeclaration'.    

System.ArgumentException: Unhandled declaration kind: RecordDeclaration
       at StyleCop.Analyzers.Helpers.NamedTypeHelpers.GetNameOrIdentifier(MemberDeclarationSyntax member)
       at StyleCop.Analyzers.Helpers.FileNameHelpers.GetConventionalFileName(MemberDeclarationSyntax declaration, FileNamingConvention convention)
       at StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName.Analyzer.HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopSettings settings)
       at StyleCop.Analyzers.AnalyzerExtensions.<>c__DisplayClass0_0.<RegisterSyntaxTreeAction>b__0(SyntaxTreeAnalysisContext c)
       at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c.<ExecuteSyntaxTreeActionsCore>b__59_1(ValueTuple`2 data)
       at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)

这是 StyleCop.Analyzers 中的错误吗?

重现步骤:

谢谢@stuartd,你给我指明了正确的方向。

这确实是 Stylecop 1 中的一个错误。1.X

已在 StyleCop.Analyzers.Unstable v1.2.0-beta.161 中更正。但不幸的是,它还没有包含在稳定版本中。所以我现在看到的解决方法是使用不稳定版本