Skip to content

Refactor AOTCompilerTools to hide implementation #800

Closed
@dmanning23

Description

@dmanning23

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Description

This is related to a lot of the AOT -> JIT bugs that have been written lately... I've been looking into iOS AOT errors more, and found some documentation of how to solve them (in the Unity docs of all places):

https://docs.unity3d.com/Manual/ScriptingRestrictions.html

ImageSharp has the AOTCompilerTools.Seed<TPixel>() method that can be called to pre-seed the AOT compiler, however that method never actually has to be called. I've verified that a call to that method only has to exist in the codebase with the correct generic type, and the AOT compiler will pick it up:

private static void NeverCallThisMethod()
        {
            AotCompilerTools.Seed<Rgba32>();
            throw new Exception("Don't call AotCompilerTools.NeverCallThisMethod(), it only exists to preseed the AOT compiler.");
        }

^ This totally works, and wouldn't force ImageSharp users to use troubleshoot confusing AOT compiler errors. I'd be happy to clean up this code and create a PR for it.

Steps to Reproduce

System Configuration

  • ImageSharp version: This is on the tip of master
  • Other ImageSharp packages and versions:
  • Environment (Operating system, version and so on): iOS
  • .NET Framework version:
  • Additional information:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions