Пример #1
0
        internal static IEnumerable <string> HandleFieldDeclaration(IVisitorContext context, MemberDeclarationSyntax node, VariableDeclarationSyntax variableDeclarationSyntax,
                                                                    SyntaxTokenList modifiers, BaseTypeDeclarationSyntax declaringType)
        {
            var visitor = new FieldDeclarationVisitor(context);

            return(visitor.HandleFieldDeclaration(node, variableDeclarationSyntax, modifiers, declaringType));
        }
Пример #2
0
        private string AddBackingField(EventFieldDeclarationSyntax node)
        {
            var privateModifier       = SyntaxFactory.Token(SyntaxKind.PrivateKeyword); // always private no matter the accessibility of the event
            var accessibilityModifier = node.Modifiers.FirstOrDefault(m => m.IsKind(SyntaxKind.PublicKeyword) || m.IsKind(SyntaxKind.InternalKeyword));
            var backingFieldModifiers = accessibilityModifier == default
                ? node.Modifiers.Add(privateModifier)
                : node.Modifiers.Replace(accessibilityModifier, privateModifier);

            var fields = FieldDeclarationVisitor.HandleFieldDeclaration(Context, node, node.Declaration, backingFieldModifiers, node.ResolveDeclaringType());

            return(fields.First());
        }