public override SyntaxNode VisitField(FieldSyntax node) { PropertyValueSyntax fieldClass = node.GetPropertyValue("FieldClass"); if ((fieldClass == null) || (fieldClass.ToString().Equals("Normal", StringComparison.CurrentCultureIgnoreCase))) { PropertySyntax propertySyntax = node.GetProperty("DataClassification"); if (propertySyntax == null) { NoOfChanges++; return(node.AddPropertyListProperties( this.CreateDataClassificationProperty(node))); } else { string valueText = propertySyntax.Value.ToString(); if ((String.IsNullOrWhiteSpace(valueText)) || (valueText.Equals("ToBeClassified", StringComparison.CurrentCultureIgnoreCase))) { NoOfChanges++; return(node.ReplaceNode(propertySyntax, this.CreateDataClassificationProperty(node))); } } } return(base.VisitField(node)); }
public SyntaxTokenCollection Format(PropertySyntax syntax) { SyntaxTokenCollection tokens = new SyntaxTokenCollection(); tokens.AddRange(FormatVisibility(syntax)); tokens.Add(Constants.Space); tokens.AddRange(FormatType(syntax)); tokens.Add(Constants.Space); tokens.Add(FormatIdentifier(syntax)); tokens.Add(new SyntaxToken(" {", SyntaxTokens.Text)); if (_syntax.GetMethod != null) { tokens.Add(new SyntaxToken("\n\t", SyntaxTokens.Text)); if (syntax.GetVisibility() != syntax.GetGetterVisibility()) { tokens.AddRange(FormatGetVisibility(syntax)); tokens.Add(Constants.Space); } tokens.Add(Constants.KeywordGet); tokens.Add(new SyntaxToken(";", SyntaxTokens.Text)); } if (_syntax.SetMethod != null) { tokens.Add(new SyntaxToken("\n\t", SyntaxTokens.Text)); if (syntax.GetVisibility() != syntax.GetSetterVisibility()) { tokens.AddRange(FormatSetVisibility(syntax)); tokens.Add(Constants.Space); } tokens.Add(Constants.KeywordSet); tokens.Add(new SyntaxToken(";", SyntaxTokens.Text)); } tokens.Add(new SyntaxToken("\n\t}", SyntaxTokens.Text)); return(tokens); }
public static PropertyValueSyntax GetPropertyValue(this SyntaxNode node, string name) { PropertySyntax property = node.GetProperty(name); if (property != null) { return(property.Value); } return(null); }
public static bool HasProperty(this SyntaxNode node, string propertyName, string emptyValue = null) { PropertySyntax propertySyntax = node.GetProperty(propertyName); return((propertySyntax != null) && (!String.IsNullOrWhiteSpace(propertySyntax.Value.ToString())) && ( (emptyValue == null) || (!emptyValue.Equals(propertySyntax.Value.ToString(), StringComparison.CurrentCultureIgnoreCase)))); }
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 SyntaxTokenCollection Format(PropertySyntax syntax) { SyntaxTokenCollection tokens = new SyntaxTokenCollection(); tokens.AddRange(FormatVisibility(syntax)); tokens.Add(Constants.Space); tokens.Add(new SyntaxToken("Property", SyntaxTokens.Keyword)); tokens.Add(Constants.Space); tokens.Add(FormatIdentifier(syntax)); tokens.Add(Constants.Space); tokens.Add(Constants.KeywordAs); tokens.Add(Constants.Space); tokens.AddRange(FormatType(syntax)); return(tokens); }
private static PropertySyntax GetProperty( SyntaxList <PropertySyntaxOrEmpty> properties, string propertyName) { foreach (PropertySyntaxOrEmpty property in properties) { if (property.Kind != SyntaxKind.EmptyProperty) { PropertySyntax propertySyntax = (PropertySyntax)property; if (SemanticFacts.IsSameName(propertySyntax.Name.Identifier.ValueText, propertyName)) { return(propertySyntax); } } } return((PropertySyntax)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); } } }
protected bool HasApplicationArea(SyntaxNode node) { PropertySyntax appAreaProperty = node.GetProperty("ApplicationArea"); return((appAreaProperty != null) && (!String.IsNullOrWhiteSpace(appAreaProperty.Value.ToString()))); }
public SyntaxToken FormatInheritance(PropertySyntax syntax) { return(FormatInheritance(syntax.GetInheritance())); }
public VBPropertyFormatter(PropertySyntax syntax) { _syntax = syntax; }
protected bool HasToolTip(SyntaxNode node) { PropertySyntax ToolTipProperty = node.GetProperty("ToolTip"); return((ToolTipProperty != null) && (!String.IsNullOrWhiteSpace(ToolTipProperty.Value.ToString()))); }
public virtual void VisitPropertySyntax(PropertySyntax property) { }
public CSharpPropertyFormatter(PropertySyntax syntax) { _syntax = syntax; }
public SyntaxToken FormatIdentifier(PropertySyntax syntax) { return(new SyntaxToken(syntax.GetIdentifier(), SyntaxTokens.Text)); }
public List <SyntaxToken> FormatSetVisibility(PropertySyntax syntax) { return(FormatVisibility(syntax.GetSetterVisibility())); }
public List <SyntaxToken> FormatType(PropertySyntax syntax) { return(FormatTypeDetails(syntax.GetType())); }