yasirkula / UnityAssetUsageDetector

Find usages of the selected asset(s) and/or Object(s) in your Unity project, i.e. list the objects that refer to them
MIT License
1.73k stars 118 forks source link

Exception on search: ArgumentException: The type 'System.Void*' may not be used as a type argument. #15

Closed rotter closed 5 years ago

rotter commented 5 years ago

Im getting an exception on this line when I perform a search on any asset:

https://github.com/yasirkula/UnityAssetUsageDetector/blob/3719ce747355b031e8841f9d1c19eda42379bf0a/Plugins/AssetUsageDetector/Editor/Utilities.cs#L353

I really dont know what is special about this project Im getting the error. On my other projects (which are on the same Unity version: 2019.2.6) it's working fine. If I reset the search and re-do it, I get the error again. I also get the error when context-right-clicking to start a search. I get the error on any asset I try searching.

Im using the latest version of the plugin (1.5.2 if I recall correctly)

Full stack trace:

ArgumentException: The type 'System.Void*' may not be used as a type argument.

System.RuntimeType.ThrowIfTypeNeverValidGenericArgument (System.RuntimeType type) (at <599589bf4ce248909b8a14cbe4a2034e>:0) System.RuntimeType.SanityCheckGenericArguments (System.RuntimeType[] genericArguments, System.RuntimeType[] genericParamters) (at <599589bf4ce248909b8a14cbe4a2034e>:0) System.RuntimeType.MakeGenericType (System.Type[] instantiation) (at <599589bf4ce248909b8a14cbe4a2034e>:0) AssetUsageDetectorNamespace.Extras.Utilities.CreateGetter (System.Reflection.PropertyInfo propertyInfo) (at Assets/Plugins/AssetUsageDetector/Editor/Utilities.cs:353) AssetUsageDetectorNamespace.AssetUsageDetector.GetFilteredVariablesForType (System.Type type) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:1233) AssetUsageDetectorNamespace.AssetUsageDetector.SearchFieldsAndPropertiesOf (AssetUsageDetectorNamespace.ReferenceNode referenceNode) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:1096) AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:800) AssetUsageDetectorNamespace.AssetUsageDetector.SearchFieldsAndPropertiesOf (AssetUsageDetectorNamespace.ReferenceNode referenceNode) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:1116) AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:800) AssetUsageDetectorNamespace.AssetUsageDetector.SearchFieldsAndPropertiesOf (AssetUsageDetectorNamespace.ReferenceNode referenceNode) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:1116) AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:800) AssetUsageDetectorNamespace.AssetUsageDetector.SearchFieldsAndPropertiesOf (AssetUsageDetectorNamespace.ReferenceNode referenceNode) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:1116) AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:800) AssetUsageDetectorNamespace.AssetUsageDetector.SearchFieldsAndPropertiesOf (AssetUsageDetectorNamespace.ReferenceNode referenceNode) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:1116) AssetUsageDetectorNamespace.AssetUsageDetector.SearchComponent (UnityEngine.Object unityObject) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:910) AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:781) AssetUsageDetectorNamespace.AssetUsageDetector.SearchGameObject (UnityEngine.Object unityObject) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:842) AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:779) AssetUsageDetectorNamespace.AssetUsageDetector.BeginSearchObject (UnityEngine.Object obj) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:719) AssetUsageDetectorNamespace.AssetUsageDetector.SearchGameObjectRecursively (UnityEngine.GameObject go) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:704) AssetUsageDetectorNamespace.AssetUsageDetector.SearchScene (System.String scenePath, System.Collections.Generic.List1[T] searchResult, UnityEditor.SceneManagement.SceneSetup[] initialSceneSetup) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:670) AssetUsageDetectorNamespace.AssetUsageDetector.Run (AssetUsageDetectorNamespace.AssetUsageDetector+Parameters searchParameters) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:536) UnityEngine.Debug:LogException(Exception) AssetUsageDetectorNamespace.AssetUsageDetector:Run(Parameters) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:565) AssetUsageDetectorNamespace.Extras.AssetUsageDetectorWindow:InitiateSearch() (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs:529) AssetUsageDetectorNamespace.Extras.AssetUsageDetectorWindow:ShowAndSearchInternal(IEnumerable1, Parameters) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs:166) AssetUsageDetectorNamespace.Extras.AssetUsageDetectorWindow:ShowAndSearch(IEnumerable`1) (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs:100) AssetUsageDetectorNamespace.Extras.AssetUsageDetectorWindow:SearchSelectedAssetReferences() (at Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs:87)

yasirkula commented 5 years ago

Will definitely check it out, thanks.

yasirkula commented 5 years ago

I can't understand how DeclaringType or PropertyType of a property can be void. Although I can resolve this issue by adding some if conditions, I'm super duper curious about this property. I'd really appreciate it if you could add a Debug.Log statement prior to the problematic line and check out the Name, DeclaringType, PropertyType and etc. values of the propertyInfo so that we can identify it and learn more about it.

P.S. Oh nevermind. After enabling "Allow 'unsafe' Code" in Player Settings and declaring a "unsafe public void* A { get; set; }" property, I was able to reproduce the issue. My curiosity is satisfied.

rotter commented 5 years ago

Here is the Log:

propertyInfo.Name[currentStatePtr] DeclType[UnityEngine.InputSystem.InputControl] PropType[System.Void] Method[Void get_currentStatePtr()]

Maybe it's related to the New Input System? The weird thing is that the other projects which dont crash also use the NIS.

yasirkula commented 5 years ago

Thank you for the super quick answer!

rotter commented 5 years ago

On my Player Settings "Allow 'unsafe' Code" is disabled (never used it), but maybe it's enabled on some library I use, or something, not sure.

yasirkula commented 5 years ago

Fixed in https://github.com/yasirkula/UnityAssetUsageDetector/commit/e3dc45b917edaeb71cd7c408cfef0766fa886ba2