我正在尝试编译解决方案,但在尝试保存时收到一条模糊的错误消息。
匿名类型 <>__blahblah 未完成
但是在编译的源代码中没有任何匿名类型。
代码是
private static void Compile(ISolution solution)
{
var workspaceServices = (IHaveWorkspaceServices)solution;
var projectDependencyService = workspaceServices.WorkspaceServices.GetService<IProjectDependencyService>();
foreach (var projectId in projectDependencyService.GetDependencyGraph(solution).GetTopologicallySortedProjects())
{
var currentDomain = AppDomain.CurrentDomain;
var assemblyName = new AssemblyName();
assemblyName.Name = "Most." + solution.GetProject(projectId).AssemblyName;
var assemblyBuilder = currentDomain.DefineDynamicAssembly
(assemblyName, AssemblyBuilderAccess.RunAndSave);
var moduleBuilder = assemblyBuilder.
DefineDynamicModule(assemblyName.Name);
var types = moduleBuilder.GetTypes();
types.Aggregate((ts, t) =>
{
var tb = t as TypeBuilder;
return tb.CreateType();
});
solution.GetProject(projectId).GetCompilation().Emit(moduleBuilder);
assemblyBuilder.Save(assemblyName.Name);
}
}