Giter Site home page Giter Site logo

Comments (9)

reflection-emit avatar reflection-emit commented on August 9, 2024 2

coming in 2.0.30

from cauldron.

reflection-emit avatar reflection-emit commented on August 9, 2024

from cauldron.

mfkl avatar mfkl commented on August 9, 2024

This link could be of interest: https://github.com/tom-englert/AutoProperties.Fody/blob/master/BackingFieldAccess.md

from cauldron.

reflection-emit avatar reflection-emit commented on August 9, 2024

Thanks for the link... But I don't think this is the same issue... Getting the backing fields of Auto-Properties is very easy, because of their naming convention. But getting the backing field of "custom" properties is another thing... Constructs like the following (Which I have seen already) make it a lot harder:

private int languageIndex;
public string LanguageName { get{ return Language[languageIndex]; } }
public int? LanguageIndex
{
   get { return languageIndex; }
   set {
            if(value == null || Language.Length < value)
                   return;
           languageIndex = value;
          }
}

The first property is something I wont be able to intercept at all, because I would have a hard time getting the backing field. I can surely just pass Language[languageIndex] to the interceptor. This requires a different logic than the current one though.
The second property is easier... I can get the backing field from the getter... I have only to make sure that it also exists and used in the setter. But there will be some stuff going on with Nullable in there, which does not make it easy to get the proper field.
That is only one example of all possibilities that can be done with getter and setter... I can implement some of the more standard ones... Like the following:

private string backingField;
public string Property
{ 
   get{ return backingField; }
   set{ 
             if(backingField == value)
                return;
             backingField = value;
        }
}

This case is actually easy to detect.

from cauldron.

reflection-emit avatar reflection-emit commented on August 9, 2024

Btw.. I did some testing... The last example works with the current implementation. I may add it in the next release.

from cauldron.

mfkl avatar mfkl commented on August 9, 2024

Great. Is support for constructor interception something you may be interested in?
FYI, I'm using your package to do native DLL version checks with attributes. https://github.com/mfkl/LibVLCSharp/blob/master/LibVlcSharp/LibVLC.cs

from cauldron.

reflection-emit avatar reflection-emit commented on August 9, 2024

from cauldron.

reflection-emit avatar reflection-emit commented on August 9, 2024

I will leave this open for a maybe better implementation of backing-field detection.

from cauldron.

Kazpers avatar Kazpers commented on August 9, 2024

Perhaps focus on property interception for computed properties (ie. no backing field)?

from cauldron.

Related Issues (20)

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.