Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Tweaking Reflector output

Tweaking Reflector output

Scheduled Pinned Locked Moved The Lounge
helpquestioncsharpvisual-studiowinforms
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dlarkin77
    wrote on last edited by
    #1

    Hi, This isn't really a programming question (at least I don't think it is). It's a question about Reflector. I have a windows forms application that uses a listview. I have some code that gets a list of the checked items in the listview and does some stuff.

    private void button1_Click(object sender, EventArgs e)
    {
    string names = "";
    for (int i = 0; i < listView1.CheckedItems.Count; i++)
    {
    names += "\n" + listView1.Items[i].Text;
    }
    MessageBox.Show("Selected Names = " + names);
    }

    When I look at the compiled executable in Reflector this code is disassembled as

    private void button1_Click(object sender, EventArgs e)
    {
    string str = "";
    for (int i = 0; i < this.listView1.get_CheckedItems().get_Count(); i++)
    {
    str = str + "\n" + this.listView1.Items[i].Text;
    }
    MessageBox.Show("Selected Names = " + str);
    }

    I'm using the File Generator plugin to recreate the Visual Studio project. The generated project cannot be compiled. Compilation fails with the following error "'System.Windows.Forms.ListView.CheckedItems.get': cannot explicitly call operator or accessor". Fair enough. Now to the question: Is there anyway to have Reflector disassemble the application so that I don't get these compiler errors? I've tried settings various options but I can't get it to work. The reason I need this is that a customer has reported a bug in a really old version of our application. We don't have a copy of the source code for this application so I'm using Reflector to generate the files. The generated project fails to compile with the error mentioned above. I know that I can manually tweak the generated files but there are about 8000 lines that I would need to change. If there is no way to change how Reflector outputs the code, can anyone recommend how to work around this problem? Thanks, dlarkin77

    G 1 Reply Last reply
    0
    • D dlarkin77

      Hi, This isn't really a programming question (at least I don't think it is). It's a question about Reflector. I have a windows forms application that uses a listview. I have some code that gets a list of the checked items in the listview and does some stuff.

      private void button1_Click(object sender, EventArgs e)
      {
      string names = "";
      for (int i = 0; i < listView1.CheckedItems.Count; i++)
      {
      names += "\n" + listView1.Items[i].Text;
      }
      MessageBox.Show("Selected Names = " + names);
      }

      When I look at the compiled executable in Reflector this code is disassembled as

      private void button1_Click(object sender, EventArgs e)
      {
      string str = "";
      for (int i = 0; i < this.listView1.get_CheckedItems().get_Count(); i++)
      {
      str = str + "\n" + this.listView1.Items[i].Text;
      }
      MessageBox.Show("Selected Names = " + str);
      }

      I'm using the File Generator plugin to recreate the Visual Studio project. The generated project cannot be compiled. Compilation fails with the following error "'System.Windows.Forms.ListView.CheckedItems.get': cannot explicitly call operator or accessor". Fair enough. Now to the question: Is there anyway to have Reflector disassemble the application so that I don't get these compiler errors? I've tried settings various options but I can't get it to work. The reason I need this is that a customer has reported a bug in a really old version of our application. We don't have a copy of the source code for this application so I'm using Reflector to generate the files. The generated project fails to compile with the error mentioned above. I know that I can manually tweak the generated files but there are about 8000 lines that I would need to change. If there is no way to change how Reflector outputs the code, can anyone recommend how to work around this problem? Thanks, dlarkin77

      G Offline
      G Offline
      Gary Wheeler
      wrote on last edited by
      #2

      Sounds like a candidate for a good global find/replace with a regular expression or two and some manual editting. 8,000 lines really isn't that big, if you only need to do it once.

      Software Zen: delete this;

      D 1 Reply Last reply
      0
      • G Gary Wheeler

        Sounds like a candidate for a good global find/replace with a regular expression or two and some manual editting. 8,000 lines really isn't that big, if you only need to do it once.

        Software Zen: delete this;

        D Offline
        D Offline
        dlarkin77
        wrote on last edited by
        #3

        Yeah I figured I'd probably have to take this route. I'm a bit confused as to how to actually replace text using a regular expression. Finding the text I need to replace should be pretty straight forward - I could search for get_*() This would find two matches: get_CheckedItems() and get_Count() But how can I use a regular expression to replace the get_ and the () for each match? Thanks.

        G 1 Reply Last reply
        0
        • D dlarkin77

          Yeah I figured I'd probably have to take this route. I'm a bit confused as to how to actually replace text using a regular expression. Finding the text I need to replace should be pretty straight forward - I could search for get_*() This would find two matches: get_CheckedItems() and get_Count() But how can I use a regular expression to replace the get_ and the () for each match? Thanks.

          G Offline
          G Offline
          Gary Wheeler
          wrote on last edited by
          #4

          Using Visual Studio, set your find string to:

          \.get_{:i}\(\)

          and your replace string to:

          .\1

          and make sure that 'regular expressions' is selected in the find options. The find string is translated as "find a literal period, followed by 'get_', followed by an identifier (which is tagged), followed by a literal left parenthesis, followed by a literal right parenthesis". The replace string is translated as "a literal period, followed by the identifier tagged in the find expression". I strongly recommend against using "Replace all" with this. I would do these one at a time, so you can confirm the changes.

          Software Zen: delete this;

          D 1 Reply Last reply
          0
          • G Gary Wheeler

            Using Visual Studio, set your find string to:

            \.get_{:i}\(\)

            and your replace string to:

            .\1

            and make sure that 'regular expressions' is selected in the find options. The find string is translated as "find a literal period, followed by 'get_', followed by an identifier (which is tagged), followed by a literal left parenthesis, followed by a literal right parenthesis". The replace string is translated as "a literal period, followed by the identifier tagged in the find expression". I strongly recommend against using "Replace all" with this. I would do these one at a time, so you can confirm the changes.

            Software Zen: delete this;

            D Offline
            D Offline
            dlarkin77
            wrote on last edited by
            #5

            Excellent. That seems to be working just fine - (I really do need to get a handle on the whole regular expressions thing, I seriously doubt I would have been to figure this out on my own). Thanks very much, dlarkin77

            G 1 Reply Last reply
            0
            • D dlarkin77

              Excellent. That seems to be working just fine - (I really do need to get a handle on the whole regular expressions thing, I seriously doubt I would have been to figure this out on my own). Thanks very much, dlarkin77

              G Offline
              G Offline
              Gary Wheeler
              wrote on last edited by
              #6

              You're very welcome; glad I could help. Regular expressions are handy for this sort of thing, but they do have one hazard: you can end up spending more time debugging your regular expression than you would have just doing dumb old-fashioned editting.

              Software Zen: delete this;

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups