提交 42170541 编写于 作者: S Sam Harwell

Map ReportDiagnostic.Default and Suppress to null instead of the default DiagnosticSeverity

上级 3e582736
......@@ -182,7 +182,7 @@ public abstract partial class Diagnostic : IEquatable<Diagnostic>, IFormattable
var warningLevel = GetDefaultWarningLevel(effectiveSeverity, descriptor.DefaultSeverity);
return SimpleDiagnostic.Create(
descriptor,
severity: effectiveSeverity.ToDiagnosticSeverity(descriptor.DefaultSeverity),
severity: effectiveSeverity.ToDiagnosticSeverity() ?? descriptor.DefaultSeverity,
warningLevel: warningLevel,
location: location ?? Location.None,
additionalLocations: additionalLocations,
......
......@@ -6,7 +6,7 @@ namespace Microsoft.CodeAnalysis
{
public static class ReportDiagnosticExtensions
{
public static DiagnosticSeverity ToDiagnosticSeverity(this ReportDiagnostic reportDiagnostic, DiagnosticSeverity defaultSeverity)
public static DiagnosticSeverity? ToDiagnosticSeverity(this ReportDiagnostic reportDiagnostic)
{
switch (reportDiagnostic)
{
......@@ -24,7 +24,7 @@ public static DiagnosticSeverity ToDiagnosticSeverity(this ReportDiagnostic repo
case ReportDiagnostic.Suppress:
case ReportDiagnostic.Default:
return defaultSeverity;
return null;
default:
throw ExceptionUtilities.UnexpectedValue(reportDiagnostic);
......
......@@ -7,5 +7,5 @@ Microsoft.CodeAnalysis.ReportDiagnosticExtensions
abstract Microsoft.CodeAnalysis.Compilation.ClassifyCommonConversion(Microsoft.CodeAnalysis.ITypeSymbol source, Microsoft.CodeAnalysis.ITypeSymbol destination) -> Microsoft.CodeAnalysis.Operations.CommonConversion
static Microsoft.CodeAnalysis.Diagnostic.Create(Microsoft.CodeAnalysis.DiagnosticDescriptor descriptor, Microsoft.CodeAnalysis.Location location, Microsoft.CodeAnalysis.ReportDiagnostic effectiveSeverity, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Location> additionalLocations, System.Collections.Immutable.ImmutableDictionary<string, string> properties, params object[] messageArgs) -> Microsoft.CodeAnalysis.Diagnostic
static Microsoft.CodeAnalysis.DiagnosticSeverityExtensions.ToReportDiagnostic(this Microsoft.CodeAnalysis.DiagnosticSeverity diagnosticSeverity) -> Microsoft.CodeAnalysis.ReportDiagnostic
static Microsoft.CodeAnalysis.ReportDiagnosticExtensions.ToDiagnosticSeverity(this Microsoft.CodeAnalysis.ReportDiagnostic reportDiagnostic, Microsoft.CodeAnalysis.DiagnosticSeverity defaultSeverity) -> Microsoft.CodeAnalysis.DiagnosticSeverity
static Microsoft.CodeAnalysis.ReportDiagnosticExtensions.ToDiagnosticSeverity(this Microsoft.CodeAnalysis.ReportDiagnostic reportDiagnostic) -> Microsoft.CodeAnalysis.DiagnosticSeverity?
static Microsoft.CodeAnalysis.ReportDiagnosticExtensions.WithDefaultSeverity(this Microsoft.CodeAnalysis.ReportDiagnostic reportDiagnostic, Microsoft.CodeAnalysis.DiagnosticSeverity defaultSeverity) -> Microsoft.CodeAnalysis.ReportDiagnostic
......@@ -49,7 +49,7 @@ public CodeStyleOption(T value, NotificationOption notification)
new XAttribute(nameof(SerializationVersion), SerializationVersion),
new XAttribute("Type", GetTypeNameForSerialization()),
new XAttribute(nameof(Value), GetValueForSerialization()),
new XAttribute(nameof(DiagnosticSeverity), Notification.Severity.ToDiagnosticSeverity(DiagnosticSeverity.Hidden)));
new XAttribute(nameof(DiagnosticSeverity), Notification.Severity.ToDiagnosticSeverity() ?? DiagnosticSeverity.Hidden));
private object GetValueForSerialization()
{
......
......@@ -25,7 +25,7 @@ public ReportDiagnostic Severity
[Obsolete("Use " + nameof(Severity) + " instead.")]
public DiagnosticSeverity Value
{
get => Severity.ToDiagnosticSeverity(DiagnosticSeverity.Hidden);
get => Severity.ToDiagnosticSeverity() ?? DiagnosticSeverity.Hidden;
set => Severity = value.ToReportDiagnostic();
}
......
......@@ -24,7 +24,7 @@ internal XElement CreateXElement()
var element = new XElement(nameof(SerializableNamingRule),
new XAttribute(nameof(SymbolSpecificationID), SymbolSpecificationID),
new XAttribute(nameof(NamingStyleID), NamingStyleID),
new XAttribute(nameof(EnforcementLevel), EnforcementLevel.ToDiagnosticSeverity(DiagnosticSeverity.Hidden)));
new XAttribute(nameof(EnforcementLevel), EnforcementLevel.ToDiagnosticSeverity() ?? DiagnosticSeverity.Hidden));
return element;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册