-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
44 lines (40 loc) · 1.58 KB
/
Program.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
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis;
namespace analyzer
{
class Program
{
static void Main(string[] args)
{
Task.Run(async () =>
{
using (var wkspace = MSBuildWorkspace.Create())
{
var prjPathfilename = "/src/test/test.csproj";
if (!File.Exists("/.dockerenv"))
{
prjPathfilename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../../test/test.csproj");
}
System.Console.WriteLine("---> OpenProject");
var prj = await wkspace.OpenProjectAsync(prjPathfilename);
ImmutableList<WorkspaceDiagnostic> diagnostics = wkspace.Diagnostics;
foreach (var diagnostic in diagnostics)
{
System.Console.WriteLine(diagnostic.Message);
}
var cts = new CancellationTokenSource();
var ct = cts.Token;
System.Console.WriteLine("---> GetCompilation");
var compilation = await prj.GetCompilationAsync(ct);
System.Console.WriteLine($"has documents = {prj.HasDocuments}");
}
}).Wait();
}
}
}