Example #1
0
            public override void VisitFieldDeclaration(FieldDeclarationSyntax node)
            {
                var namedTypeSymbol = _context.GetNamedSymbol(node.Declaration.Type);

                if (namedTypeSymbol == null)
                {
                    return;
                }
                if (!namedTypeSymbol.IsServiceContract())
                {
                    return;
                }

                var typeName   = namedTypeSymbol.Name;
                var isContract = typeName.IsServiceContractName();

                if (!isContract)
                {
                    return;
                }
                var expectedFieldName = typeName.GetServiceContractFieldName();
                var actualFieldName   = node.GetFieldName();

                if (expectedFieldName == actualFieldName)
                {
                    return;
                }
                var diagnostic = Diagnostic.Create(Rule, node.GetFieldNameLocation(), _className, actualFieldName, expectedFieldName);

                _context.ReportDiagnostic(diagnostic);
            }