浏览代码

Fix enumeration of assembly for CsharpToHLSL

/feature-ReflectionProbeFit
sebastienlagarde 7 年前
当前提交
99e8024a
共有 1 个文件被更改,包括 2 次插入66 次删除
  1. 68
      ScriptableRenderPipeline/Core/Editor/ShaderGenerator/CSharpToHLSL.cs

68
ScriptableRenderPipeline/Core/Editor/ShaderGenerator/CSharpToHLSL.cs


using System;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Visitors;
using ICSharpCode.NRefactory.Ast;

s_TypeName = new Dictionary<string, ShaderTypeGenerator>();
// Iterate over assemblyList, discover all applicable types with fully qualified names
var assemblyList = AssemblyEnumerator.EnumerateReferencedAssemblies(Assembly.GetCallingAssembly());
var assemblyList = AppDomain.CurrentDomain.GetAssemblies().ToList();
foreach (var assembly in assemblyList)
{

return null;
}
}
}
// Helper class to recursively enumerate assemblies referenced by the calling assembly, including unloaded ones
static class AssemblyEnumerator
{
public static List<Assembly> EnumerateReferencedAssemblies(Assembly assembly)
{
Dictionary<string, Assembly> referenced = assembly.GetReferencedAssembliesRecursive();
referenced[GetName(assembly.FullName)] = assembly;
return referenced.Values.ToList();
}
public static Dictionary<string, Assembly> GetReferencedAssembliesRecursive(this Assembly assembly)
{
s_Assemblies = new Dictionary<string, Assembly>();
InternalGetDependentAssembliesRecursive(assembly);
// Skip assemblies from GAC (@TODO: any reason we'd want to include them?)
var keysToRemove = s_Assemblies.Values.Where(
o => o.GlobalAssemblyCache == true).ToList();
foreach (var k in keysToRemove)
{
s_Assemblies.Remove(GetName(k.FullName));
}
return s_Assemblies;
}
private static void InternalGetDependentAssembliesRecursive(Assembly assembly)
{
// Load assemblies with newest versions first.
var referencedAssemblies = assembly.GetReferencedAssemblies()
.OrderByDescending(o => o.Version);
foreach (var r in referencedAssemblies)
{
if (string.IsNullOrEmpty(assembly.FullName))
{
continue;
}
if (s_Assemblies.ContainsKey(GetName(r.FullName)))
continue;
try
{
// Ensure that the assembly is loaded
var a = Assembly.Load(r.FullName);
s_Assemblies[GetName(a.FullName)] = a;
InternalGetDependentAssembliesRecursive(a);
}
catch
{
// Missing dll, ignore.
}
}
}
static string GetName(string name)
{
return name.Split(',')[0];
}
static Dictionary<string, Assembly> s_Assemblies;
}
}
正在加载...
取消
保存