Skip to content

Commit 9bee3c3

Browse files
committed
include internal types when finding relevant attributes
1 parent 3ad038c commit 9bee3c3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Contentless/Program.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private static (List<ImporterInfo>, List<string>) GetContentData() {
255255
try {
256256
if (assembly.IsDynamic)
257257
continue;
258-
foreach (var type in assembly.GetExportedTypes()) {
258+
foreach (var type in Program.GetTypes(assembly)) {
259259
var importer = (ContentImporterAttribute) type.GetCustomAttribute(typeof(ContentImporterAttribute), true);
260260
if (importer != null)
261261
importers.Add(new ImporterInfo(importer, type));
@@ -270,6 +270,15 @@ private static (List<ImporterInfo>, List<string>) GetContentData() {
270270
return (importers, processors);
271271
}
272272

273+
private static IEnumerable<Type> GetTypes(Assembly assembly) {
274+
try {
275+
return assembly.GetTypes();
276+
} catch (ReflectionTypeLoadException e) {
277+
// if we failed to load some types, still return the ones that were successful
278+
return e.Types.Where(t => t != null);
279+
}
280+
}
281+
273282
private static IEnumerable<OverrideInfo> GetOverrides(Dictionary<string, Override> config) {
274283
foreach (var entry in config)
275284
yield return new OverrideInfo(entry.Key, entry.Value);

0 commit comments

Comments
 (0)