public static void AnalyzeEnumValuesCaptions(SyntaxNodeAnalysisContext context, EnumValueSyntax syntax) { if (syntax == null) { return; } PropertyListSyntax propertyListSyntax = syntax.PropertyList; PropertySyntax propertySyntax = GetProperty(propertyListSyntax.Properties, "Caption"); if (propertySyntax == null) { ReportEnumValueMustHaveCaptionProperty(context, propertyListSyntax.GetLocation(), syntax.Name.ToString(), syntax.Kind, syntax.Name); } }
public override SyntaxNode VisitPropertyList(PropertyListSyntax node) { if ((this.NodeInSpan(node)) && (node.Properties != null) && (node.Properties.Count > 0) && (!node.ContainsDiagnostics)) { List <SyntaxNodeSortInfo <PropertySyntaxOrEmpty> > list = SyntaxNodeSortInfo <PropertySyntaxOrEmpty> .FromSyntaxList(node.Properties); list.Sort(new PropertyComparer()); SyntaxList <PropertySyntaxOrEmpty> properties = SyntaxNodeSortInfo <PropertySyntaxOrEmpty> .ToSyntaxList(list); node = node.WithProperties(properties); } return(base.VisitPropertyList(node)); }
public static PropertySyntax GetProperty(this SyntaxNode node, string name) { PropertyListSyntax propertyList = node.TryGetValueOf <PropertyListSyntax>(name); if (propertyList != null) { foreach (PropertySyntax property in propertyList.Properties) { if (property.Name.Identifier.ValueText == name) { return(property); } } } return(null); }
public static void AnalyzePagePartsCaptions(SyntaxNodeAnalysisContext context, dynamic syntax) { if (syntax != null) { PropertyListSyntax propertyListSyntax = syntax.PropertyList; PropertySyntax propertySyntax = GetProperty(propertyListSyntax.Properties, "Caption"); PropertySyntax showCaptionPropertySyntax = GetProperty(propertyListSyntax.Properties, "ShowCaption"); if (showCaptionPropertySyntax != null) { dynamic showCaptionPropertyValueSyntax = showCaptionPropertySyntax.Value; if (showCaptionPropertyValueSyntax.Value.Value.Value == "false") { return; } } if (propertySyntax == null) { ReportPagePartsMustHaveCaptionProperty(context, propertyListSyntax.GetLocation(), syntax.Name.ToString(), syntax.Kind, syntax.Name); } } }