#[Request] Make DisableAutoTypeRegistrationAttribute work on assembly level
1 messages · Page 1 of 1 (latest)
I think I have this working in my fork with a simple check in StaticTypeRegistryPostProcessor.cs
(TypeGenInfoList, SystemList) GatherTypeInformation()
{
var components = new HashSet<TypeReference>();
var typeGenInfoList = new TypeGenInfoList();
var systemList = new List<TypeReference>();
var invalidAutoSystems = new List<TypeDefinition>();
// It's possible for the whole assembly to disable auto creation so check for it
var disableAsmAutoCreation = AssemblyDefinition.CustomAttributes.Any(attr => attr.AttributeType.Name == "DisableAutoCreationAttribute");
var componentSystemBaseClass = AssemblyDefinition.MainModule.ImportReference(typeof(ComponentSystemBase)).Resolve();
var disableRegistration = AssemblyDefinition.CustomAttributes.Any(a => a.AttributeType.Name.Contains("DisableAutoTypeRegistrationAttribute"));
foreach (var type in AssemblyDefinition.MainModule.GetAllTypes())
{
if ((type.IsValueType() && !type.IsInterface && type.Interfaces.Count > 0) || !type.IsValueType())
{
// Generic components are handled below
if (type.HasGenericParameters) continue;
if (!disableRegistration && AddTypeToListIfSupported(components, type)) continue;```
applying this to all my authoring assemblies - so nice