Closed xiaoxiao921 closed 1 year ago
https://discord.com/channels/562704639141740588/562704639569428506/1150855528805826570
Pretty sure this is the case. Did some testing, it seems that GetCustomAttributes and all its variants return a new instance of the attribute each time it's called, so modifying the dependencies won't change anything: var attr1 = typeof(SkinCatalog).GetMethod("Init", BindingFlags.Static | BindingFlags.NonPublic).GetCustomAttribute<SystemInitializerAttribute>(false); var attr2 = typeof(SkinCatalog).GetMethod("Init", BindingFlags.Static | BindingFlags.NonPublic).GetCustomAttribute<SystemInitializerAttribute>(false); if (attr1 != attr2) { Log.Debug("Problem"); } ArrayUtils.ArrayAppend(ref attr1.dependencies, typeof(DynamicSkinAdder)); Log.Debug("attr1: " + attr1.dependencies.Length); Log.Debug("attr2: " + attr2.dependencies.Length); [Debug :ModelSwapperSkins] Main.cs:32 (Awake) Problem [Debug :ModelSwapperSkins] Main.cs:37 (Awake) attr1: 2 [Debug :ModelSwapperSkins] Main.cs:38 (Awake) attr2: 1
Pretty sure this is the case. Did some testing, it seems that GetCustomAttributes and all its variants return a new instance of the attribute each time it's called, so modifying the dependencies won't change anything:
var attr1 = typeof(SkinCatalog).GetMethod("Init", BindingFlags.Static | BindingFlags.NonPublic).GetCustomAttribute<SystemInitializerAttribute>(false); var attr2 = typeof(SkinCatalog).GetMethod("Init", BindingFlags.Static | BindingFlags.NonPublic).GetCustomAttribute<SystemInitializerAttribute>(false); if (attr1 != attr2) { Log.Debug("Problem"); } ArrayUtils.ArrayAppend(ref attr1.dependencies, typeof(DynamicSkinAdder)); Log.Debug("attr1: " + attr1.dependencies.Length); Log.Debug("attr2: " + attr2.dependencies.Length);
[Debug :ModelSwapperSkins] Main.cs:32 (Awake) Problem [Debug :ModelSwapperSkins] Main.cs:37 (Awake) attr1: 2 [Debug :ModelSwapperSkins] Main.cs:38 (Awake) attr2: 1
https://discord.com/channels/562704639141740588/562704639569428506/1150855528805826570