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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Can I compile only some line of code?

Can I compile only some line of code?

Scheduled Pinned Locked Moved C#
question
11 Posts 6 Posters 1 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.
  • C CoderForEver

    Hey buddys I was making a POS Software ... and it realy huge size ... & wen i made some changes and want to run it ... it takes lot time ... So I was hoping if there is a way to just compile the modified line of code and then to run it ... I thought it will not compile the hole code again ? is that possible?

    D Offline
    D Offline
    dan sh
    wrote on last edited by
    #2

    Are you looking for Snippet compiler[^]?

    50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

    C 1 Reply Last reply
    0
    • D dan sh

      Are you looking for Snippet compiler[^]?

      50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

      C Offline
      C Offline
      CoderForEver
      wrote on last edited by
      #3

      I dont know what it is ... and I followed the link but there is just a picture of some lines of code ... can u tell me briefly please?

      D 1 Reply Last reply
      0
      • C CoderForEver

        I dont know what it is ... and I followed the link but there is just a picture of some lines of code ... can u tell me briefly please?

        D Offline
        D Offline
        dan sh
        wrote on last edited by
        #4

        Below that image, there is are download links based on the framework version. Now, instead of compiling you entire project, you can place the lines of code inside that main method in Snippet compiler and run as you would do in the VS.

        50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

        1 Reply Last reply
        0
        • C CoderForEver

          Hey buddys I was making a POS Software ... and it realy huge size ... & wen i made some changes and want to run it ... it takes lot time ... So I was hoping if there is a way to just compile the modified line of code and then to run it ... I thought it will not compile the hole code again ? is that possible?

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

          CoderForEver wrote:

          I was making a POS Software ... and it realy huge size ..

          A single executable? How large is "huge"? Are we talking more than 10 Mb?

          CoderForEver wrote:

          So I was hoping if there is a way to just compile the modified line of code and then to run it ..

          Sounds like you want to divide your project into different subprojects. Try and move some of your code to an assembly that can be loaded during runtime. That way you only need to (re)compile the assembly that you're working on, as opposed to the entire codebase.

          I are Troll :suss:

          C 1 Reply Last reply
          0
          • C CoderForEver

            Hey buddys I was making a POS Software ... and it realy huge size ... & wen i made some changes and want to run it ... it takes lot time ... So I was hoping if there is a way to just compile the modified line of code and then to run it ... I thought it will not compile the hole code again ? is that possible?

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #6

            You have three options: 0) Put the code you want to test into a separate assembly and just compile that assembly (easiest/cheapest way out). 1) Use compiler definitions to omit code from the compile (NOT recommended). 2) Buy some decent hardware - 8gb of RAM, the fastest quad-core CPU you can find, a large SSD (at least 128gb), and a normal SATA drive to put the system swap file on. Finally, use Weven64 for your OS.

            .45 ACP - because shooting twice is just silly
            -----
            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

            1 Reply Last reply
            0
            • C CoderForEver

              Hey buddys I was making a POS Software ... and it realy huge size ... & wen i made some changes and want to run it ... it takes lot time ... So I was hoping if there is a way to just compile the modified line of code and then to run it ... I thought it will not compile the hole code again ? is that possible?

              V Offline
              V Offline
              vtchris peterson
              wrote on last edited by
              #7

              Another technique is to use the "Edit and Continue" functionality of VS. Set a breakpoint near the code to be modified, when it hits, you can make your edits and when you continue running (or step), the changes are recompiled. This approach is somewhat limited (i.e. you can't add a new method, alter a try/catch, etc -- the IDE will tell you when you've made a change that requires a full build), but for tweaking procedural code, this is a great technique (and it has the advantage of forcing you to step through the code and make sure it's doing what you expect) :)

              1 Reply Last reply
              0
              • C CoderForEver

                Hey buddys I was making a POS Software ... and it realy huge size ... & wen i made some changes and want to run it ... it takes lot time ... So I was hoping if there is a way to just compile the modified line of code and then to run it ... I thought it will not compile the hole code again ? is that possible?

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

                That's more or less what incremental builds are for, but they are on an Assembly (project) level. If your "huge" application isn't already broken up into several projects, I suggest you do so.

                1 Reply Last reply
                0
                • L Lost User

                  CoderForEver wrote:

                  I was making a POS Software ... and it realy huge size ..

                  A single executable? How large is "huge"? Are we talking more than 10 Mb?

                  CoderForEver wrote:

                  So I was hoping if there is a way to just compile the modified line of code and then to run it ..

                  Sounds like you want to divide your project into different subprojects. Try and move some of your code to an assembly that can be loaded during runtime. That way you only need to (re)compile the assembly that you're working on, as opposed to the entire codebase.

                  I are Troll :suss:

                  C Offline
                  C Offline
                  CoderForEver
                  wrote on last edited by
                  #9

                  the Executable is not huge ... but there are a lot of forms .... in which they contain a lot of buttons and pictures to make our pos system high quality graphics ... so when I i change some line of code ... it debugs the whole program ... but I I want to compile that line of code only and to run it .... I hope u got what i meant... Thank you for your kind help

                  L 1 Reply Last reply
                  0
                  • C CoderForEver

                    Hey buddys I was making a POS Software ... and it realy huge size ... & wen i made some changes and want to run it ... it takes lot time ... So I was hoping if there is a way to just compile the modified line of code and then to run it ... I thought it will not compile the hole code again ? is that possible?

                    C Offline
                    C Offline
                    CoderForEver
                    wrote on last edited by
                    #10

                    Thank you everybody ... am working on ur suggestions.

                    1 Reply Last reply
                    0
                    • C CoderForEver

                      the Executable is not huge ... but there are a lot of forms .... in which they contain a lot of buttons and pictures to make our pos system high quality graphics ... so when I i change some line of code ... it debugs the whole program ... but I I want to compile that line of code only and to run it .... I hope u got what i meant... Thank you for your kind help

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

                      Try to move a form to a DLL, and load it from that assembly. That way you'll only have to compile the assemblies that are actually modified. As an example, add a new class-library to the project. Next, create a form in that class library. Lastly, add a reference from your main-project to the new classlibrary - you'll see that you can access your form and display it within the original project. If you make any changes in the form, remember to recompile the classlibrary too. Resources like images can also be loaded at runtime :)

                      I are Troll :suss:

                      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