Output: Include using directives for assembly-level attribute namespaces

This commit is contained in:
Katy Coe
2019-11-12 05:46:33 +01:00
parent e83fc9fbb5
commit cec6c4aea7

View File

@@ -66,6 +66,12 @@ namespace Il2CppInspector
code.Append(text + "\n");
}
// Determine assemblies used in this file
var assemblies = types.Select(t => t.Assembly).Distinct();
// Add assembly attribute namespaces to reference list
nsRefs.UnionWith(assemblies.SelectMany(a => a.CustomAttributes).Select(a => a.AttributeType.Namespace));
// Determine using directives (put System namespaces first)
var usings = nsRefs.OrderBy(n => (n.StartsWith("System.") || n == "System") ? "0" + n : "1" + n);
@@ -74,9 +80,6 @@ namespace Il2CppInspector
if (nsRefs.Any())
writer.Write("\n");
// Determine assemblies used in this file
var assemblies = types.Select(t => t.Assembly).Distinct();
// Output assembly information and attributes
writer.Write(generateAssemblyInfo(assemblies) + "\n\n");