This repository was archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathCopyrightHeaderRule.CSharp.cs
57 lines (48 loc) · 1.73 KB
/
CopyrightHeaderRule.CSharp.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using System.Collections.Immutable;
namespace Microsoft.DotNet.CodeFormatting.Rules
{
internal partial class CopyrightHeaderRule
{
private sealed class CSharpRule : CommonRule
{
internal CSharpRule(ImmutableArray<string> header) : base(header)
{
}
protected override SyntaxTriviaList CreateTriviaList(IEnumerable<SyntaxTrivia> e)
{
return SyntaxFactory.TriviaList(e);
}
protected override bool IsLineComment(SyntaxTrivia trivia)
{
return trivia.Kind() == SyntaxKind.SingleLineCommentTrivia;
}
protected override bool IsWhitespace(SyntaxTrivia trivia)
{
return trivia.Kind() == SyntaxKind.WhitespaceTrivia;
}
protected override bool IsNewLine(SyntaxTrivia trivia)
{
return trivia.Kind() == SyntaxKind.EndOfLineTrivia;
}
protected override SyntaxTrivia CreateLineComment(string commentText)
{
return SyntaxFactory.Comment("//" + commentText);
}
protected override SyntaxTrivia CreateNewLine()
{
return SyntaxFactory.CarriageReturnLineFeed;
}
}
}
}