0

I am trying to use SpatialFocus.MethodCache but with a static method rather than in an instance of a class. I am getting an error:

1>MSBUILD : warning : Fody/SpatialFocus.MethodCache: Class Test contains [Cache] attribute but does not contain a single property implementing IMemoryCache interface

Has anyone had success making this work?

public class Test
{
    static protected IMemoryCache MemoryCache { get; }

    [Cache]
    static string Test()
    {
        return "hello";
    }
}
2
  • 1
    Can't confirm or deny if it should or can work but consider "static" to be the new "goto". If you need it its almost always not the right thing to do. I would assume the implementor of the feature you try to use here doesn't even considered it as valid use case and so it will just not work even when maybe possible(or rather easy implementable in the current code). Commented May 28, 2024 at 13:15
  • Is it working correctly for non-static method? If yes, do not use static, consider singleton instead Commented Jun 4, 2024 at 2:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.