{"record":{"id":"a1e7e52a71ee4181","repo":"pardeike/Harmony","slug":"unknown-member-type-member-membertype","errorCode":null,"errorMessage":"Unknown member type: {member.MemberType}","messagePattern":"Unknown member type: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Harmony/Tools/AccessTools.cs","lineNumber":2356,"sourceCode":"#pragma warning disable IDE0060\r\n\t\tpublic static bool IsOfNullableType<T>(T instance) => Nullable.GetUnderlyingType(typeof(T)) is not null;\r\n\r\n\t\t/// <summary>Tests whether a type or member is static, as defined in C#</summary>\r\n\t\t/// <param name=\"member\">The type or member</param>\r\n\t\t/// <returns>True if the type or member is static</returns>\r\n\t\t///\r\n\t\tpublic static bool IsStatic(MemberInfo member)\r\n\t\t{\r\n\t\t\tif (member is null)\r\n\t\t\t\tthrow new ArgumentNullException(nameof(member));\r\n\t\t\treturn member.MemberType switch\r\n\t\t\t{\r\n\t\t\t\tMemberTypes.Constructor or MemberTypes.Method => ((MethodBase)member).IsStatic,\r\n\t\t\t\tMemberTypes.Event => IsStatic((EventInfo)member),\r\n\t\t\t\tMemberTypes.Field => ((FieldInfo)member).IsStatic,\r\n\t\t\t\tMemberTypes.Property => IsStatic((PropertyInfo)member),\r\n\t\t\t\tMemberTypes.TypeInfo or MemberTypes.NestedType => IsStatic((Type)member),\r\n\t\t\t\t_ => throw new ArgumentException($\"Unknown member type: {member.MemberType}\"),\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\t/// <summary>Tests whether a type is static, as defined in C#</summary>\r\n\t\t/// <param name=\"type\">The type</param>\r\n\t\t/// <returns>True if the type is static</returns>\r\n\t\t///\r\n\t\t[EditorBrowsable(EditorBrowsableState.Never)]\r\n\t\tpublic static bool IsStatic(Type type)\r\n\t\t{\r\n\t\t\tif (type is null)\r\n\t\t\t\treturn false;\r\n\t\t\treturn type.IsAbstract && type.IsSealed;\r\n\t\t}\r\n\r\n\t\t/// <summary>Tests whether a property is static, as defined in C#</summary>\r\n\t\t/// <param name=\"propertyInfo\">The property</param>\r\n\t\t/// <returns>True if the property is static</returns>\r","sourceCodeStart":2338,"sourceCodeEnd":2374,"githubUrl":"https://github.com/pardeike/Harmony/blob/e7872dc17008bc0ca2b3de1f53fd4120dbd7a17c/Harmony/Tools/AccessTools.cs#L2338-L2374","documentation":"AccessTools.IsStatic(MemberInfo) throws ArgumentException('Unknown member type') when it receives a MemberInfo whose MemberType is none of Constructor, Method, Event, Field, Property, TypeInfo, or NestedType. Harmony has no staticness rule for that member kind, so it refuses to guess.","triggerScenarios":"Calling AccessTools.IsStatic(member) with a MemberInfo of an unhandled kind - practically this means new/obscure MemberTypes values (e.g. synthetized members) or a wrongly constructed MemberInfo.","commonSituations":"Writing generic reflection code that passes arbitrary MemberInfo (e.g. from member.MemberType filtering mistakes) into IsStatic; future .NET runtimes introducing member kinds Harmony does not yet handle.","solutions":["Check member.MemberType before calling IsStatic and handle unsupported kinds yourself.","For unsupported kinds, fall back to manual inspection (e.g. 'IsStatic'-style property of the concrete info type).","Upgrade Harmony if a new MemberType from a newer runtime is the cause."],"exampleFix":"// before\nvar isStatic = AccessTools.IsStatic(anyMember);\n// after\nvar isStatic = anyMember.MemberType is MemberTypes.Method or MemberTypes.Field or MemberTypes.Property or MemberTypes.Event or MemberTypes.Constructor or MemberTypes.TypeInfo or MemberTypes.NestedType\n    ? AccessTools.IsStatic(anyMember)\n    : false;","handlingStrategy":"type-guard","validationCode":"switch (member) { case MethodBase: case FieldInfo: case PropertyInfo: case EventInfo: case Type: break; default: return false; }","typeGuard":"bool IsSupportedMember(MemberInfo m) => m is MethodBase or FieldInfo or PropertyInfo or EventInfo or Type;","tryCatchPattern":"try { var s = AccessTools.IsStatic(member); }\ncatch (ArgumentException) { /* unsupported MemberType; handle manually */ }","preventionTips":["Filter MemberInfo collections to supported kinds before calling IsStatic.","Handle MemberTypes explicitly in generic reflection code.","Keep Harmony updated for new runtime member kinds."],"tags":["reflection","unsupported-type","harmony"],"backgroundTag":"unsupported-enum-value","analyzedSha":"e7872dc17008bc0ca2b3de1f53fd4120dbd7a17c","analyzedAt":"2026-09-15T22:47:11.550Z","contentChangedAt":"2026-09-15T22:47:11.550Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}