Coder Social home page Coder Social logo

Comments (4)

jbevain avatar jbevain commented on September 22, 2024

It's possible that you're hitting an indexer. Currently GetBackingField works only for traditional properties. Could you paste the code of the property that triggers the exception ?

from mono.reflection.

joergbattermann avatar joergbattermann commented on September 22, 2024

Oh now that was quick :)

The property & backingfield are the following:

private string _department;

    /// <summary>
    /// Gets or sets the department.
    /// </summary>
    /// <value>The department.</value>
    public string Department
    {
        get
        {
            Activate(ActivationPurpose.Read);
            return _department;
        }
        set
        {
            Activate(ActivationPurpose.Write);
            _department = value;
        }
    }

(it's using db4o's transparent activation mechanism in the Property there)

from mono.reflection.

jbevain avatar jbevain commented on September 22, 2024

GetBackingField reads the IL of the property to find a certain pattern, specific to simple properties. As you have calls to methods in them, they stop being simple properties.

Now, it's possible to write a custom IL pattern to look for. That's your lucky day, I already wrote the pattern for db4o properties here:

http://source.db4o.com/db4o/trunk/db4o.net/Db4objects.Db4o.Linq/Db4objects.Db4o.Linq/CodeAnalysis/ReflectionMethodAnalyser.cs

from mono.reflection.

joergbattermann avatar joergbattermann commented on September 22, 2024

Nice! Thanks Jean-Baptiste for the quick help!

from mono.reflection.

Related Issues (17)

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.