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. Better obfuscation?

Better obfuscation?

Scheduled Pinned Locked Moved The Lounge
csharpdebuggingtutorialquestion
9 Posts 9 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.
  • V Offline
    V Offline
    VE2
    wrote on last edited by
    #1

    In the MS doc "New features in C# 4.0" there is this example of applying "Betterness rules" to overload resolution... Given these overloads of M.. M(string s, int i = 1); M(object o); M(int i, string s = “Hello”); M(int i); which does M(5) use? Given these overloads, we can see the working of the betterness rules. M(string,int) is not applicable because 5 doesn’t convert to string. M(int,string) is applicable because its second parameter is optional, and so, obviously are M(object) and M(int). M(int,string) and M(int) are both better than M(object) because the conversion from 5 to int is better than the conversion from 5 to object. Finally M(int) is better than M(int,string) because no optional arguments are omitted. Thus the method that gets called is M(int). Ok, clear enough for this example...but I hope I don't have to debug code that uses this feature a lot!

    73

    L A M T P 7 Replies Last reply
    0
    • V VE2

      In the MS doc "New features in C# 4.0" there is this example of applying "Betterness rules" to overload resolution... Given these overloads of M.. M(string s, int i = 1); M(object o); M(int i, string s = “Hello”); M(int i); which does M(5) use? Given these overloads, we can see the working of the betterness rules. M(string,int) is not applicable because 5 doesn’t convert to string. M(int,string) is applicable because its second parameter is optional, and so, obviously are M(object) and M(int). M(int,string) and M(int) are both better than M(object) because the conversion from 5 to int is better than the conversion from 5 to object. Finally M(int) is better than M(int,string) because no optional arguments are omitted. Thus the method that gets called is M(int). Ok, clear enough for this example...but I hope I don't have to debug code that uses this feature a lot!

      73

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You should look at some of the embedded C code I have - obfuscation isn't needed. :sigh:

      Join the cool kids - Come fold with us[^]

      1 Reply Last reply
      0
      • V VE2

        In the MS doc "New features in C# 4.0" there is this example of applying "Betterness rules" to overload resolution... Given these overloads of M.. M(string s, int i = 1); M(object o); M(int i, string s = “Hello”); M(int i); which does M(5) use? Given these overloads, we can see the working of the betterness rules. M(string,int) is not applicable because 5 doesn’t convert to string. M(int,string) is applicable because its second parameter is optional, and so, obviously are M(object) and M(int). M(int,string) and M(int) are both better than M(object) because the conversion from 5 to int is better than the conversion from 5 to object. Finally M(int) is better than M(int,string) because no optional arguments are omitted. Thus the method that gets called is M(int). Ok, clear enough for this example...but I hope I don't have to debug code that uses this feature a lot!

        73

        A Offline
        A Offline
        Anthony Mushrow
        wrote on last edited by
        #3

        That's no feature, more like a disaster waiting to happen, well maybe not quit a disaster. I just hope you can turn up the warnings to point this kind of thing out, like when you don't explicitly cast a float to an int for example.

        My current favourite phrase: I've seen better!

        -SK Genius

        Source Indexing and Symbol Servers Vehicle Simulation Demo - Mostly Works

        1 Reply Last reply
        0
        • V VE2

          In the MS doc "New features in C# 4.0" there is this example of applying "Betterness rules" to overload resolution... Given these overloads of M.. M(string s, int i = 1); M(object o); M(int i, string s = “Hello”); M(int i); which does M(5) use? Given these overloads, we can see the working of the betterness rules. M(string,int) is not applicable because 5 doesn’t convert to string. M(int,string) is applicable because its second parameter is optional, and so, obviously are M(object) and M(int). M(int,string) and M(int) are both better than M(object) because the conversion from 5 to int is better than the conversion from 5 to object. Finally M(int) is better than M(int,string) because no optional arguments are omitted. Thus the method that gets called is M(int). Ok, clear enough for this example...but I hope I don't have to debug code that uses this feature a lot!

          73

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Can you imagine the reaction if you were doing a code review and came across something like that, the writer of such crap would be howled out of the building. Just b/c a language will allow you to write crap does not mean you should.

          Never underestimate the power of human stupidity RAH

          Sander RosselS 1 Reply Last reply
          0
          • M Mycroft Holmes

            Can you imagine the reaction if you were doing a code review and came across something like that, the writer of such crap would be howled out of the building. Just b/c a language will allow you to write crap does not mean you should.

            Never underestimate the power of human stupidity RAH

            Sander RosselS Offline
            Sander RosselS Offline
            Sander Rossel
            wrote on last edited by
            #5

            Mycroft Holmes wrote:

            Just b/c a language will allow you to write crap does not mean you should.

            That would make the lounge largely superfluous ;)

            It's an OO world.

            1 Reply Last reply
            0
            • V VE2

              In the MS doc "New features in C# 4.0" there is this example of applying "Betterness rules" to overload resolution... Given these overloads of M.. M(string s, int i = 1); M(object o); M(int i, string s = “Hello”); M(int i); which does M(5) use? Given these overloads, we can see the working of the betterness rules. M(string,int) is not applicable because 5 doesn’t convert to string. M(int,string) is applicable because its second parameter is optional, and so, obviously are M(object) and M(int). M(int,string) and M(int) are both better than M(object) because the conversion from 5 to int is better than the conversion from 5 to object. Finally M(int) is better than M(int,string) because no optional arguments are omitted. Thus the method that gets called is M(int). Ok, clear enough for this example...but I hope I don't have to debug code that uses this feature a lot!

              73

              T Offline
              T Offline
              TorstenH
              wrote on last edited by
              #6

              don't do funny things - there are certain ways to protect your software: ProGuard Obfuscator @ sourceforge[^] How-to obfuscate with ProGuard[^] and if you want to make sure your software is only used correctly, use dongles: Dongle @ wikipedia[^] regards Torsten

              I never finish anyth...

              1 Reply Last reply
              0
              • V VE2

                In the MS doc "New features in C# 4.0" there is this example of applying "Betterness rules" to overload resolution... Given these overloads of M.. M(string s, int i = 1); M(object o); M(int i, string s = “Hello”); M(int i); which does M(5) use? Given these overloads, we can see the working of the betterness rules. M(string,int) is not applicable because 5 doesn’t convert to string. M(int,string) is applicable because its second parameter is optional, and so, obviously are M(object) and M(int). M(int,string) and M(int) are both better than M(object) because the conversion from 5 to int is better than the conversion from 5 to object. Finally M(int) is better than M(int,string) because no optional arguments are omitted. Thus the method that gets called is M(int). Ok, clear enough for this example...but I hope I don't have to debug code that uses this feature a lot!

                73

                P Offline
                P Offline
                peterchen
                wrote on last edited by
                #7

                I'd rather have an "that's ambigous, make up your mind" for the last two cases.

                FILETIME to time_t
                | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

                1 Reply Last reply
                0
                • V VE2

                  In the MS doc "New features in C# 4.0" there is this example of applying "Betterness rules" to overload resolution... Given these overloads of M.. M(string s, int i = 1); M(object o); M(int i, string s = “Hello”); M(int i); which does M(5) use? Given these overloads, we can see the working of the betterness rules. M(string,int) is not applicable because 5 doesn’t convert to string. M(int,string) is applicable because its second parameter is optional, and so, obviously are M(object) and M(int). M(int,string) and M(int) are both better than M(object) because the conversion from 5 to int is better than the conversion from 5 to object. Finally M(int) is better than M(int,string) because no optional arguments are omitted. Thus the method that gets called is M(int). Ok, clear enough for this example...but I hope I don't have to debug code that uses this feature a lot!

                  73

                  P Offline
                  P Offline
                  patbob
                  wrote on last edited by
                  #8

                  That's Microsoft for you.. relearning the wisdom of the past by making all the same mistakes. They can't even be original enough to make new mistakes :D

                  patbob

                  1 Reply Last reply
                  0
                  • V VE2

                    In the MS doc "New features in C# 4.0" there is this example of applying "Betterness rules" to overload resolution... Given these overloads of M.. M(string s, int i = 1); M(object o); M(int i, string s = “Hello”); M(int i); which does M(5) use? Given these overloads, we can see the working of the betterness rules. M(string,int) is not applicable because 5 doesn’t convert to string. M(int,string) is applicable because its second parameter is optional, and so, obviously are M(object) and M(int). M(int,string) and M(int) are both better than M(object) because the conversion from 5 to int is better than the conversion from 5 to object. Finally M(int) is better than M(int,string) because no optional arguments are omitted. Thus the method that gets called is M(int). Ok, clear enough for this example...but I hope I don't have to debug code that uses this feature a lot!

                    73

                    S Offline
                    S Offline
                    Stefan_Lang
                    wrote on last edited by
                    #9

                    VE2 wrote:

                    M(int i, string s = “Hello”);
                    M(int i);

                    Is that actually valid code in C#? In C++ it wouldn't hold, because, like you said, M(5) would invoke M(int), and the only way to invoke M(int,string) would be to use two arguments, making the default argument "Hello" obsolete!

                    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