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. General Programming
  3. C#
  4. meta data and attribute

meta data and attribute

Scheduled Pinned Locked Moved C#
csharpdotnetquestion
19 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.
  • N natsuyaki

    If there is a custom attribute. It displays ".custom instance void[xxx]xxxxxx.xxxxAtribute::cctor()=........."

    G Offline
    G Offline
    George_George
    wrote on last edited by
    #9

    Great natsuyaki! How to identify which parts of IL code are dealing with attribute definition? Any fields or keywords in IL identify? regards, George

    1 Reply Last reply
    0
    • G George_George

      Thanks natsuyaki! I think you monitor the attribute in IL using ILDasm tool, not the below tool, right? http://www.aisto.com/roeder/dotnet/ (the tool has a confusing name relfector, which makes me confused in the discussion context) regards, George

      N Offline
      N Offline
      natsuyaki
      wrote on last edited by
      #10

      :) but it's really using reflection.~

      G 1 Reply Last reply
      0
      • N natsuyaki

        :) but it's really using reflection.~

        G Offline
        G Offline
        George_George
        wrote on last edited by
        #11

        Thanks natsuyaki, 1. Yes, it is using relection, but not using the tool I quoted. From this tool, could you see any attributes? 2. Any comments to, http://www.codeproject.com/script/Forums/View.aspx?fid=1649&msg=2547385[^] regards, George

        N 1 Reply Last reply
        0
        • G George_George

          Thanks natsuyaki, 1. Yes, it is using relection, but not using the tool I quoted. From this tool, could you see any attributes? 2. Any comments to, http://www.codeproject.com/script/Forums/View.aspx?fid=1649&msg=2547385[^] regards, George

          N Offline
          N Offline
          natsuyaki
          wrote on last edited by
          #12

          The following IL code is retrieved by ILDasm: class with SerializableAttribute: .class public auto ansi serializable beforefieldinit ClassLibrary2.Class1 extends [mscorlib]System.Object { } // end of class ClassLibrary2.Class1 method with ObsoleteAttribute: .method public hidebysig instance void s() cil managed { .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = ( 01 00 00 00 ) // code size 2 (0x2) .maxstack 8 IL_0000: nop IL_0001: ret } // end of method Class1::s

          G 1 Reply Last reply
          0
          • N natsuyaki

            The following IL code is retrieved by ILDasm: class with SerializableAttribute: .class public auto ansi serializable beforefieldinit ClassLibrary2.Class1 extends [mscorlib]System.Object { } // end of class ClassLibrary2.Class1 method with ObsoleteAttribute: .method public hidebysig instance void s() cil managed { .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = ( 01 00 00 00 ) // code size 2 (0x2) .maxstack 8 IL_0000: nop IL_0001: ret } // end of method Class1::s

            G Offline
            G Offline
            George_George
            wrote on last edited by
            #13

            Thanks natsuyaki, 1. It is great! Are there any tool for us to use to retrieve readable meta data and attribute information without using ILDasm tool? 2. Generally speaking, from what pattern, could you identify a part of code in IL is dealing with attribute -- like the following code,

            .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = ( 01 00 00 00 )

            regards, George

            N 1 Reply Last reply
            0
            • G George_George

              Thanks natsuyaki, 1. It is great! Are there any tool for us to use to retrieve readable meta data and attribute information without using ILDasm tool? 2. Generally speaking, from what pattern, could you identify a part of code in IL is dealing with attribute -- like the following code,

              .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = ( 01 00 00 00 )

              regards, George

              N Offline
              N Offline
              natsuyaki
              wrote on last edited by
              #14

              1. i don't really know, maybe the tool you mentioned can. 2. I wrote a custom attribute PuginAttribute. All the plugins must add this attribute. So, I can get it at runtime by GetCustomAttribute(), if exists, that mean this is a plugin. [Plugin(true)] public class SamplePlugin:IPlugin { ..... .... IL code would be displayed like this: .custom instance void [XXXX]aaa.bbb.ccc.PluginAttribute::.ctor(bool) = ( 01 00 00 00 )

              G 1 Reply Last reply
              0
              • N natsuyaki

                1. i don't really know, maybe the tool you mentioned can. 2. I wrote a custom attribute PuginAttribute. All the plugins must add this attribute. So, I can get it at runtime by GetCustomAttribute(), if exists, that mean this is a plugin. [Plugin(true)] public class SamplePlugin:IPlugin { ..... .... IL code would be displayed like this: .custom instance void [XXXX]aaa.bbb.ccc.PluginAttribute::.ctor(bool) = ( 01 00 00 00 )

                G Offline
                G Offline
                George_George
                wrote on last edited by
                #15

                Thanks natsuyaki, 1. Looks like attribute will be treated as a private class in IL? 2. I think not all built-in attributes will be left in final IL, what kinds of built-in attributes will be in final IL, could you list some please? :-) regards, George

                N 1 Reply Last reply
                0
                • G George_George

                  Thanks natsuyaki, 1. Looks like attribute will be treated as a private class in IL? 2. I think not all built-in attributes will be left in final IL, what kinds of built-in attributes will be in final IL, could you list some please? :-) regards, George

                  N Offline
                  N Offline
                  natsuyaki
                  wrote on last edited by
                  #16

                  1.some like that 2.some attributes reprent for "mark",and some for "deal". That means, some attributes are use for comment the content, some for the compiler that the content will be processed by the mean mentioned in the attributes. So, some keep there and some disappeared. This is my point of view. For the precise definition, please view msdn.

                  G 1 Reply Last reply
                  0
                  • N natsuyaki

                    1.some like that 2.some attributes reprent for "mark",and some for "deal". That means, some attributes are use for comment the content, some for the compiler that the content will be processed by the mean mentioned in the attributes. So, some keep there and some disappeared. This is my point of view. For the precise definition, please view msdn.

                    G Offline
                    G Offline
                    George_George
                    wrote on last edited by
                    #17

                    Thanks natsuyaki, I agree with your points. Could you list some of the attribute names which do not disappear in IL please? Sorry, my knowledge of attribute is limited. :-) regards, George

                    N 1 Reply Last reply
                    0
                    • G George_George

                      Thanks natsuyaki, I agree with your points. Could you list some of the attribute names which do not disappear in IL please? Sorry, my knowledge of attribute is limited. :-) regards, George

                      N Offline
                      N Offline
                      natsuyaki
                      wrote on last edited by
                      #18

                      That's a big work to do.... You may be interested in this book: Applied .Net Attributes by Jason Bock Sorry, here we go. And this could also help:http://www.codeproject.com/KB/cs/attributes.aspx

                      modified on Monday, May 12, 2008 4:30 AM

                      G 1 Reply Last reply
                      0
                      • N natsuyaki

                        That's a big work to do.... You may be interested in this book: Applied .Net Attributes by Jason Bock Sorry, here we go. And this could also help:http://www.codeproject.com/KB/cs/attributes.aspx

                        modified on Monday, May 12, 2008 4:30 AM

                        G Offline
                        G Offline
                        George_George
                        wrote on last edited by
                        #19

                        Thanks natsuyaki, The link you provided can not be opened, could you double check please? :-) regards, George

                        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