-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
46 lines (39 loc) · 1.52 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
45
46
using System;
using System.Linq;
using System.IO;
using Microsoft.CodeAnalysis.CSharp;
namespace Chickenfuscator
{
sealed class Program
{
static int Main (string [] args)
{
var commandLine = CSharpCommandLineParser.Default.Parse (
args,
Environment.CurrentDirectory,
System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory ());
var compilation = CSharpCompilation.Create (
commandLine.CompilationName
?? Path.GetFileNameWithoutExtension (
commandLine.OutputFileName),
commandLine.SourceFiles.Select (file =>
CSharpSyntaxTree.ParseText (
File.ReadAllText (file.Path),
commandLine.ParseOptions,
file.Path)),
references: commandLine.ResolveMetadataReferences (
new ChickenMetadataReferenceResolver ()),
options: commandLine.CompilationOptions);
foreach (var tree in compilation.SyntaxTrees) {
var chickenRewriter = new ChickenSyntaxRewriter (
compilation.GetSemanticModel (
tree,
ignoreAccessibility: true));
var chickenRoot = chickenRewriter.Visit (tree.GetRoot ());
chickenRoot.WriteTo (Console.Out);
Console.WriteLine ();
}
return 0;
}
}
}