13
13
using Microsoft . CodeAnalysis . CSharp . Syntax ;
14
14
using Microsoft . CodeAnalysis . FindSymbols ;
15
15
using Microsoft . CodeAnalysis . MSBuild ;
16
+ using Microsoft . CodeAnalysis . Text ;
16
17
using NHibernate . AsyncGenerator . Extensions ;
17
18
using Nito . AsyncEx ;
18
19
@@ -104,6 +105,7 @@ public async Task Generate(WriterConfiguration configuration)
104
105
{
105
106
continue ;
106
107
}
108
+
107
109
var config = projectConfigs [ projectOrig . Name ] ;
108
110
var projectInfo = new ProjectInfo ( this , projectOrig . Id , config ) ;
109
111
ProjectInfos . Add ( projectInfo ) ;
@@ -128,40 +130,23 @@ public async Task Generate(WriterConfiguration configuration)
128
130
project = project . GetDocument ( docInfo . Document . Id ) . WithSyntaxRoot ( result . OriginalRootNode ) . Project ;
129
131
}
130
132
var folders = new List < string > { projectInfo . Configuration . AsyncFolder } . Union ( docInfo . Folders ) ;
131
- project = project . AddDocument ( docInfo . Name , result . NewRootNode , folders , $ "{ writer . DestinationFolder } \\ { docInfo . Name } ") . Project ;
133
+ project = project . AddDocument ( docInfo . Name , result . NewRootNode . GetText ( Encoding . UTF8 ) , folders , $ "{ writer . DestinationFolder } \\ { docInfo . Name } ") . Project ;
132
134
Solution = project . Solution ;
133
135
}
134
136
137
+ //var origCompilation = await projectOrig.GetCompilationAsync();
138
+ //var origEmit = origCompilation.Emit("output.exe", "output.pdb");
139
+ //var origDiagnostincs = origEmit.Diagnostics;
140
+ //var compilation = await project.GetCompilationAsync();
141
+ //var emit = compilation.Emit("output2.exe", "output2.pdb");
142
+ //var diagnostincs = emit.Diagnostics;
143
+ ////var diagnostincs = compilation.GetDeclarationDiagnostics();
144
+ //foreach (var diagnostic in diagnostincs)
145
+ //{
146
+ //}
147
+
135
148
ProjectInfos . Clear ( ) ;
136
149
}
137
-
138
- //foreach (var projectInfo in ProjectInfos)
139
- //{
140
- // var modifiedProject = projectInfo.RemoveGeneratedDocuments();
141
- // Solution = modifiedProject.Solution; // update solution as it is immutable
142
- // await projectInfo.Analyze().ConfigureAwait(false);
143
- // projectInfo.PostAnalyze();
144
-
145
- // var project = projectInfo.Project;
146
-
147
- // foreach (var pair in projectInfo.Where(o => o.Value.Any()))
148
- // {
149
- // var docInfo = pair.Value;
150
- // var writer = new DocumentWriter(docInfo, configuration);
151
- // var result = writer.Transform();
152
- // if (result == null)
153
- // {
154
- // continue;
155
- // }
156
- // if (result.OriginalRootNode != null)
157
- // {
158
- // project = project.GetDocument(docInfo.Document.Id).WithSyntaxRoot(result.OriginalRootNode).Project;
159
- // }
160
- // var folders = new List<string> { projectInfo.Configuration.AsyncFolder }.Union(docInfo.Folders);
161
- // project = project.AddDocument(docInfo.Name, result.NewRootNode, folders, $"{writer.DestinationFolder}\\{docInfo.Name}").Project;
162
- // Solution = project.Solution;
163
- // }
164
- //}
165
150
Workspace . TryApplyChanges ( Solution ) ;
166
151
}
167
152
}
@@ -320,28 +305,28 @@ static void Main(string[] args)
320
305
{
321
306
ProjectConfigurations =
322
307
{
323
- // new ProjectConfiguration("NHibernate")
324
- // {
325
- // ScanMethodsBody = true,
326
- // IgnoreExternalReferences = true,
327
- // MethodConversionFunc = symbol =>
328
- // {
329
- // if (symbol.GetAttributes().Any(a => a.AttributeClass.Name == "AsyncAttribute"))
330
- // {
331
- // return MethodAsyncConversion.ToAsync;
332
- // }
333
- // return MethodAsyncConversion.None;
334
- // },
335
- // FindAsyncCounterpart = findAsyncFn
336
- // },
337
-
338
- // new ProjectConfiguration("NHibernate.DomainModel")
339
- // {
340
- // ScanMethodsBody = true,
341
- // IgnoreExternalReferences = true,
342
- // ScanForMissingAsyncMembers = true,
343
- // FindAsyncCounterpart = findAsyncFn
344
- // },
308
+ new ProjectConfiguration ( "NHibernate" )
309
+ {
310
+ ScanMethodsBody = true ,
311
+ IgnoreExternalReferences = true ,
312
+ MethodConversionFunc = symbol =>
313
+ {
314
+ if ( symbol . GetAttributes ( ) . Any ( a => a . AttributeClass . Name == "AsyncAttribute" ) )
315
+ {
316
+ return MethodAsyncConversion . ToAsync ;
317
+ }
318
+ return MethodAsyncConversion . None ;
319
+ } ,
320
+ FindAsyncCounterpart = findAsyncFn
321
+ } ,
322
+
323
+ new ProjectConfiguration ( "NHibernate.DomainModel" )
324
+ {
325
+ ScanMethodsBody = true ,
326
+ IgnoreExternalReferences = true ,
327
+ ScanForMissingAsyncMembers = true ,
328
+ FindAsyncCounterpart = findAsyncFn
329
+ } ,
345
330
346
331
new ProjectConfiguration ( "NHibernate.Test" )
347
332
{
0 commit comments