Skip to main content
  • 94 Accesses

Abstract

In this chapter, I’ll walk through a number of code snippets written in various .NET languages and demonstrate what the differences are in their assemblies. I’ll compare and contrast debug and release builds. You’ll get a chance to look at how different language constructs are translated into CIL by the different compilers. I’ll show you how a piece of code in one language may not create the output you expect. As you’ll see throughout this chapter, what you code is not always what you get. By knowing CIL, you’ll be able to figure out what’s really going on.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 49.95
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 49.95
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Reference

  1. Technically, the C# compiler will tell you if a variable is not being used as is the case with i, but it won’t be able to make the optimization with someType.

    Google Scholar 

  2. In this case, it’s easy to see that i will be 1 when the method is finished, but in more complex cases it may be nice to see the value before the method exits.

    Google Scholar 

  3. Later on, I’ll demonstrate a more convoluted example with overridden and overloaded methods.

    Google Scholar 

  4. For a listing of the optimizations that C#’s compiler will perform, please read the section “Optimizations” in Chapter 36 of Eric Gunnerson’s book, A Programmer’s Introduction to C#, Second Edition (Apress, 2001).

    Google Scholar 

  5. See Section 8.4 of the Visual Basic Language Specification of the.NET SDK.

    Google Scholar 

  6. This isn’t possible with ATL out of the box; see http: //www.sellsbrothers.com/tools/default.aspx for a workaround to this problem if you run into it and you’re still coding COM servers in ATL.

    Google Scholar 

  7. The reason this worked with the Oberon example in Chapter 1 is because the interface and class methods matched, so the runtime was able to determine that the interface was implemented correctly.

    Google Scholar 

  8. I think that most vendors will do this before they publish their assemblies. However, it doesn’t hurt to do a quick check on them before you use them—the time it takes to run PEVerify on an assembly relative to the time it may take to figure out why something isn’t working as expected is worth it in my book.

    Google Scholar 

  9. I have to admit, I’ve used it on VB projects in the past, primarily in the error handling code itself. But I’ve made a resolution to never use this feature as long as I live, especially after 216 seeing what happens when it’s used!

    Google Scholar 

  10. Right before this book was published, a research paper was released on adding constructs similar to active objects to C#. It’s titled “Modern Concurrency Abstractions for C#,” and you can download it athttp://research.microsoft.com/Users/luca/Papers/Polyphony%20ECOOP.A4.pd-F.

    Google Scholar 

  11. Technically, this is documented behavior according to a white paper from the makers of the Oberon compiler for.NET (http: //www. oberon. ethz. ch/oberon. net/whitepaper/ ActiveoberonNetWhitePaper. pdf). See Section 6.1 in the paper for details.

    Google Scholar 

  12. Unfortunately, IntelliSense won’t show the property methods, even though they’re public. But if you simply type them in, everything will compile normally.

    Google Scholar 

Download references

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2002 Jason Bock

About this chapter

Cite this chapter

Bock, J. (2002). .NET Languages and CIL. In: CIL Programming: Under the Hood™ of .NET. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4302-0845-7_6

Download citation

  • DOI: https://doi.org/10.1007/978-1-4302-0845-7_6

  • Publisher Name: Apress, Berkeley, CA

  • Print ISBN: 978-1-4302-5156-9

  • Online ISBN: 978-1-4302-0845-7

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics