From a7899a9707991f17836542d0c2c1e1432f3f1a04 Mon Sep 17 00:00:00 2001 From: Arthur van de Vondervoort Date: Tue, 7 Nov 2023 09:52:04 +0100 Subject: [PATCH] Improve Rule0026 for supporting attributes --- Design/Rule0026ToolTipPunctuation.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Design/Rule0026ToolTipPunctuation.cs b/Design/Rule0026ToolTipPunctuation.cs index 4657550a..13b9a4fc 100644 --- a/Design/Rule0026ToolTipPunctuation.cs +++ b/Design/Rule0026ToolTipPunctuation.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Immutable; +using System.Collections.Immutable; using Microsoft.Dynamics.Nav.CodeAnalysis; using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics; using Microsoft.Dynamics.Nav.CodeAnalysis.Syntax; @@ -18,15 +17,13 @@ private void AnalyzeToolTipPunctuation(SyntaxNodeAnalysisContext ctx) if (ctx.ContainingSymbol.IsObsoletePending || ctx.ContainingSymbol.IsObsoleteRemoved) return; if (ctx.ContainingSymbol.GetContainingObjectTypeSymbol().IsObsoletePending || ctx.ContainingSymbol.GetContainingObjectTypeSymbol().IsObsoleteRemoved) return; - PropertySyntax tooltipProperty = ctx.Node.GetProperty("ToolTip"); - - if (tooltipProperty != null) - { - string tooltipValue = tooltipProperty.Value.GetText().ToString(); - if (!tooltipValue.EndsWith(".'")) - ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0026ToolTipPunctuation, tooltipProperty.GetLocation())); - } + PropertyValueSyntax tooltipProperty = ctx.Node.GetPropertyValue(PropertyKind.ToolTip); + if (tooltipProperty == null) + return; + StringLiteralValueSyntax tooltipLabel = ((LabelPropertyValueSyntax)tooltipProperty).Value.LabelText; + if (!tooltipLabel.Value.ToString().EndsWith(".'")) + ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0026ToolTipPunctuation, tooltipProperty.GetLocation())); } } } \ No newline at end of file