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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public static PropertyValueSyntax GetPropertyValue(this SyntaxNode node, string name)
        {
            PropertySyntax property = node.GetProperty(name);

            if (property != null)
            {
                return(property.Value);
            }
            return(null);
        }
コード例 #4
0
        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))));
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 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);
 }
コード例 #8
0
        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);
                }
            }
        }
コード例 #9
0
        protected bool HasApplicationArea(SyntaxNode node)
        {
            PropertySyntax appAreaProperty = node.GetProperty("ApplicationArea");

            return((appAreaProperty != null) && (!String.IsNullOrWhiteSpace(appAreaProperty.Value.ToString())));
        }
コード例 #10
0
 public SyntaxToken FormatInheritance(PropertySyntax syntax)
 {
     return(FormatInheritance(syntax.GetInheritance()));
 }
コード例 #11
0
 public VBPropertyFormatter(PropertySyntax syntax)
 {
     _syntax = syntax;
 }
コード例 #12
0
        protected bool HasToolTip(SyntaxNode node)
        {
            PropertySyntax ToolTipProperty = node.GetProperty("ToolTip");

            return((ToolTipProperty != null) && (!String.IsNullOrWhiteSpace(ToolTipProperty.Value.ToString())));
        }
コード例 #13
0
 public virtual void VisitPropertySyntax(PropertySyntax property)
 {
 }
コード例 #14
0
 public CSharpPropertyFormatter(PropertySyntax syntax)
 {
     _syntax = syntax;
 }
コード例 #15
0
 public SyntaxToken FormatIdentifier(PropertySyntax syntax)
 {
     return(new SyntaxToken(syntax.GetIdentifier(), SyntaxTokens.Text));
 }
コード例 #16
0
 public List <SyntaxToken> FormatSetVisibility(PropertySyntax syntax)
 {
     return(FormatVisibility(syntax.GetSetterVisibility()));
 }
コード例 #17
0
 public List <SyntaxToken> FormatType(PropertySyntax syntax)
 {
     return(FormatTypeDetails(syntax.GetType()));
 }