📄
core/src/AuthoredSource.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
using System; using System.IO; using System.Linq; using Microsoft.CodeAnalysis; namespace Cfa; internal static class AuthoredSource { public static bool Includes(SyntaxTree tree, Document document) { var path = document.FilePath ?? tree.FilePath; if ( document.Project.FilePath is string projectPath && Path.IsPathRooted(path) && Path.GetDirectoryName(projectPath) is string projectDirectory ) { path = Path.GetRelativePath(projectDirectory, path); } if ( path.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) .Any(segment => segment.Equals("obj", StringComparison.OrdinalIgnoreCase) || segment.Equals("bin", StringComparison.OrdinalIgnoreCase) ) ) { return false; } var name = Path.GetFileName(path); if ( name.EndsWith(".g.cs", StringComparison.OrdinalIgnoreCase) || name.EndsWith(".g.i.cs", StringComparison.OrdinalIgnoreCase) || name.EndsWith(".generated.cs", StringComparison.OrdinalIgnoreCase) || name.EndsWith(".designer.cs", StringComparison.OrdinalIgnoreCase) ) { return false; } return true; } }