Skip to content

AccessPublicizedMemberAnalyzer threw an exception of type 'System.IndexOutOfRangeException' #7

@myocytebd

Description

@myocytebd

BepinEx 5.4.21.0

All of a sudden, AccessPublicizedMemberAnalyzer starts to throw this exception:

Warning AD0001: Analyzer 'BepInEx.Analyzers.AccessPublicizedMemberAnalyzer' threw an exception of type 'System.IndexOutOfRangeException' with message 'Index was outside the bounds of the array.'. (AD0001)

After some bisecting, I think it is due to this code. (Not verified in a standalone project)

// [assembly: IgnoresAccessChecksTo("UnityEngine")] is in another file.
// UnityEngine.ResourceRequest.asset getter
[HarmonyPrefix, HarmonyPatch(typeof(ResourceRequest), nameof(ResourceRequest.asset), MethodType.Getter)]
public static bool ResourceRequest_get_asset(out UnityEngine.Object __result, ResourceRequest __instance) {
    __result = Resources.Load(__instance.m_Path, __instance.m_Type);  // AccessPublicizedMemberAnalyzer dislike this line
    return false;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions