Esempio n. 1
0
		/// <summary>
		///   Normalizes the <paramref name="structDeclaration" />.
		/// </summary>
		public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax structDeclaration)
		{
			structDeclaration = (StructDeclarationSyntax)base.VisitStructDeclaration(structDeclaration);

			if (structDeclaration.Modifiers.Any(SyntaxKind.PartialKeyword))
				return structDeclaration;

			var partialKeyword = SyntaxFactory.Token(SyntaxKind.PartialKeyword).WithTrailingSpace();
			partialKeyword = partialKeyword.WithLeadingTrivia(structDeclaration.Keyword.LeadingTrivia);
			structDeclaration = structDeclaration.WithModifiers(structDeclaration.Modifiers.Add(partialKeyword));
			return structDeclaration.WithKeyword(structDeclaration.Keyword.WithLeadingSpace());
		}
        private static SyntaxNode HandleStructDeclaration(StructDeclarationSyntax node)
        {
            SyntaxToken triviaToken = node.Keyword;
            if (triviaToken.IsMissing)
            {
                return null;
            }

            SyntaxKind defaultVisibility = IsNestedType(node) ? SyntaxKind.PrivateKeyword : SyntaxKind.InternalKeyword;
            SyntaxTokenList modifiers = DeclarationModifiersHelper.AddModifier(node.Modifiers, ref triviaToken, defaultVisibility);
            return node
                .WithKeyword(triviaToken)
                .WithModifiers(modifiers)
                .WithoutFormatting();
        }