Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3405362
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:29:47+00:00 2026-05-18T05:29:47+00:00

Im parsing through a type with Mono.Cecil. How can i check if the type

  • 0

Im parsing through a type with Mono.Cecil. How can i check if the type im parsing is accessing getter Methods of other classes?

For accessing the fields directly I have found a solution:

foreach (MethodDefinition method in type.Methods)
            {
                foreach (Instruction instruction in method.Body.Instructions)
                {

                    if (instruction.OpCode == OpCodes.Ldfld)
                    {
                        FieldReference field = instruction.Operand as FieldReference;



                        if (fields.Contains(field.ToString()) && !accesses.Contains(field.ToString()))
                        {
                            accesses.Add(field.ToString());
                            Console.WriteLine("Class " + type.Name + " accesses field " + field.Name + " of a foreign class.");
                        }

                    }
                }
            }

But how can I solve the problem if the field of another class is accessed by a getter method?

Or to simplify the question: how can i determine if a method is a getter method using CIL instructions? and how can i detect which field is returned?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:29:47+00:00Added an answer on May 18, 2026 at 5:29 am

    As Donnie suggests in the comments, getters and setters are just like any other methods. They can return pretty much whatever they want, be as complex as they want, etc. So whatever you will do will be at best, an educated guess.

    To begin with, you can have a look at the semantic attributes of the MethodDefinition. If it says that the method is a getter or a setter, at least you’ll know if it’s attached to a property.

    Now, you can also analyse the IL to try to find a certain pattern, like I did in my blog post about retrieving the backing field of a property. You’d have to adjust the code to use Mono.Cecil instead of Mono.Reflection, but it shouldn’t be a big deal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm finally parsing through wikipedias wiki text. I have the following type of text
I've been parsing through some log files and I've found that some of the
I have a parsing system for fixed-length text records based on a layout table:
I'm fetching the JSON timeline from twitter and parsing it through PHP. I then
( Almost exact duplicate of Keeping original format POST passing through AWK submitted by
When you're passing variables through your site using GET requests, do you validate (regular
I'm having issues passing arguments through run to the windows side To demonstrate, it
When running an MSI through the command line what does passing the arguement CHECKDB=FALSE
.NET XSLT engine allows passing objects to the XSLT processing engine through the AddExtensionObject
Parsing a text file in vb.net and need to locate the latitude and longitude

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.