Giter Site home page Giter Site logo

methodcache's People

Contributors

dresel avatar simoncropp avatar tpluscode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

methodcache's Issues

No xamarin compatibility

It's a pity the last package does not work in Xamarin PCL projects (.net profile78). Annotation is not recognized.
Do you have some glue to let it work ?

Don't add "readme.txt" to a project

Instead bundle the readme with your lib:

<file src="readme.txt" target="" />

This will automatically display the file during installation.

CacheAttribute not removed

I've just found out that the [Cache] attribute is not removed from a class, when there was no methods found for rewriting.

In my example I wanted to add caching to a class which has only properties and because no method was found, the attribute wasn't removed.

Update to Fody Version 2

Fody Version 2 is out and you will need to do an update for your addin to be usable with it

Specifically:

  • Update to the newest Fody.Cecil nuget
  • Change the min dependency range for Fody to be at least 2.0

Please ping me if u need help

Add array values arguments of methods for cache-key generation

Hello,
Cache-key don't support array values :

Example :
public object[] TestMethod(object[] parameters)
{
return parameters;
}

The result is the same whatever the values contained in the array :
CollectionAssert.AreNotEquivalent(classTest.Method3(new object[] { 1, 2 }), classTest.Method3(new object[] { 2, 1 }));
=> The result is always object[] { 1, 2 }

Best regards,

Uncaught exception on auto-generated read-only property

If I try to run this on a class that contains an auto-generated read-only property (ie. no setter), it fails with an uncaught exception. The problem appears to be in the file MethodCache.Fody/ModuleWeaver.cs line 438:

bool hasSetAccessor = property.GetMethod != null;

Should be:

bool hasSetAccessor = property.SetMethod != null;

Dont assembly scan for lookup types

I notice you do an assembly scan to lookup CacheAttribute (for example). This is not required and will actually negatively impact the performance of you weaver.

Instead just scan the attributes of a method and do a string match on the attribute type name for "CacheAttribute"

Generics bug

This code crashes with Unhandled Exception: System.InvalidOperationException: Could not execute the method because either the method itself or the containing type is not fully instantiated.

using MethodCache.Attributes;
using System.Collections.Generic;

namespace ReproduceBug
{
    public class Bug<T>
    {
        [Cache]
        public string Execute(T input)
        {
            return input.ToString();
        }

        public DictionaryCache Cache => new DictionaryCache();
    }

    public class DictionaryCache
    {
        private readonly Dictionary<string, object> _cache = new Dictionary<string, object>();
        public void Remove(string key) => _cache.Remove(key);
        public void Store(string key, object value) => _cache[key] = value;
        public T Retrieve<T>(string key) => (T)_cache[key];
        public bool Contains(string key) => _cache.ContainsKey(key);
    }

    class Program
    {
        static void Main(string[] args)
        {
            var bug = new Bug<int>();
            bug.Execute(0);
        }
    }
}

FodyHelpers >= 3.0.0

Mind upgrading ur FodyHelpers to >= 3.0.0?

Getting this with ur latest Alpha1:
Fody: The weaver assembly 'MethodCache.Fody, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' references an out of date version of Mono.Cecil.dll. Expected strong name token of '1C-A0-91-87-7D-12-CA-03' but got '50-CE-BF-1C-CE-B9-D0-5E'. The weaver needs to update to at least version 3.0 of FodyHelpers.

Static method support

Why static method caching is not supported ?
If it is please tell me how can I do it.

Allow caching of properties

Hi as I mentioned in issue #5 I have just discovered the it is not possible cache properties.

I suppose that is due to the fact the they combine both read and write methods so that that it is difficult to determine when to invalidate a cache key. However there is no guarantee that a method's return would not change due to some side effects of another method and in such situation the cache would indeed return stale data just as well.

Given the above I think it's worth extending MethodCache with support for properties in two steps:

  1. Add support for readonly properties - these are nothing more than a different syntax for methods.
  2. Add support for writable properties. For a reasonable implementation something like a Remove(key) method should be added to invalidate cache whenever the property setter is invoked

I think I sould be able to help with step 1...

What do you think?

Problem when using MethodCache on a 3.5 assembly

Hello,

When using MethodCache on a 3.5 assembly, a reference to mscorlib 4.0 seems to be added to the assembly.

If the debug messages are enabled, a reference to System 4.0 is added too, and I get a FileNotFoundException saying that System 4.0 can't be found.

I'm not sure if older versions of .NET are supported or not, so maybe it is just a matter of indicating it in the readme.

Best regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.