-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
103 lines (83 loc) · 3.52 KB
/
Copy pathProgram.cs
File metadata and controls
103 lines (83 loc) · 3.52 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#pragma warning disable 162
// ReSharper disable HeuristicUnreachableCode
using System;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using NETMetaCoder.Abstractions;
using NETMetaCoder.MSBuild;
using NETMetaCoder.SyntaxWrappers;
namespace NETMetaCoder.TestApp
{
class Program
{
// ReSharper disable once UnusedParameter.Local
static void Main(string[] args)
{
const bool compile = false;
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
if (compile)
{
var projectRootPath = Directory.GetParent(Environment.CurrentDirectory).Parent!.Parent!.FullName;
var codeFilePaths = Directory.GetFiles(projectRootPath, "*.cs", SearchOption.AllDirectories)
.Where(f => !f.Contains("/obj/")).ToArray();
var testCodeFilePaths = codeFilePaths.Where(codeFilePath => codeFilePath.EndsWith("TestClass.cs"))
.ToArray();
var outputBasePath = Path.Combine(projectRootPath, "obj");
var wrappers = AttributesIndexReader.Read(projectRootPath).Select(attributeDescriptor =>
{
var wrapperType = SyntaxWrappersIndex.WrapperTypes[attributeDescriptor.WrapperType];
return (attributeDescriptor, (
wrapperType.Usings,
wrapperType.PropertySyntaxGenerator,
wrapperType.StatementWrappers));
})
.ToImmutableDictionary(
kv =>
{
var (a, _) = kv;
return a;
},
kv =>
{
var (_, b) = kv;
return b;
});
if (!wrappers.Any())
{
throw new NETMetaCoderException(
"[NETMetaCoder] No attributes found to wrap. Consider removing the reference to NETMetaCoder.");
}
var codeWrapTransformationOptions = new CodeWrapTransformationOptions(
projectRootPath,
outputBasePath,
"NETMetaCoderRewrittenCodeSyntax",
wrappers);
var codeTransformer = new CodeTransformer(codeWrapTransformationOptions);
foreach (var codeFilePath in testCodeFilePaths)
{
var _ = codeTransformer.Wrap(codeFilePath);
}
}
else
{
var x = new Namespace1.Namespace1__Class2();
x.Namespace1__Class2__Method3(new Class1());
var y = (IFace) x;
y.Kalua();
int i = 5;
Class1.Class1__Class1.Class1__Class1__Class3.StructInner<int>.StructInner__Method2<int, string, double>(
Task.FromResult("generics"), null, ref i);
#pragma warning disable 618
Console.WriteLine($"result = {Class1.StructOuter.StructOuter__Method4().GetAwaiter().GetResult()}");
#pragma warning restore 618
// var z = new Namespace1.Namespace1__Class2();
// z.Namespace1__Class2__Method3(new Class1());
//
// var w = (IFace) z;
// w.Kalua();
}
}
}
}