예제 #1
0
        private static MemberDeclarationSyntax LastField(
            SyntaxList <MemberDeclarationSyntax> members,
            FieldDeclarationSyntax fieldDeclaration)
        {
            var lastConst = members.AsEnumerable()
                            .OfType <FieldDeclarationSyntax>()
                            .Where(f => f.Modifiers.Any(SyntaxKind.ConstKeyword)).LastOrDefault();

            // Place a const after the last existing const.
            if (fieldDeclaration.Modifiers.Any(SyntaxKind.ConstKeyword))
            {
                return(lastConst);
            }

            // Place a field after the last field, or after the last const.
            return(CSharpCodeGenerationHelpers.LastField(members) ?? lastConst);
        }